Sign in to follow this  
Followers 0
zeppy

Listview

15 posts in this topic

How can I detect if my $aListview was double clicked on anywhere on it?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I belive a message is sent when it's clicked, you can do a check for that message in your gui..

Switch GuiGetMsg()
Case $aListView
; ...
EndSwitch

Edit:

Or perhaps the problem is to detect a double click?

If that's the case then perhaps you need to use a timer, and a variable to check if the message was sent twice(or more) within some time.

Edited by FreeFry

Share this post


Link to post
Share on other sites

zeppy

From help:

#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")

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, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $hWndFrom
    Case $hWndListView
        Switch $iCode
        Case $NM_DBLCLK
            MsgBox(0, "", "Double click")
        EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
:)

Share this post


Link to post
Share on other sites

an easier script:

#include <GUIConstants.au3>
#include <Misc.au3>

$User32 = DllOpen("User32.dll")

AdlibEnable("Check",50)


$Gui = GuiCreate("TestGui", 600, 400)
    $Listview = GUICtrlCreateListView("hi",100,50,400,300)
GUISetState()

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

    EndSwitch
    
WEnd

DllClose($User32)


Func Check()
    
    $Mouse = GUIGetCursorInfo($Gui)
    
    If IsArray($Mouse) Then
        if $Mouse[4] Then; $Mouse[4] is the control the mouse is hovering
            If _IsPressed("01", $User32) Then
                MsgBox(0,"sdsds","hello")
            EndIf
        EndIf
    EndIf
    
EndFunc

Share this post


Link to post
Share on other sites

an easier script:

Your example don`t work correctly. Was need processed double click, not click :)

Share this post


Link to post
Share on other sites

zeppy

From help:

#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")

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, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $hWndFrom
    Case $hWndListView
        Switch $iCode
        Case $NM_DBLCLK
            MsgBox(0, "", "Double click")
        EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
:)
Nice example! ;)

Share this post


Link to post
Share on other sites

I get an error when i run it. says variable used without being declared on line 21. the GUIRegister line

Share this post


Link to post
Share on other sites

I get an error when i run it. says variable used without being declared on line 21. the GUIRegister line

Did you #include the files as shown?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

What AutoIt version do you have?

To late. :)

Edited by FreeFry

Share this post


Link to post
Share on other sites

Did you #include the files as shown?

Yes i did.

and i already have beta.

Share this post


Link to post
Share on other sites

The problem was the other way around then.. You had beta but the code didn't, this is good:

#include<StructureConstants.au3>
#include<WindowsConstants.au3>
#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")

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, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView)

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

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Btw, was does it mean if a listview item is "cut". im reading a function...

Share this post


Link to post
Share on other sites

Btw, was does it mean if a listview item is "cut". im reading a function...

The item is marked for a cut-and-paste operation


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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  
Followers 0