Jump to content
Sign in to follow this  
JonnyThunder

Detect double-click on edit box

Recommended Posts

JonnyThunder

Hello,

As per the title - is there a way to detect a double-click on a text box?? Or even, create a context menu for a text box??

Thanks,

JT

Share this post


Link to post
Share on other sites
Kiti

Share this post


Link to post
Share on other sites
JonnyThunder

Is this really the only way it can be done? Are there no event handlers or anything for double clicks on a form field?

Share this post


Link to post
Share on other sites
rasim

JonnyThunder

Is this really the only way it can be done?

Example with subclassing control:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>

Global Const $WM_LBUTTONDBLCLK = 0x203

$hGUI = GUICreate("Test GUI", 300, 200)

$edit = GUICtrlCreateEdit("", 10, 10, 280, 180)

$wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam")

$wProcOld = _WinAPI_SetWindowLong(GUICtrlGetHandle($edit), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete($hGui)
DllCallbackFree($wProcHandle)

Func _WindowProc($hWnd, $Msg, $wParam, $lParam)
    Switch $hWnd
        Case GUICtrlGetHandle($edit)
            Switch $Msg
                Case $WM_LBUTTONDBLCLK
                    ConsoleWrite("-> Left mouse double click" & @LF)
                    Return 0
            EndSwitch
    EndSwitch
    
    Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _
                          "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    Return $aRet[0]
EndFunc

Share this post


Link to post
Share on other sites
JonnyThunder

Wow - thats just the example im looking for!

Many thanks for your post.

Share this post


Link to post
Share on other sites
martin

Wow - thats just the example im looking for!

Many thanks for your post.

It might be worth considering commenting out the Return 0 line after detecting the double click so that the user can select a word that way and you can detect the double click as well.

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

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  

×