jezzzzy Posted December 16, 2005 Share Posted December 16, 2005 I need to simply make something happen when I click in my listview. If I do this: Case $msg = $listview _GUICtrlListViewGetItemText($listview,-1,3) Nothing happens. I don't know what message is sent when a listview item is clicked. I don't want to have to highlight a listview item and then click a button to perform an action. I want the action to run when the item is double-clicked (or single if that is all I can do). Also, for bonus points -- is it possible to get a right click menu from a listview item? Link to comment Share on other sites More sharing options...
GaryFrost Posted December 16, 2005 Share Posted December 16, 2005 I need to simply make something happen when I click in my listview. If I do this: Case $msg = $listview _GUICtrlListViewGetItemText($listview,-1,3) Nothing happens. I don't know what message is sent when a listview item is clicked. I don't want to have to highlight a listview item and then click a button to perform an action. I want the action to run when the item is double-clicked (or single if that is all I can do). Also, for bonus points -- is it possible to get a right click menu from a listview item? MsgBox(0,"Test",_GUICtrlListViewGetItemText($listview,-1,3)) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
jezzzzy Posted December 16, 2005 Author Share Posted December 16, 2005 Hey gafrost. I can pull the info out of the listview fine. I just need that to happen when I click the listview item. I've even polled the $msg variable to find out what ID gets spit out when I click an item. But it seems to be a different ID for each item. How do I "Case $msg = ???" for that? Link to comment Share on other sites More sharing options...
GaryFrost Posted December 16, 2005 Share Posted December 16, 2005 expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> Opt ('MustDeclareVars', 1) Dim $listview, $Btn_Get, $Btn_GetSelected, $Btn_Exit, $msg, $Status, $ret GUICreate("ListView Get Item Text", 392, 322) $listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149) GUICtrlCreateListViewItem("line1|data1|more1", $listview) GUICtrlCreateListViewItem("line2|data2|more2", $listview) GUICtrlCreateListViewItem("line3|data3|more3", $listview) GUICtrlCreateListViewItem("line4|data4|more4", $listview) GUICtrlCreateListViewItem("line5|data5|more5", $listview) $Btn_Get = GUICtrlCreateButton("Get From Index 2", 75, 200, 90, 40) $Btn_GetSelected = GUICtrlCreateButton("Get Selected", 200, 200, 90, 40) $Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30) $Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER)) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit ExitLoop Case $msg = $Btn_Get GUICtrlSetData($Status, "") MsgBox(0, "Passed Item Index only", _GUICtrlListViewGetItemText ($listview, 2)) MsgBox(0, "Passed Item Index, SubItem 0", _GUICtrlListViewGetItemText ($listview, 2, 0)) Case $msg = $GUI_EVENT_PRIMARYDOWN GUICtrlSetData($Status, "") $ret = _GUICtrlListViewGetItemText ($listview) If ($ret <> $LV_ERR) Then MsgBox(0, "Selected Item", $ret) $ret = _GUICtrlListViewGetItemText ($listview, -1, 0) If ($ret <> $LV_ERR) Then MsgBox(0, "Selected Item, SubItem 0", $ret) EndIf Else GUICtrlSetData($Status, "Nothing Selected") EndIf EndSelect WEnd Exit SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
jezzzzy Posted December 16, 2005 Author Share Posted December 16, 2005 That's close. I can maybe adapt that to do what I want. Except...The problem with that code is that everytime I click (no matter where I click) the action will run (assuming a listview item is selected). I need to have a way to determine if the $primarydown is in the listview box. However, I think if I can figure out a way to know that, I won't need to use the $primarydown at all.There has to be a way to poll $msg to find out if a listview item is clicked... Link to comment Share on other sites More sharing options...
GaryFrost Posted December 16, 2005 Share Posted December 16, 2005 might want to look at using the advanced GUIGetMsg ( [advanced] ) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
jezzzzy Posted December 16, 2005 Author Share Posted December 16, 2005 might want to look at using the advanced GUIGetMsg ( [advanced] ) Looking now... Link to comment Share on other sites More sharing options...
jezzzzy Posted December 16, 2005 Author Share Posted December 16, 2005 might want to look at using the advanced GUIGetMsg ( [advanced] ) Your idea being to use the mouseX and mouseY to determine whether I'm in the listview? Link to comment Share on other sites More sharing options...
Valuater Posted December 16, 2005 Share Posted December 16, 2005 (edited) I think he meant the advanced feature of GUIGetMsg() from help GUIGetMsg ( [advanced]) Parameters advanced [optional] return extended information in an array. 0 = (default) Returns a single event. 1 = returns an array containing the event and extended information. Return Value Returns an event, or an array depending on the "advanced" parameter. The "event" returned is the control ID of the control sending the message, or it is a special event (like the window is closing, minimizing). Or if there is no message, the event is 0. Event ID the ID of the control sending the message 0 No event $GUI_EVENT_CLOSE dialog box being closed (either by defined button or system menu). $GUI_EVENT_MINIMIZE dialog box minimized with Windows title bar button. $GUI_EVENT_RESTORE dialog box restored by click on task bar icon. $GUI_EVENT_MAXIMIZE dialog box maximized with Windows title bar button. $GUI_EVENT_MOUSEMOVE the mouse cursor has moved. $GUI_EVENT_PRIMARYDOWN the primary mouse button was pressed. $GUI_EVENT_PRIMARYUP the primary mouse button was released. $GUI_EVENT_SECONDARYDOWN the secondary mouse button was pressed. $GUI_EVENT_SECONDARYUP the secondary mouse button was released. $GUI_EVENT_RESIZED dialog box has been resized. When using the "advanced" parameter the information is returned in an array with extended information: $array[0] = 0 or Event ID or Control ID $array[1] = The window handle the event is from $array[2] = The control handle the event is from (if applicable) $array[3] = The current X position of the mouse cursor (relative to the GUI window) $array[4] = The current Y position of the mouse cursor (relative to the GUI window) see help files 8) Edited December 16, 2005 by Valuater Link to comment Share on other sites More sharing options...
jezzzzy Posted December 16, 2005 Author Share Posted December 16, 2005 I realize that. I just don't see how the advanced getmsg mode will help me other than maybe using the mouseX and mouseY values from the array that it creates ($array[2] & $array[3]). Other than using that, i'm not sure how that would help me. Maybe i'm missing something. Link to comment Share on other sites More sharing options...
Valuater Posted December 16, 2005 Share Posted December 16, 2005 actually, gafrost is exceptionally knowledgeable with listviews i am sure he can direct you ... on this 8) Link to comment Share on other sites More sharing options...
jezzzzy Posted December 16, 2005 Author Share Posted December 16, 2005 actually, gafrost is exceptionally knowledgeable with listviews i am sure he can direct you ... on this 8) I bet he can. He must first overcome my inexperience. I initially thought I could use $array[2] = The control handle the event is from (if applicable) But it returns "0x00000000" no matter where I click. I thought it would return the handle of the listview ("0x00180D9A") but no such luck. So it seems (please correct me if I am wrong) that I am left with using the mouse coordinates to determine whether I am clicking in the $listview or not. Link to comment Share on other sites More sharing options...
jezzzzy Posted December 16, 2005 Author Share Posted December 16, 2005 Not sure if a visual will help. What I need to do is make it so that if someone clicks a listview entry (for example - timestamp: 11.04.27) I want to open the folder referenced in the line they click in windows explorer. Link to comment Share on other sites More sharing options...
randallc Posted December 16, 2005 Share Posted December 16, 2005 Hi, In Gary's Edit list view example attached, change "rename" func to select your line, get item array number 3 or 4, run you open macro. Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now