Jump to content

Move a GUI


Recommended Posts

Hey,

I use this script:

#include <GuiConstants.au3>
GuiCreate("My message box", 400, 78,(@DesktopWidth-400)/2, (@DesktopHeight-78)/2, $WS_POPUP + $WS_DLGFRAME)
$Button = GuiCtrlCreateButton("X", 370, 0, 30, 30)
GUICtrlSetFont($Button, 24)
$Label = GuiCtrlCreateLabel("", 0, 0, 370, 30 )
GUICtrlSetBkColor(-1,0x8080ff)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
       Case $msg = $Button
        ExitLoop
    EndSelect
WEnd

It works perfect but now I would move the GUI with my mouse...

How can I do this?

Greetz,

YoseMite

Link to comment
Share on other sites

Why not just use

#include <GuiConstants.au3>
GuiCreate("My message box", 400, 78,(@DesktopWidth-400)/2, (@DesktopHeight-78)/2)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
       Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    EndSelect
WEnd

And you can move it anywhere you want.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Because I doesn't wanna to see the GUI.

What do you want to see


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

#include <GuiConstants.au3>
$GUI = GUICreate("My message box", 400, 78, -1, -1, BitOR($WS_POPUPWINDOW, $WS_BORDER))
$Button = GUICtrlCreateButton("X", 370, 0, 30, 30)
GUICtrlSetFont($Button, 24)
$Label = GUICtrlCreateLabel("", 0, 0, 370, 30)
GUICtrlSetBkColor(-1, 0x8080ff)
$Label2 = GUICtrlCreateLabel("This is a test, this is only a test", 0, 30, 400, 48)
GUISetState()
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $Button
         Exit
      Case $msg = $Label Or $msg = $Label2
         _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

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Link to comment
Share on other sites

  • Moderators

#include <GuiConstants.au3>
$GUI = GUICreate("My message box", 400, 78, -1, -1, BitOR($WS_POPUPWINDOW, $WS_BORDER))
$Button = GUICtrlCreateButton("X", 370, 0, 30, 30)
GUICtrlSetFont($Button, 24)
$Label = GUICtrlCreateLabel("", 0, 0, 370, 30)
GUICtrlSetBkColor(-1, 0x8080ff)
$Label2 = GUICtrlCreateLabel("This is a test, this is only a test", 0, 30, 400, 48)
GUISetState()
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $Button
         Exit
      Case $msg = $Label Or $msg = $Label2
         _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
Awesome!!, I was sitting here trying to mess with it, and had it moving, but constantly lost focus!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...