Jump to content

Detect double-click on edit box


Recommended Posts

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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