Simon Cooke dug back into his memory and asked,
"Doesn't calling SetWindowPos
with SWP_
cause a recreate
and re-apply of the styles?"
The
SWP_
flag does not recreate anything,
but it does reapply the styles, as far as it knows.
Recall that the bits in the window style break into two parts. There are the styles managed by the window manager, which are in the upper 16 bits, and there are the styles that are specific to each control, which are in the lower 16 bits.
The window manager knows about the styles that it manages,
but it has no clue about the styles that are specific to each
control.
It has no idea that the
MCIWNDF_
style controls the
toolbar in an MCI window,
or that the
ES_
style controls the alignment of text
in an edit control.
The
SWP_
flag tells the window manager,
"Hey, I changed some styles that affect the non-client area of the window
(the window frame).
Could you go and re-read those styles and apply them to the window?
Thanks."
That's sort of implied in the name: "Frame changed."
If you want a control to re-inspect the window styles and adjust
its behavior in response,
you need to do something control-specific.
The control might have a custom message you can send it to say,
"Hey, I changed some styles that afect the client area of the window.
Could you go and re-read those styles and apply them to the window?
Thanks."
Or there may be special messages specifically for changing styles,
such as EM_
.
The fancier windows may do it automatically on receipt of the
WM_
messages.