The Secret Life of GetWindowText
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.