Jump to content
Sign in to follow this  

GuiSetStyle, Remove styles

Recommended Posts

local $guiStyleoriginal = BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)
                    local $guiStyleremove = BitNOT($WS_POPUPWINDOW))
                    GUISetStyle(BitXor($guiStyleoriginal, $guiStyleremove))

The GUI is originally set with Topmost and Toolwindow. I then have it set with static positioning to remove the programs title bar which applies PopupWindow on top of Topmost and Toolwindow.

That works. However when I try to return it to just Topmost and Toolwindow it seems I fail. I've tried numerous ways and read multiple comments, the examples, and the wiki. I'm afraid I've only confused myself and now I'm not sure how to apply this.

Though, it could also be that once i apply this style, I'm unable to remove it without restarting.

Share this post

Link to post
Share on other sites

That one was a real bugger ^_^...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>
#include <Constants.au3>

Local $msg, $a_style
Local $hGUI = GUICreate("My GUI", Default, Default, Default, Default, $WS_POPUPWINDOW)
$c_button = GUICtrlCreateButton("Change Style", 10, 10, 100, 20)

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

    If $msg = $c_button Then
        $a_style = GUIGetStyle($hGUI)

        If BitAND($a_style[0], $WS_POPUPWINDOW) Then

            ; MSDN - SetWindowLong function
            ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).aspx
            ; 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.

            _WinAPI_SetWindowLong($hGUI, $GWL_STYLE, BitXOR($a_style[0], $WS_POPUPWINDOW))
            _WinAPI_SetWindowLong($hGUI, $GWL_EXSTYLE, BitOR($a_style[1], $WS_EX_TOOLWINDOW))

            ; MSDN - Extended Window Styles
            ; https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx
            ; WS_EX_TOPMOST = The window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function.

            _WinAPI_SetWindowPos($hGUI, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
            _WinAPI_SetWindowLong($hGUI, $GWL_STYLE, BitOR($a_style[0], $WS_POPUPWINDOW))
            _WinAPI_SetWindowLong($hGUI, $GWL_EXSTYLE, BitXOR($a_style[1], $WS_EX_TOOLWINDOW))

            _WinAPI_SetWindowPos($hGUI, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))




Edited by KaFu

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...