Jump to content

Listviews... How do i know if someone dbl clicked?


Recommended Posts

script snippets:

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event
    
    If $wParam = $ListView1 Then
        $tagNMHDR = DllStructCreate("int;int;int", $lParam)
        If @error Then Return
        $event = DllStructGetData($tagNMHDR, 3)
        
        If $event = $NM_DBLCLK Then OnDoubleclick()
    EndIf
EndFunc

Func OnDoubleclick()
    $col1 = _GUICtrlListViewGetItemText($ListView1,_GUICtrlListViewGetCurSel($ListView1),0)
    If $col1 = -1 Then Return

    ; do what you want here ...
EndFunc
Link to comment
Share on other sites

I can't remember whi wrote this maybe gafrost?

Global Const $WM_NOTIFY = 0x004E
Global $debug = 1
#include <GuiConstants.au3>
$Form1 = GUICreate("", 633, 467, -1, -1)

;Main listview which accepts droped items
$ListView1 = GUICtrlCreateListView("Stuff|Stuff|Stuff|and more stuff", 30, 54, 573, 300,-1)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)


GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

Do
    Sleep (10)
    
Until GuiGetMsg() = $GUI_EVENT_CLOSE






Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local Const $NM_FIRST = 0
    Local Const $NM_CLICK = ($NM_FIRST - 2)
    Local Const $NM_DBLCLK = ($NM_FIRST - 3)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $ListView1
            Select
                Case $event = $NM_CLICK
                    ListView_Click()
                Case $event = $NM_DBLCLK
                    ListView_DoubleClick()
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc  ;==>WM_Notify_Events

Func ListView_Click()
;----------------------------------------------------------------------------------------------
    ConsoleWrite("$NM_CLICK" & @crlf)
;----------------------------------------------------------------------------------------------
EndFunc  ;==>ListView_Click

Func ListView_DoubleClick()
;----------------------------------------------------------------------------------------------
    ConsoleWrite("$NM_DBLCLK"& @crlf)
;----------------------------------------------------------------------------------------------
EndFunc  ;==>ListView_DoubleClick
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...