Jump to content

[Q] Detect ListView Add item event?


Recommended Posts

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"

Link to comment
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 :)
Link to comment
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"

Link to comment
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" ?
Link to comment
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"

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