Jump to content
Sign in to follow this  

ListView Control $LVN_ITEMACTIVATE help

Recommended Posts


I am having issues trying to detect a doublelclick in a listview control. According to smashly, the issue is with an int in the $tagNMHDR struct not being converted to int64. I need assistance correcting this, whether in the struct or a workaround (other than running 32bit).

The following link is to the discussion, few months old now.


Some code that only notifies me with a msgbox when I run 32bit:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>

$Form1 = GUICreate('boo', 361, 270, 200, 200)

;~ Create listview
    $hListView = GUICtrlCreateListView( "", 0, 0, 260, 377) ; LEFT],[TOP],WIDTH],[HEIGHT]

  ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 150)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)

    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)


$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

;~ ========================================================
;~ This thing is responsible for click events
;~ ========================================================
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode

                Case $LVN_ITEMACTIVATE  ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                   Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)

                   $Index = DllStructGetData($tInfo, "Index")

                   $subitemNR = DllStructGetData($tInfo, "SubItem")

                   ; make sure user clicks on the listview & only the activate
                   If $Index <> -1 Then

                       ; col1 ITem index
                        $item = StringSplit(_GUICtrlListView_GetItemTextString($hListView, $Index),'|')
                        $item = $item[1]

                        ;Col item 2 index
                        $item2 = StringSplit(_GUICtrlListView_GetItemTextString($hListView, $subitemNR),'|')
                        $item2= $item2[2]

                        MsgBox(0,"",$item & ' ' & $item2 & @CRLF)


EndFunc   ;==>WM_NOTIFY

[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Share this post

Link to post
Share on other sites

Are you sure you compiled it for 64-bit? Because the tag is $tagNMHDR = "hwnd hWndFrom;uint_ptr IDFrom;INT Code", and uint_ptr will be either 32-bit or 64-bit depending on how you compiled the script (see help file under DllStructCreate() for types).


Edit: Add #AutoIt3Wrapper_UseX64=Y to the top of your script.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.