Jump to content
Sign in to follow this  
CodyBarrett

If mouse click is held

Recommended Posts

CodyBarrett

im builing a custom GUI.. and i have a question about mouse dragging.. i can figure out if the primary is clicked... but not when its is held down and i cannot make an event for that

what i want:

custom titlebar - GOTT!

able to move GUI - GOTT

able to determine when primary is clicked and move gui then when primary is released gui stops moving...

i have this an i just switch between the primary and secondary to move it...

While 1
    If _IsPressed ('02') Then _WinMove ()
    Sleep (100)
WEnd
Func _WinMove ()
    while $GUI_EVENT_PRIMARYDOWN
        Local $x = MouseGetPos (0)
        Local $y = MouseGetPos (1)
        WinMove ($GUI, '', $x, $y)
        If _IsPressed ('01') Then ExitLoop
    WEnd
EndFunc

PS all the other code isnt relevent.. so i just included what is.. hence whats up there ^

Share this post


Link to post
Share on other sites
spudw2k

Give this a shot too.

#include <GUIConstantsEx.au3>
#include <sendmessage.au3>

$gui = GUICreate("test",200,200,-1,-1)
GUISetState()

While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $hWnd = _SendMessage($nMsg[1], 274, 0xF012, 2,1)
            GUISwitch($nMsg[1])
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
CodyBarrett

alright.. have never seen this before... ill try it out.. isnt there an easyer way like

If $GUI_PRIMARY_DOWN then
Do
;DO THIS
until $GUI_PRIMARY_UP
Endif

either way ill check into it

Share this post


Link to post
Share on other sites
CodyBarrett

alright i looked into it.. but COULD NOT figure out how to get the parameters in _SendMessage()...

what im thinking would be easyer.. instead of having the ENTIRE gui background be the target to move if $GUI_EVENT_PRIMARYDOWN happens.. just make my own title bar using GUIctrlcreategraphic().... any ideas guys? on perhaps how to get the values of the parameters or... an easyer solution lol

EDIT

alright i have settled for this

Global $L = GUICtrlCreateLabel ('', 0, 0, 400, 20)
GUICtrlSetBkColor ($L, 0xFFFFFF)
GUICtrlSetOnEvent ($L, '_WinMove')
Func _WinMove ()
    While _IsPressed ('01')
        Local $x = MouseGetPos (0)
        Local $y = MouseGetPos (1)
        WinMove ($GUI, '', $x, $y)
    WEnd
EndFunc

that is my custom title bar.. sadely but it will do for now

Edited by CodyBarrett

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  

×