News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

change style to STATIC control?

Started by RHL, April 09, 2012, 03:59:05 AM

Previous topic - Next topic

RHL

Hello guys , i have a static control and want change the windows style in runtime
how to do it?   :bg
I try do it with SendMessage:

invoke SendMessage,HANDLECONTROL,WS_BORDER,0,0

but I cannot...
thanks :)


dedndave

        INVOKE  GetWindowLong,HANDLECONTROL,GWL_STYLE
        or      eax,WS_BORDER
        INVOKE  SetWindowLong,HANDLECONTROL,GWL_STYLE,eax


you also have to call SetWindowPos to force it to re-draw the window frame
(more correctly, to force the cached style value to be updated)

Swp_Flags = SWP_NOZORDER or SWP_NOMOVE or SWP_NOSIZE or SWP_FRAMECHANGED or SWP_SHOWWINDOW
        xor     eax,eax
        INVOKE  SetWindowPos,HANDLECONTROL,eax,eax,eax,eax,eax,Swp_Flags


EDIT: added SWP_SHOWWINDOW

RHL

 :eek
dedndave simply thank you very much, :|
all that just to change the style of a control :S
thanks!

RHL

dedndave a question... why use SetwindowPos?... : P
the API moves a windows or control, but in that code is not moved  ( the coordinates are  zero ) : P

dedndave

in the documentation for SetWindowLong
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx

QuoteCertain window data is cached, so changes you make using SetWindowLong will not take effect
until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you
must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly.

however, they fail to mention what other flags should be used
SetWindowPos has several optional flags - it is sometimes difficult to figure out which ones you need - lol
you may have to try different combinations   :P

the flags i mention above...
SWP_NOZORDER - no change in Z-order (hWndInsertAfter parameter is ignored)
SWP_NOMOVE - do not move the window (position parameters are ignored)
SWP_NOSIZE - do not change window size (size parameters are ignored)
SWP_FRAMECHANGED - see SetWindowLong text, above
SWP_SHOWWINDOW - make window visible