Announcement

Collapse
No announcement yet.

WS_SysMenu to WS_Popup

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • WS_SysMenu to WS_Popup

    In working on EZFree screen saver code I wanted to toggle from WS_SysMenu to WS_Popup. The solution might be of interest to others ..


    I had this code which changes from %WS_OverLappedWIndow to %WS_Popup ...

    Code:
    SetWindowLong hDlg, %GWL_Style, GetWindowLong(hDlg,%GWL_Style) Xor %WS_OverlappedWindow Xor %WS_Popup

    Making a simple substitution of styles DOES NOT change from %WS_SysMenu to %WS_Popup ...

    Code:
    SetWindowLong hDlg, %GWL_Style, GetWindowLong(hDlg,%GWL_Style) Xor %WS_SysMenu Xor %WS_Popup

    I had to add WS_Caption like this ...

    Code:
    SetWindowLong hDlg, %GWL_Style, GetWindowLong(hDlg,%GWL_Style) Xor %WS_SysMenu Xor %WS_Popup Xor %WS_Caption

  • #2
    Please note some style changes made via SetWindowLong (GWL_STYLE or GWL_EXSTYLE) require you to repaint the window to see the changes:
    Certain 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.
    Source: SDK on disk

    If you are not sure if it is required, you can just make the call... it is harmless if nothing is required.

    You might also want to look at using SetWindowLongPtr() to be compatible wth 64-bit Windows, if you plan on porting your code to a 64-bit compiler.

    Lastly, SetWindowLong() will return non-zero (the previous value of the attribute set) when it succeeds. If the function fails it returns zero and GetLastError() can help you pinpoint your problem.

    .
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment

    Working...
    X