Sign in to follow this  
Followers 0
newcomer11

[Q] Detect ListView Add item event?

6 posts in this topic

Can we track the "add listview item message" ? Some thing like "hook" in AutoIt?

Thank you

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Internal listview? LVN_INSERTITEM. But then you should've posted in GUI support forum.

External? Then polling item count/text would be about the only option available to you.

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

External? Then polling item count/text would be about the only option available to you.

Hi, I'm new to AutoIt so can you give me an example of external listview : detect ListView Add item event, and change the item text before add it to LV? I can get it handle of the LV but don't know what to do next :)

Share this post


Link to post
Share on other sites

Hi, I'm new to AutoIt so can you give me an example of external listview : detect ListView Add item event, and change the item text before add it to LV? I can get it handle of the LV but don't know what to do next :)

You won't be able to change text "before", as you'll only know "after".

What you can do is, using GuiListView functions (see helpfile) - such as _GUICtrlListView_GetItemCount, and a While loop, know when number of items in an external listview changes, then maybe compare all item texts against old values to know which one is new, then change it with _GUICtrlListView_SetItemText.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Thank you for you fast replying :)

You won't be able to change text "before", as you'll only know "after".

Sorry if I miss understanding, but I think that when I catch the LVN_INSERTITEM message, I able to modify the item text then send to the LV ?

using GuiListView functions (see helpfile) - such as _GUICtrlListView_GetItemCount, and a While loop, know when number of items in an external listview changes, then maybe compare all item texts against old values to know which one is new, then change it with _GUICtrlListView_SetItemText.

Very good solution, but this is not the best if some new texts are same the old one? And when I change it with _GUICtrlListView_SetItemText, does the LV "flash" ?

Share this post


Link to post
Share on other sites

Sorry if I miss understanding, but I think that when I catch the LVN_INSERTITEM message, I able to modify the item text then send to the LV ?

With that message you are notified about the fact that a new item was inserted in your listview and get its index.

Very good solution, but this is not the best if some new texts are same the old one?

Then keep text and index of each item, and compare against both. Where this really wouldn't work reliably is if the listview is editable and item texts can change without your knowing. Or if it happens too fast, too often, etc, which is main weakness of polling approach in general.

Or maybe try _GUICtrlListView_MapIndexToID.


"be smart, drink your wine"

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