Jump to content
Sign in to follow this  
rasim

Processing button double click

Recommended Posts

Hi! I ask about subj several times, but not found solution? I tryed processing double click on button control with below code, but unsuccessful :D

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

$hGui = GuiCreate("TestGui", 200, 100)

$hListView = _GUICtrlListView_Create($hGui, "Item|Subitem", 5, 5, 195, 50)
$LV_Item1 = _GUICtrlListView_AddItem($hListView, "Item1")

$button = GUICtrlCreateButton("Click", 10, 70, 50, 25)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

GUISetState()

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

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $hWndButton
    
    $hWndButton = GUICtrlGetHandle($button)
    
    $hWndListView = $hListView
    If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    
    Switch $hWndFrom
    Case $hWndListView
        Switch $iCode
        Case $NM_DBLCLK
            MsgBox(0, "ListView Itmem", "Double click")
        EndSwitch
    Case $hWndButton
        Switch $iCode
        Case $NM_DBLCLK
            MsgBox(0, "Button", "Double click")
        EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

$cBtn = GUICtrlCreateButton("", 0, 0)

;~ Global Const $BN_CLICKED = 0
;~ Global Const $BN_DBLCLK = 5

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")


Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
    If $nID = $cBtn
        Switch $nNotifyCode
            Case $BN_CLICKED
                ConsoleWrite('Single clicked' & @CRLF)
            Case $BN_DBLCLK
                ConsoleWrite('Double clicked' & @CRLF)
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Siao

Hello! I glad for your help! Single click work correctly, but double click not work :D

#include <GuiConstants.au3>

Global Const $BN_CLICKED = 0
Global Const $BN_DBLCLK = 5

GUICreate("Double Click Demo", 400, 300)

$button = GUICtrlCreateButton("start", 10, 10, 50, 25)

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

GUISetState()

While GUIGetMsg() <> -3
    ;Sleep(20)
WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl          = $lParam
    
    If $nID = $button Then
        Switch $nNotifyCode
            Case $BN_CLICKED
                ConsoleWrite('Single clicked' & @CRLF)
            Case $BN_DBLCLK
                ConsoleWrite('Double clicked' & @CRLF)
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
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  

×
×
  • Create New...