Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 6021 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hmm...how come this doesnt work:
char* CButtonControl::GetText()
	char* buffer = NULL ;
	int length ;

	length = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0) ;
	SendMessage(hwnd, WM_GETTEXT, length, (LPARAM)buffer) ;

	return buffer ;


Share this post

Link to post
Share on other sites
From the documentation for WM_GETTEXT:


An application sends a WM_GETTEXT message to copy the text that corresponds to a window into a buffer provided by the caller.

The most important part to observe in the above is "a buffer provided by the caller"

You already get the length using GETTEXTLENGTH so you know how big to make the buffer, so just after that do something like:

buffer = new char[length];

and then remember to delete[] that buffer when the caller of your function has finished with it.

If CButtonControl inherits from any MFC classes, make sure that the hWnd is valid (use CWnd::GetSafeHwnd).

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!