Sign in to follow this  
Followers 0
Bert

moving a window by dragging.

7 posts in this topic

WHat do I need to do to be able to move this toolbar by dragging it with the mouse? Having a little trouble here.

#include <GuiConstants.au3>
GuiCreate("MyGUI", 798, 20,1, 1 , $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GuiSetState()
$Menu_1 =   GUICtrlCreateMenu("&CTS Team Sites")
$Menu_1_Item_1 = GUICtrlCreateMenuItem("C&TS Management", $Menu_1)
$Menu_2 =   GUICtrlCreateMenu("&Exit")
$Menu_Item_2 = GUICtrlCreateMenuItem("exit", $Menu_2)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE or $msg = $Menu_Item_2
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites



WHat do I need to do to be able to move this toolbar by dragging it with the mouse? Having a little trouble here.

#include <GuiConstants.au3>
GuiCreate("MyGUI", 798, 20,1, 1 , $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GuiSetState()
$Menu_1 =   GUICtrlCreateMenu("&CTS Team Sites")
$Menu_1_Item_1 = GUICtrlCreateMenuItem("C&TS Management", $Menu_1)
$Menu_2 =   GUICtrlCreateMenu("&Exit")
$Menu_Item_2 = GUICtrlCreateMenuItem("exit", $Menu_2)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE or $msg = $Menu_Item_2
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd
Exit
You could do something like this

#include <GuiConstants.au3>
#include <misc.au3>
GUICreate("MyGUI", 798, 20, 1, 1, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GUISetState()
$Menu_1 = GUICtrlCreateMenu("&CTS Team Sites")
$Menu_1_Item_1 = GUICtrlCreateMenuItem("C&TS Management", $Menu_1)
$Menu_2 = GUICtrlCreateMenu("&Exit")
$Menu_Item_2 = GUICtrlCreateMenuItem("exit", $Menu_2)
GUISetState()
;opt("MouseCoordMode",2)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Menu_Item_2
            ExitLoop
        Case Else
        ;;;
    EndSelect

    If WinActive("MyGUI") Then
        $mc = mousegetpos()
        If _IsPressed("1") Then;if primary down
            $gp = WinGetPos("MyGUI")
            If inside($gp, $mc) Then;cleft mouse down over the window
                consolewrite('inside is true' & @LF)
                while _IsPressed("1")
                $nowc = mousegetpos()   
                winmove("MyGUI",'',$gp[0] + $nowc[0] - $mc[0],$gp[1] + $nowc[1] - $mc[1])
                    
                WEnd
                
            EndIf
        EndIf

    EndIf
WEnd
Exit

Func inside($a,$b)
;returns true if point $b not outside rectangle $a
    if $b[0] < $a[0] then return False
    if $b[1] < $a[1] then return False
    if $b[0] > $a[2] + $a[0] then return False
    if $b[1] > $a[3] + $a[1] then return False  
    
    return True
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Made a small UDF out of it

#include <GuiConstants.au3>

$GUI = GUICreate("MyGUI", 798, 20, 1, 1, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GUISetState()
$Menu_1 = GUICtrlCreateMenu("&CTS Team Sites")
$Menu_1_Item_1 = GUICtrlCreateMenuItem("C&TS Management", $Menu_1)
$Menu_2 = GUICtrlCreateMenu("&Exit")
$Menu_Item_2 = GUICtrlCreateMenuItem("exit", $Menu_2)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Menu_Item_2
            GUIDelete($GUI)
            ExitLoop
        Case Else
            ;;;
    EndSelect
    _WinMove($GUI)
WEnd


Run("notepad.exe")
WinWaitActive("")

While WinExists("Untitled -")
    _WinMove("Untitled -")
    Sleep(10)
WEnd

;===============================================================================
;
; Description:      Moves any Window by Left Mouse "Click & Drag"
; Syntax:           _WinMove($hWnd) or  _WinMove($s_Title)
; Parameter(s):     $s_hWnd = as returned by GUICreate()
;                   $s_Title = title of window to be moved
; Requirement(s):   None
; Return Value(s):  On Success - Repositions the Window
;                   On Failure - Returns ""
; Author(s):        Valuater,  Valuater [at] aol [.com], Inspired by Martin
;
;===============================================================================
Func _WinMove($hWnd)
    If Not WinActive($hWnd) Then Return
    Local $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x1')
    If @error Or BitAND($a_R[0], 0x8000) <> 0x8000 Then Return
    Local $a = WinGetPos($hWnd), $b = MouseGetPos()
    If $b[0] < $a[0] Or $b[1] < $a[1] Or $b[0] > $a[2] + $a[0] Or $b[1] > $a[3] + $a[1] Then Return
    While WinActive($hWnd)
        Local $c = MouseGetPos()
        WinMove($hWnd, '', $a[0] + $c[0] - $b[0], $a[1] + $c[1] - $b[1])
        $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x1')
        If @error Or BitAND($a_R[0], 0x8000) <> 0x8000 Then Return
    WEnd
EndFunc   ;==>_WinMove

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Isn't there a style or extended style that you can set for an image, to allow the window to be dragged around by it? The property's a pretty complex one, not sure if I ever got it working... It's worth checking into. With that you can create your own window "skins," complete with max, min, restore buttons. But the floating menubar makes a cool effect, too.

Edited by RobertKipling

Share this post


Link to post
Share on other sites

Yepper... More Elegant!

8)


NEWHeader1.png

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