Jump to content

Unmovable GUI


toonboon
 Share

Recommended Posts

i didnt see any GUI control styles for unmovable, but what about this?

#Include <GUIConstants.au3>
#Include <WindowsConstants.au3>

$GUI = GUICreate("Test GUI", 400, 400, -1, -1)
GuiSetState(@SW_SHOW)
Opt("GUIOnEventMode",1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$StartWinPos = WinGetPos("Test GUI", "")

While 1
    sleep(10)
    $WinPos = WinGetPos("Test GUI", "")

    If $StartWinPos[0] <> $WinPos[0] or $StartWinPos[1] <> $WinPos[1] Then
    WinMove("Test GUI", "", $StartWinPos[0], $StartWinPos[1])
    EndIf
WEnd


Func _Exit()
    Exit
EndFunc
Link to comment
Share on other sites

Another option to give you more control over what happens to the window -

#Include <GUIConstants.au3>
#Include <WindowsConstants.au3>
#include <Constants.au3>

$GUI = GUICreate("Test GUI", 400, 400, -1, -1)
GuiSetState(@SW_SHOW)
Opt("GUIOnEventMode",1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$pos = WinGetPos($GUI)

GUIRegisterMsg($WM_WINDOWPOSCHANGING, "MY_MSG")

While 1
    Sleep(1000)
WEnd

Func MY_MSG($hwnd, $msg, $wparam, $lparam)
    $tagWINDOWPOS = "hwnd hwnd;hwnd hwndInsertAfter;int x;int y;int cx;int cy;uint Flags"
    $wpos = DllStructCreate($tagWINDOWPOS, $lparam)
    DllStructSetData($wpos, "Flags", BitOR($SWP_NOMOVE, $SWP_NOSIZE))
    Return 0
EndFunc

Func _Exit()
    Exit
EndFunc
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...