Home > Articles > Operating Systems, Server

The Secret Life of GetWindowText

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
GetWindowText is caught between rules, and therefore how it does its job is based on whether window classes are managing their text manually or letting the system do it. But why are things like this, and what if you don't like it? Raymond Chen describes the the history of this oft-maligned function.

How windows manage their text

THERE ARE TWO ways window classes can manage their text. They can do it manually or they can let the system do it. The default is to let the system do it.

If a window class lets the system manage its text, the system will do the following:

  • Default handling of the WM_NCCREATE message takes the lpWindowName parameter passed to CreateWindow/Ex and saves the string in a “special place.”
  • Default handling of the WM_GETTEXT message retrieves the string from that special place.
  • Default handling of the WM_SETTEXT message copies the string to that special place.

On the other hand, if a window class manages its window text manually, the system does not do any special handling, and it is the window class’s responsibility to respond to the WM_GETTEXT/WM_SETTEXT messages and return/save the strings explicitly.

Frame windows typically let the system manage their window text. Custom controls typically manage their window text manually.

  • Share ThisShare This
  • Save To Your Account

Discussions

comments powered by Disqus

Related Resources

What Apple and Every Apple Support Professional Must Do
By on April 14, 2012Comments

The Flashback attack is a sign of more to come.  Are you prepared to see your Apple computer (or those you support) as functional UNIX devices that require special skills?


Flashbacks On Your Mac?
By on April 9, 2012Comments
Unless you live under a rock, by now, you should have learned about the Flashback trojan that has compromised over 600,000 Apple computers.

Care to learn what you can do?  Read on...


Post-PC Era--Really???
By on March 8, 2012Comments

The much hyped iPad 3 introduction leaves Traenk a bit bored.


See All Related Blogs