Sign in to follow this  
Followers 0
JD2066

Is there a way to get image set by GUICtrlSetImage?

8 posts in this topic

#1 ·  Posted (edited)

Hi,

I have used GUICtrlSetImage to set icons on listview items and want to by able to sort the listview by clicking on the headers.

I have searched the fourm and found a few ways to do that but found a few problems:

1. If I use the included listview sort UDF the images don't get sorted.

2. If I use the UDF I found here there is some flicker.

I was thinking if there was a way to get the image set on a listview item I might be able to update the above UDF so there wasn't as much flicker.

Anyone know a way to get the image set by GUICtrlSetImage?

I am using Windows XP and AutoIt version 3.1.1.99.

Justin

Update:

Problem Solved now.

See my last post.

Edited by JD2066

Share this post


Link to post
Share on other sites



Hi,

I have used GUICtrlSetImage to set icons on listview items and want to by able to sort the listview by clicking on the headers.

I have searched the fourm and found a few ways to do that but found a few problems:

1. If I use the included listview sort UDF the images don't get sorted.

2. If I use the UDF I found here there is some flicker.

I was thinking if there was a way to get the image set on a listview item I might be able to update the above UDF so there wasn't as much flicker.

Anyone know a way to get the image set by GUICtrlSetImage?

I am using Windows XP and AutoIt version 3.1.1.99.

Justin

Couldn't you just store the last image set in a variable? Or if dealing with multiple images, an array?

Share this post


Link to post
Share on other sites

Couldn't you just store the last image set in a variable? Or if dealing with multiple images, an array?

I thought about that idea but it also has a few problems:

1. I'm adding items to the listview with a "For...In" loop so I don't have a total amount of items to dim the array with.

2. Because the items could be sorted more then one time the array would have to be recreated each time it's sorted.

I think I might be able to do that by add the items to a string during each loop and split the string into an array after that though it would be easier with a GUICtrlGetImage type function.

I'm also not sure of the performance impact of doing that vs diming an array from the start though with only a few hundred users and only needing to store the icon index as the file is the same it might not be noticable.

Justin

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

could you post an example script for me to try to work with? i've been browsing around for a solution and i think it's time to just try to do it.

My script is a User Management script that pulls a user list from Active Directory.

So my script won't really work for you unless you have a computer joined to a domain to test it on.

But the listview sorting code I copyed from the example on the last post here with the only real differences being that in my script the the users are added to the listview when an OU is selected and the two hidden columns end up showing when doing that.

Justin

Edited by JD2066

Share this post


Link to post
Share on other sites

I got on the windows api reference and found something called Listview_GetImageList and I was all psyched to help you. So I made a function for it only to realized that it simply returns the imagelist handle for use in the SetImageList function. So I basically came up empty. Sorry.

Share this post


Link to post
Share on other sites

I got on the windows api reference and found something called Listview_GetImageList and I was all psyched to help you. So I made a function for it only to realized that it simply returns the imagelist handle for use in the SetImageList function. So I basically came up empty. Sorry.

Thats ok. Thanks for looking.

I think I'll just have to keep the sorting code I have the way it is then as I've already spent to much time on it.

It seems like sorting while keeping the images right by clicking the header should be built in to the listview control but I guess someone on the Windows Dev team thought otherwise.

Justin

Share this post


Link to post
Share on other sites

I just downloaded AutoIt 3.1.1.103 and found a new function GUICtrlRegisterListViewSort.

I looked at the example code, copyed it to my script and after debugging it a bit I got it to work.

I made it work by lowering the sleep time in my main loop. I guess it had something to do with the example using MessageLoop mode and my script using EventMode.

I don't really have any idea how the code works but it does.

Justin

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