Sign in to follow this  
Followers 0
fi3ldy

Using $WS_POPUP, ow to move the window?

10 posts in this topic

#1 ·  Posted (edited)

Hey, stuck again :)

Im using $WS_POPUP in my GUICreate, so i have no titlebar or menubar, whatever you want to call it.

I was wondering if there was a way to select a region in your window which is the same as being able to click on the titlebar/menubar and dragging/moving the window anywhere on your screen... (titlebar/menubar being bar with name of window and minimize, maximize and close buttons on (i know your not an idiot, im the one thats not sure on the proper name for titlebar/menubar))

Thanks alot guys.

Edited by fi3ldy

Share this post


Link to post
Share on other sites



take it there is no way :)? is there any alternatives u guys know of? and comments appriciated

Share this post


Link to post
Share on other sites

cheers for the repy, yes thats my point, theres no menu bar, so how can you move the window around on ur screen? :)

Share this post


Link to post
Share on other sites

Label + $GUI_WS_EX_PARENTDRAG

Share this post


Link to post
Share on other sites

Another way:

#include <GUIConstants.au3>

Const $HTCAPTION = 2
Const $WM_NCLBUTTONDOWN = 0xA1

$gui = GuiCreate("Test",200,60,-1,-1,BitOR($WS_POPUP,$WS_BORDER)) 
GUISetState(@SW_SHOW)

While 1
    Switch GuiGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            Drag()
    EndSwitch
WEnd

Func Drag()
    dllcall("user32.dll","int","ReleaseCapture")
    dllcall("user32.dll","int","SendMessage","hWnd", $gui,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)
EndFunc

Look here

Share this post


Link to post
Share on other sites

Really appriciated the hlpe im recieving!

Went for the second method, works awsome!

big kiss for u ;p

Share this post


Link to post
Share on other sites

...I was wondering if there was a way to select a region in your window...

Well, with Zedna's code the window will be dragged whenever you click anything in the GUI...even if you happen to

move the mouse while pressing a button or similar, the window will be moved as well. Using a label and simply setting

the style to $GUI_WS_EX_PARENTDRAG will limit the moving of the window to the label only (or region if you want)

instead of the entire window.

You're not even adding another line to your code as you're just setting the style, and after that everything is handled

automagically for you. Anyway, you can also add some checking to Zedna's code to do the same, to ensure that the

window is moved only when over a specific control, by using GUIGetCursorInfo I guess.

Share this post


Link to post
Share on other sites

Instead of using primary down you can use controls

i.e.

#include <GuiConstants.au3>

$GUI = GUICreate("test", 199, 74, -1, -1, BitOR($WS_POPUPWINDOW, $WS_BORDER))
$pic1 = GUICtrlCreatePic(@SystemDir & "\oobe\images\wpakey.jpg", -1, -1, 200, 75)
GUICtrlSetState($pic1, $GUI_DISABLE)
$Button_Exit = GUICtrlCreateLabel("X", 184, 0, 16, 17, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont($Button_Exit, Default, 600)
GUICtrlSetColor($Button_Exit, 0xFFFFFF)
$Button_Min = GUICtrlCreateLabel("_", 166, 0, 16, 17, $SS_CENTER, $WS_EX_STATICEDGE)
$Label = GUICtrlCreateLabel("", 0, 0, 166, 17)
GUICtrlSetBkColor($Label, $GUI_BKCOLOR_TRANSPARENT)
$Label2 = GUICtrlCreateLabel("", 0, 17, 199, 57)
GUICtrlSetBkColor($Label2, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($Button_Min, 0xFFFFFF)
GUICtrlSetFont($Button_Exit, Default, 600)
$Button_Text = GUICtrlCreateButton("Test", 30, 30, 50, 25)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button_Exit
            Exit
        Case $msg = $Button_Min
            GUISetState(@SW_MINIMIZE)
;~         Case $msg = $Label Or $msg = $Label2
        Case $msg = $Label
            _Drag($GUI)
    EndSelect
WEnd

Func _Drag($h_gui)
    DllCall("user32.dll", "int", "ReleaseCapture")
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $h_gui, "int", 0xA1, "int", 2, "int", 0)
EndFunc   ;==>_Drag

Modified from http://www.autoitscript.com/forum/index.ph...st&p=213007


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

i noticed that helge. ill try other methods you guys have given, thanks alot :)

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