Jump to content

How to set an event for listview item?


Der_Andi
 Share

Recommended Posts

Hi all,

my listview's items use icons. Thus, I create the items with _GUICtrlListView_AddItem() to get the icons from an image list.

This function however returns only the new zero-based item index and not a control ID or handle to the item itself.

How can I connect a function to a click event on such an item?

Best regards,

Andi

PS:

Need an example? See help file entry for the UDF mentioned above. That's pretty the same, I've got so far.

Link to comment
Share on other sites

I believe what you want can be accomplished by GUIRegisterMsg(). Check out _GUICtrlListView_Create the example is exactly what I'm talking about. You can catch single and double click on items...etc.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

Yet i realise it with(for get text):

_GUICtrlListView_GetItemText()
for listview.So below replace it with
_GUICtrlListView_GetImageList()

I think you will get it

$op=_GUICtrlListView_GetSelectedIndices($List1)
_GUICtrlListView_GetItemText((GUICtrlGetHandle($List1),$op,0)    ;for firt column.If you want another column just replcae increment column number and under test you will get it.
Edited by Sh3llC043r
[size="5"] [/size]
Link to comment
Share on other sites

I believe what you want can be accomplished by GUIRegisterMsg(). Check out _GUICtrlListView_Create the example is exactly what I'm talking about. You can catch single and double click on items...etc.

Thank you, someone.

That helped and it works now.

Happy Holidays to all.

Andi

Link to comment
Share on other sites

  • 7 months later...

@pioray... there are many ways to do this. I personally am a huge fan of guisetonevent option since I tend to have many triggers and find it easier to organize. Not to say its better, but it works for me.

#include <GUIConstants.au3>

opt("GUIOnEventMode", 1)

$maingui = GUICreate("test", 500, 500, 1, 1)
GUISetState()
$lstmain = GUICtrlCreateList("",10,10,480,480)
GUICtrlSetOnEvent($lstmain,"FunListSelect")
$i = 1
    While $i < 10
        GUICtrlSetData($lstmain, $i)
        $i = $i+1
    WEnd

GUISetOnEvent($GUI_EVENT_CLOSE, "FunClose")

While 1
    sleep(50)
Wend

Func FunListSelect()
    MsgBox(0,"","You clicked on " & guictrlread($lstmain))
EndFunc

Func FunClose()
    Exit
EndFunc

woof... there answered my 6 questions for the 2 I posted. Karma should be happy :-).

Good luck

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