Jump to content
Sign in to follow this  
xAx

Detect Double click on the main GUI

Recommended Posts

xAx

Hi

How can I show message when I double click the main GUI that I made using the command

$GUI_Main = GUICreate("My GUI", 100, 100, 400, 350, $WS_POPUP)

And how can I do it with single click too?

I think they are stupid questions, but I am a newbie :)

Regards

Abduljabbar


Abduljabbar Faaiz Al_Kazzazx A x Company islamway.com

Share this post


Link to post
Share on other sites
Authenticity

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

If Not IsDeclared("WM_LBUTTONDOWN") Then Global Const $WM_LBUTTONDOWN = 0x0201
If Not IsDeclared("WM_LBUTTONDBLCLK") Then Global Const $WM_LBUTTONDBLCLK = 0x0203
If Not IsDeclared("GCL_STYLE") Then Global Const $GCL_STYLE = -26

Local $fDblClk = False
Local $iDoubleClickTime = 200 ; _WinAPI_GetDoubleClickTime() ; 500 by default
Local $hGUI = GUICreate("Test", 300, 300)
GUIRegisterMsg($WM_LBUTTONDBLCLK, "_WM_LBUTTONDBLCLK")
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUISetState ()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()
Exit

Func _WM_LBUTTONDBLCLK($hWnd, $iMsg, $iwParam, $ilParam)
    Local $iX = BitAND($ilParam, 0xFFFF), $iY = BitShift($ilParam, 16)
    
    $fDblClk = True
    ConsoleWrite("!Double click on: [" & $iX & "," & $iY & "]" & @CRLF)
    Return $GUI_RUNDEFMSG
EndFunc

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    Local $iX = BitAND($ilParam, 0xFFFF), $iY = BitShift($ilParam, 16)
    
    Sleep($iDoubleClickTime)
    If $fDblClk Then
        $fDblClk = False
        Return 0
    EndIf
    ConsoleWrite("+Single click on: [" & $iX & "," & $iY & "]" & @CRLF)
    Return $GUI_RUNDEFMSG
EndFunc

Func _WinAPI_GetDoubleClickTime()
    Local $aResult = DllCall("user32.dll", "uint", "GetDoubleClickTime")
    
    Return $aResult[0]
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  

×