Sign in to follow this  
Followers 0
jezzzzy

Quickie

14 posts in this topic

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?

Share this post


Link to post
Share on other sites



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.

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#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.

 

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

might want to look at using the advanced GUIGetMsg ( [advanced] )

Looking now...

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

actually, gafrost is exceptionally knowledgeable with listviews

i am sure he can direct you ... on this

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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. :P

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.

Share this post


Link to post
Share on other sites

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.

Posted Image

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