Jump to content

Double click on listview help


Go to solution Solved by Danyfirex,

Recommended Posts

hey guys. I have this current code which works very well:

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $listview1 And $code = -3 Then $double_click = True
    If $wParam = $listview2 And $code = -3 Then $double_click2 = True
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

It allows me to double click on certain listviews for an effect. What id like to know is, how can i convert or change this code to allow me to double RIGHT click?

Any help would be appreciated.

Link to comment
Share on other sites

Hi,
Here is a proper code for the double click:

#include <StructureConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
 
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
 
    Local $tNMHDR = 0, $iIDFrom = 0, $iCode = 0
 
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
 
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
 
    Switch $iCode
        Case $NM_DBLCLK
            Switch $iIDFrom
                Case $listview1
                    $double_click = True
                Case $listview2
                    $double_click2 = True
            EndSwitch
    EndSwitch
 
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
I let you find out how to do for the double right click.

Br, FireFox.
Link to comment
Share on other sites

hi. Maybe this

Global Const $WM_RBUTTONDBLCLK = 0x0206
$Gui = GUICreate("doble right click", 400, 400)
GUISetState()

GUIRegisterMsg($WM_RBUTTONDBLCLK, "WM_RBUTTONDBLCLK")

While 1
   $msg = GUIGetMsg()
   Select
       Case $msg = -3
           Exit
   EndSelect
WEnd

Func WM_RBUTTONDBLCLK($hWndGui, $MsgId, $wParam, $lParam)
    local Static $n=0
    $n+=1
    Consolewrite( 'Doble Click derecho ' & $n  &  " veces" & @crlf)
EndFunc

saludos

Edited by Danyfirex
Link to comment
Share on other sites

  • Solution

Also another example with both double right click and double left click

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>




GUICreate("Ejemplo", 300, 200)
local $hListView = GUICtrlCreateListView("Hola  |Como|Estas", 2, 2, 290, 100)
local $item1 = GUICtrlCreateListViewItem("hola|como|estas", $hListView)


GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
local Static $nl=1
local Static $nr=1
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode

                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    consolewrite( "$NM_DBLCLK listview " & $nl & @CRLF) ; No return value
                    $nl+=1
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    consolewrite( "$NM_RDBLCLK listview " & $nr & @CRLF) ; No return value
                    $nr+=1
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

saludos

Link to comment
Share on other sites

Also another example with both double right click and double left click

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>




GUICreate("Ejemplo", 300, 200)
local $hListView = GUICtrlCreateListView("Hola  |Como|Estas", 2, 2, 290, 100)
local $item1 = GUICtrlCreateListViewItem("hola|como|estas", $hListView)


GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
local Static $nl=1
local Static $nr=1
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode

                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    consolewrite( "$NM_DBLCLK listview " & $nl & @CRLF) ; No return value
                    $nl+=1
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    consolewrite( "$NM_RDBLCLK listview " & $nr & @CRLF) ; No return value
                    $nr+=1
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

saludos

 

Thanks very much bruz.

Link to comment
Share on other sites

Wow, it was very hard to change $NM_DBLCLK to $NM_RDBLCLK in my example...

lol  :thumbsup:

 

Thanks very much bruz.

You're welcome. 

Link to comment
Share on other sites

@Cybernetic,

I agree that my example does the same thing as yours, however the constants used (and the clear way I wrote it) make it very clear on how to solve the problem and change DBLCLCK to RDBLCLCK.

Magic numbers only troubles you that's why you did not understood how it works.

It's a pity you asked for the answer and someone cared to give you the solution (no offense to both), but you can't learn by this way.

Br, FireFox.

Edited by FireFox
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...