Jump to content
Sign in to follow this  
Cybernetic

Double click on listview help

Recommended Posts

Cybernetic

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.

Share this post


Link to post
Share on other sites
FireFox

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.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Cybernetic

Thanks FireFox, but your code is very similiar to mine. And in my code i didn't know how to do it which is why i was asking for help.

Could you please show me how to do it?

Share this post


Link to post
Share on other sites
Danyfirex

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

Share this post


Link to post
Share on other sites
Danyfirex

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

Share this post


Link to post
Share on other sites
Cybernetic

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.

Share this post


Link to post
Share on other sites
FireFox

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

  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Danyfirex

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

lol  :thumbsup:

 

Thanks very much bruz.

You're welcome. 

Share this post


Link to post
Share on other sites
FireFox

@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
  • Like 2

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

×