-
March 11th, 2014, 04:39 AM
#1
Size from CImageList
The documentation states that "An image list is a collection of same-sized images" (http://msdn.microsoft.com/en-us/library/9xc4z2c7.aspx).
But how do I retrieve that size? I have a pointer to an empty image list. The size was set during creation, but that's out of my control.
-
March 11th, 2014, 05:12 AM
#2
Re: Size from CImageList
Nobody cares how it works as long as it works
-
March 11th, 2014, 05:31 AM
#3
Re: Size from CImageList
GetImageInfo requires the index of an image. In case the list is empty, this will not work. If all images have already been removed when I am given the pointer, I still need to be able to get the size so I can insert an image of the correct size. Any ideas?
-
March 11th, 2014, 07:03 AM
#4
Re: Size from CImageList
Okay, then maybe this workaround:
int n = list.GetImageCount();
list.SetImageCount(n + 1);
list.GetImageInfo(n, ...);
list.SetImageCount(n);
Nobody cares how it works as long as it works
-
March 11th, 2014, 07:17 AM
#5
Re: Size from CImageList
Well, thanks. I was hoping for some less ugly solution, but I guess this will have to do.
-
March 11th, 2014, 07:40 AM
#6
Re: Size from CImageList
You're welcome. A solution that works is always better than a solution that doesn't, no matter how ugly the code is
Nobody cares how it works as long as it works
-
March 11th, 2014, 08:03 AM
#7
Re: Size from CImageList
GetImageInfo is a less-than-ideal solution because it goes through the process of extracting an actual image.
Unfortunately the CImageList class doesn't provide any alternative solution, but the Windows API does.
Code:
int cx, cy;
ImageList_GetIconSize( imgl.m_hImageList, &cx, &cy);
-
March 11th, 2014, 09:06 AM
#8
Re: Size from CImageList
Originally Posted by OReubens
GetImageInfo is a less-than-ideal solution because it goes through the process of extracting an actual image.
Unfortunately the CImageList class doesn't provide any alternative solution, but the Windows API does.
Code:
int cx, cy;
ImageList_GetIconSize( imgl.m_hImageList, &cx, &cy);
Excellent! Thank you!!
-
March 11th, 2014, 09:37 AM
#9
Re: Size from CImageList
Yeah, that's much better.
Nobody cares how it works as long as it works
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|