Sign in to follow this  
Followers 0
pinkfoyd

How to dectect that an element of a GUICtrlCreateListViewItem is clicked ?

10 posts in this topic

#1 ·  Posted (edited)

Hi all !

I can't found how to detect an element of my ListView control has been clicked

Ie, for the moment i have a ListView with some element, and, when an element is selected, i click a button to get info from this element.

In my idea, it was must easiest for the user if, when he click on a element, the info get automatically

ok the GUICtrlCreateListViewItem function return an id, but my list is not fill before the GUI was enable so, if i do :

if $msg = $element_of_my_list[$number] then....

like $element_of_my_list[$number] is empty, $msg activate....

hope i have been clear... if not, sorry.

Thanks !

PS : oups, bast copy/past in the title, you must read :

How to detect that an element of a ListView is clicked ? :D

Edited by pinkfoyd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Check out "GUICtrlRead($ControlID)".

e.g.

$Selected = GUICtrlRead($ListView)
if $Selected = "Text1" then
MsgBox(0, "", "Selected Text1)
Else
MsgBox(0, "", "You selected something different")
endif
oÝ÷ ٩趫Á¬­¡Ú-+"°,ºh§*.«ÞÊ«¨§)±ën¥«­¢+Ø(ÀÌØíÍ°ôU%
ÑɱI ÀÌØí1¥ÍÑY¥Ü¤)M±Ð(
ÍÀÌØíµÍôÀÌØíÍ°(5Í    ½à À°ÅÕ½ÐìÅÕ½Ðì°ÀÌØíÍ°¤)¹M±Ð(

something like that..

for more info check "GUICtrlRead" in the help file.

Hope that helps!

Edited by CHRIS95219

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thanks for the fast reply, but i have a pb with your code

because i d'ont konw what contain the list :P

ie : i can't use this $Selected = "Text1" because i d'ont know Text1

EDIT : cross message :D

ok for your code, but it' to read was what selected in my list, but my main problem is how to detect a click on one of this element

and, need to add, that for my list control i use sort whit this :

if $msg = $listview_top_10_lots then

_GUICtrlListViewSort($B_DESCENDING_top_10_lot, $B_DESCENDING_top_10_lot, GUICtrlGetState($B_DESCENDING_top_10_lot))

EndIf

this ( if $msg = $listview_top_10_lots then ) work great when click on the header of the list, but no in a element

by the hand, thank for your help :D

Edited by pinkfoyd

Share this post


Link to post
Share on other sites

thanks for the fast reply, but i have a pb with your code

because i d'ont konw what contain the list :D

ie : i can't use this $Selected = "Text1" because i d'ont know Text1

If you are having a problem, and you don't understand functions people tell you to read up on, then I would suggest posting your entire code, and commenting where you need help, otherwise your best answers are just guesses on what it is you may actually "need".

P.S.

When posting code, use the code tag option [ code] < before your code without spaces and [ /code] after your code without spaces.


[center]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.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

sorry smoke_n, but i didn' think so i was neccessary to put the tag CODE for one line, sorry about that

I can't put my entire code ( is too long but here it's a minimal exemple of my problem)

$listview = GUICtrlCreateListView ("Name|Ping" ,  9,150,191,580,  -1, BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
 

GUICtrlCreateListViewItem("G0011111" & "|" & "3ms",$listview )
     

do
    $msg = GUIGetMsg()

       ;sorting the list view
        if $msg = listview  then _GUICtrlListViewSort($B_DESCENDING_listview , $B_DESCENDING_listview , GUICtrlGetState($B_DESCENDING_listview ))   
    
       ;click on a element of the listview
        if $msg = <here i would act when $msg detect that an element of my list view was clicked> then

 endif

until $msg = $GUI_EVENT_CLOSE

hope it's better

Edited by pinkfoyd

Share this post


Link to post
Share on other sites

How do people expect to get help if they can't even post a freaking working example!!


[center]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.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

What do you want more !?

the

if $msg = listview
work just when you click on a header column, not in an element ! Edited by pinkfoyd

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

What do you want more !?

the

if $msg = listview
work just when you click on a header column, not in an element !
How about a GUI that actually works... when you need someone to help with your coding, then create an example that looks like yours, if you say it's "too long" well, you'd be amazed on how many characters a code box can hold. But I absolutely despise people pulling snippets from their code, and can't even create a semi working enviroment... It's like here, this is what I want, and no, I wont' give you any more information, figure it out for yourself and when you do post it here... I decided to help, but geeze... show that you care if you get some:

Requires Beta

#include <guiconstants.au3>
#include <guilistview.au3>
Global $listview
Global Const $WM_NOTIFY = 0x004E
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)

$main = GUICreate('')
$listview = GUICtrlCreateListView ("Name|Ping" ,  9,150,191,580,  -1, BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
GUICtrlCreateListViewItem("G0011111" & "|" & "3ms",$listview )
GUIRegisterMsg($WM_NOTIFY, "MY_WM_COMMAND")
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = - 3 
            Exit
        ;Case $msg = $listview 
            ;_GUICtrlListViewSort($B_DESCENDING_listview , $B_DESCENDING_listview , GUICtrlGetState($B_DESCENDING_listview ))
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID
    Local $tagNMHDR, $event
    Switch $wParam
        Case $listview
            $tagNMHDR = DllStructCreate("int;int;int", $lParam)
            If @error Then Return
            $event = DllStructGetData($tagNMHDR, 3)
            Switch $event
                Case $NM_CLICK
                    MsgBox(64, 'Info', 'You clicked the listview')
            EndSwitch
    EndSwitch
    $tagNMHDR = 0
EndFunc
Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Yes, you did it !

That was what I was in mind ( ie detect a user click) , but i didn't get how to detect a mouse click.

Thank's a lot for your code ! But there was no need to be mean like that :D , i thought that my explanation was enough clear for this problem.

Anyway, thanks again for your function ! :D

Edited by pinkfoyd

Share this post


Link to post
Share on other sites

But there was no need to be mean like that :D , i thought that my explanation was enough clear for this problem.

1. Your welcome

2. It's not "my" code (could have searched the GUI forum for it)

3. Whether your explination is good enough or not, it's always easiest to work with a ready made example (even if it doesn't work right), than to force me/anyone to have to write one ourselves, after all, your the one asking for help and we don't always have the "answer" without working with the code first... :D


[center]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.[/center]

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