Jump to content

help ? Can't switch $WS_EX_TOPMOST ?


xbtsw
 Share

Recommended Posts

i hope i can use the checkbox to switch the window between on top and not on top, but the code doesn't work. anyone can help me with my code?

Thanks~

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
$Main_Form = GUICreate("test", 573, 340, 244, 129, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))
$always_on_top = GUICtrlCreateCheckbox("always on top", 446, 93, 97, 17)
GUICtrlSetOnEvent($always_on_top, "_setalwaysontop")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _setalwaysontop()
    Local $tmp_set_ontop
    $tmp_set_ontop = GUICtrlRead($always_on_top)
    Switch $tmp_set_ontop
        Case $GUI_CHECKED
            GUISetStyle (-1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
        Case $GUI_UNCHECKED
            GUISetStyle (-1, 0)
    EndSwitch
EndFunc   ;==>_setalwaysontop
Func _exit()
    DirRemove(@ScriptDir & "\Data\", 1)
    Exit
EndFunc   ;==>_exit
Link to comment
Share on other sites

Why not use WinSetOnTop?

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
$Main_Form = GUICreate("test", 573, 340, 244, 129, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))
$always_on_top = GUICtrlCreateCheckbox("always on top", 446, 93, 97, 17)
GUICtrlSetOnEvent($always_on_top, "_setalwaysontop")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _setalwaysontop()
    Local $tmp_set_ontop
    $tmp_set_ontop = GUICtrlRead($always_on_top)
    Switch $tmp_set_ontop
        Case $GUI_CHECKED
            WinSetOnTop($Main_Form, "", 1)
        Case $GUI_UNCHECKED
            WinSetOnTop($Main_Form, "", 0)
    EndSwitch
EndFunc   ;==>_setalwaysontop
Func _exit()
    DirRemove(@ScriptDir & "\Data\", 1)
    Exit
EndFunc   ;==>_exit

"be smart, drink your wine"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...