Sign in to follow this  
Followers 0
toonboon

Unmovable GUI

7 posts in this topic

can I create an immovable GUI? I found the answer nowhere in the helpfile, so I thought posting it here might solve it.


[right]~What can I say, I'm a Simplistic person[/right]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

while 1
$array = wingetpos("unmovable gui")
If $array[0] <> $original width or $array[1] <> $originalheight then guisetcoord($array[2],$array[3],$originalwidth,$originalheight)
wend

Edit: forgot some stuff

Edited by youknowwho4eva

Giggity

Share this post


Link to post
Share on other sites

I figured that out just 5 seconds after you posted it :mellow:

I was wondering if there was something like GuiSetState(@SW_STICK) (or something like that...)


[right]~What can I say, I'm a Simplistic person[/right]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Ok thanks that code workt even better than perfectly =)


[right]~What can I say, I'm a Simplistic person[/right]

Share this post


Link to post
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

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  
Followers 0