Jump to content

Processing double click on Label


rasim
 Share

Recommended Posts

How can processing double click on Label control?

I tryed with this code, but futile :) :

#include <GuiConstants.au3>

$hGui = GUICreate("Test", 200, 100)

$label = GUICtrlCreateLabel("Click", 70, 45, 50, 17)
GUICtrlSetBkColor(-1, 0xFFFF00)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
WEnd

Func WM_COMMAND($hWnd, $MsgID, $wParam, $lParam)
    MsgBox(0, "", "")
    Local $tagNMHDR, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $label And $code = $NM_DBLCLK Then MsgBox(0, "Ok", "Double click")
    Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

Hi, you could make it a bit tidier but it's something like this..

#include <GuiConstants.au3>

Global $label, $DoubleClick

$hGui = GUICreate("Test", 200, 100)
$label = GUICtrlCreateLabel("Click", 70, 45, 50, 17)
GUICtrlSetBkColor(-1, 0xFFFF00)
GUISetState()

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    If $DoubleClick = 1 Then
        $DoubleClick = 0
        MsgBox(0, "Ok", "Double click")
    EndIf
WEnd

Func WM_COMMAND($hWnd, $MsgID, $wParam, $lParam)
    Local Const $STN_DBLCLK = 1
    Local $nID = BitAND($wParam, 0xFFFF)
    Local $nNotifyCode = BitShift($wParam, 16)
    If $nID = $label And $nNotifyCode = $STN_DBLCLK Then $DoubleClick = 1
    Return $GUI_RUNDEFMSG
EndFunc

Cheers

Edited by smashly
Link to comment
Share on other sites

  • 9 years later...

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