Jump to content

Listview double click


Zest
 Share

Recommended Posts

Hi,

I'm making a script for a book database, which has a listview. I want it so that when a user double clicks on a listview item (a book listed in it), an other GUI with information about the book is updated. I've been trying everything I read about this in the forums for almost a week, and am totally at a loss: I just can't get it to work. Most likely because I don't entirely understand the example scripts posted by others.

So I have a request:

Could anyone please post a -very simple- script (yes, I'm quite a noob), which does nothing but make a listbox with a few items in it, where double clicking on an item will pop up a MsgBox or do something else.

If I can understand that I think I can implement it in my script and change it to do what I want.

(Since my current script version is quite large and uses external data I think it's more confusing for someone to understand it than to write a quick example...)

Of course, by request I'll post it anyway.

Many thanks in advance for any help!!

Link to comment
Share on other sites

  • Moderators

Hi,

I'm making a script for a book database, which has a listview. I want it so that when a user double clicks on a listview item (a book listed in it), an other GUI with information about the book is updated. I've been trying everything I read about this in the forums for almost a week, and am totally at a loss: I just can't get it to work. Most likely because I don't entirely understand the example scripts posted by others.

So I have a request:

Could anyone please post a -very simple- script (yes, I'm quite a noob), which does nothing but make a listbox with a few items in it, where double clicking on an item will pop up a MsgBox or do something else.

If I can understand that I think I can implement it in my script and change it to do what I want.

(Since my current script version is quite large and uses external data I think it's more confusing for someone to understand it than to write a quick example...)

Of course, by request I'll post it anyway.

Many thanks in advance for any help!!

http://www.autoitscript.com/forum/index.ph...CDoubleClick%5C

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

A real simple one.

HTH, Reinhard

; Simple Example of WM Notify
#include <GUIConstants.au3>
;#include <A3LTreeView.au3>
#include <GuiTab.au3>

Global $main_GUI,$ok_button,$cancel_button

; This window has 2 ok/cancel-buttons
$main_GUI  = GUICreate("TAB in TAB",260,250,-1,-1)
    
    $listview       = GUICtrlCreateListView("Col1|Col2",10,10,210,150)
                    GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview)
                    GUICtrlCreateListViewItem("ItemLong2|Item22", $listview)
        
    $ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
    $cancel_button  = GUICtrlCreateButton("Cancel",150,220,70,20)

GUISetState()

;; Insert this to catch events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE, $cancel_button
            ExitLoop
    EndSwitch
WEnd

;; Insert this to handle events
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
     #forceref $hWndGUI, $MsgID, $wParam
     Local $tagNMHDR, $event, $hwndFrom, $code 
     $tagNMHDR = DllStructCreate("int;int;int", $lParam) 
     If @error Then Return
     $event = DllStructGetData($tagNMHDR, 3)
     Select
     Case $wParam = $ListView
          Select
               Case $event = $NM_DBLCLK
                    msgbox(0,"",GUICtrlRead(GUICtrlRead($listview),1))
            EndSelect
    EndSelect
endFunc
Link to comment
Share on other sites

Thank you Reinhard!

I still have no clue how the function in your script works, but managed to get what I wanted working by using your script and replacing which info to retrieve from the listview.

Thanks again for the fast and good help! You're a genious! :)

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