From: GT on
I have a few views based on CTreeCtrl and CListCtrl. The list is set to
details view, so never uses large icons. I define an image list for them and
add the icons as follows:

int nColorDepth = CWindowDC(this).GetDeviceCaps(BITSPIXEL);
m_ImageList.Create(16, 16, nColorDepth > 16 ? ILC_COLOR32 :
ILC_COLOR24|ILC_MASK, 1, 1);
m_ImageList.Add(app->LoadIcon(IDI_FolderBlue));
etc etc for each icon.
I then use SetImageList to apply the icons to the list or tree.

My question is about the icons size on both the trees and lists. I want to
use the same icon on the tree and list, but:

Do they always have to be square?
Do they always have to be 16x16?
Can I make an icon that is the standard height, but wider - 32x16 for
example - maybe wider?

Thanks,
GT


From: Joseph M. Newcomer on
See below...
On Tue, 23 Mar 2010 11:47:59 -0000, "GT" <ContactGT_rem_ove_(a)hotmail.com> wrote:

>I have a few views based on CTreeCtrl and CListCtrl. The list is set to
>details view, so never uses large icons. I define an image list for them and
>add the icons as follows:
>
>int nColorDepth = CWindowDC(this).GetDeviceCaps(BITSPIXEL);
>m_ImageList.Create(16, 16, nColorDepth > 16 ? ILC_COLOR32 :
>ILC_COLOR24|ILC_MASK, 1, 1);
>m_ImageList.Add(app->LoadIcon(IDI_FolderBlue));
>etc etc for each icon.
>I then use SetImageList to apply the icons to the list or tree.
>
>My question is about the icons size on both the trees and lists. I want to
>use the same icon on the tree and list, but:
>
>Do they always have to be square?
****
Actually, no; for imges in an ImageList, your ImageList gives the dimensions, and all
icons have to be the same height and width. But for icons which are not in the imgelist,
they are real icons and have to be square.
****
>Do they always have to be 16x16?
****
Icons can be any size, and for listview in the icon view, they can be 48x48 or 65x64 as
well as 32x32. But if you are using icons to form an imagelist for a treeview, they should
be limited to 16x16
****
>Can I make an icon that is the standard height, but wider - 32x16 for
>example - maybe wider?
***
No. You can make a bimap of that size, however. Note as I said above all the images in
the imagelist have to be the same width and height, but don't have to be square.
joe

****
>
>Thanks,
>GT
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: GT on
"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:3gjhq5dq2sum13hpmphq30endngpjiotqf(a)4ax.com...
> See below...
> On Tue, 23 Mar 2010 11:47:59 -0000, "GT" <ContactGT_rem_ove_(a)hotmail.com>
> wrote:
>
>>I have a few views based on CTreeCtrl and CListCtrl. The list is set to
>>details view, so never uses large icons. I define an image list for them
>>and
>>add the icons as follows:
>>
>>int nColorDepth = CWindowDC(this).GetDeviceCaps(BITSPIXEL);
>>m_ImageList.Create(16, 16, nColorDepth > 16 ? ILC_COLOR32 :
>>ILC_COLOR24|ILC_MASK, 1, 1);
>>m_ImageList.Add(app->LoadIcon(IDI_FolderBlue));
>>etc etc for each icon.
>>I then use SetImageList to apply the icons to the list or tree.
>>
>>My question is about the icons size on both the trees and lists. I want to
>>use the same icon on the tree and list, but:
>>
>>Do they always have to be square?
> ****
> Actually, no; for imges in an ImageList, your ImageList gives the
> dimensions, and all
> icons have to be the same height and width. But for icons which are not
> in the imgelist,
> they are real icons and have to be square.
> ****
>>Do they always have to be 16x16?
> ****
> Icons can be any size, and for listview in the icon view, they can be
> 48x48 or 65x64 as
> well as 32x32. But if you are using icons to form an imagelist for a
> treeview, they should
> be limited to 16x16
> ****
>>Can I make an icon that is the standard height, but wider - 32x16 for
>>example - maybe wider?
> ***
> No. You can make a bimap of that size, however. Note as I said above all
> the images in
> the imagelist have to be the same width and height, but don't have to be
> square.
> joe

OK, thanks Joe. My list controls are hard-coded to details view style, so I
never need the larger 'icon' type views.

So, I could make a series of bitmaps each 32x16 and I load them into an
imagelist. I could then use that imagelist for my tree and list controls.
Would this give me tree items with 'images' that are 32x16 in size? I
presume, I simply have to change one number in my above code (a 16 to a 32)
as follows:

int nColorDepth = CWindowDC(this).GetDeviceCaps(BITSPIXEL);
m_ImageList.Create(32, 16, nColorDepth > 16 ? ILC_COLOR32 :
ILC_COLOR24|ILC_MASK, 1, 1);

And also change the line that loads the images, as it loads icons at the
moment:
m_ImageList.Add(app->LoadIcon(IDI_FolderBlue));


From: Tom Serface on
Just to add to Joe's response. I've done list controls with all sizes of
icons. In fact, you can use the icon in report view to even make the rows a
bigger size if you want (I do this with video thumbnails for example). This
also works on virtual list controls, but you'll have to tell it which icon
to replace.

So far as I know tree controls always have the same sized icons, but I've
never tried to make them larger so don't know for sure.

Tom

"GT" <ContactGT_rem_ove_(a)hotmail.com> wrote in message
news:4ba8aa53$0$7549$c3e8da3(a)news.astraweb.com...
> I have a few views based on CTreeCtrl and CListCtrl. The list is set to
> details view, so never uses large icons. I define an image list for them
> and add the icons as follows:
>
> int nColorDepth = CWindowDC(this).GetDeviceCaps(BITSPIXEL);
> m_ImageList.Create(16, 16, nColorDepth > 16 ? ILC_COLOR32 :
> ILC_COLOR24|ILC_MASK, 1, 1);
> m_ImageList.Add(app->LoadIcon(IDI_FolderBlue));
> etc etc for each icon.
> I then use SetImageList to apply the icons to the list or tree.
>
> My question is about the icons size on both the trees and lists. I want to
> use the same icon on the tree and list, but:
>
> Do they always have to be square?
> Do they always have to be 16x16?
> Can I make an icon that is the standard height, but wider - 32x16 for
> example - maybe wider?
>
> Thanks,
> GT
>
From: Joseph M. Newcomer on
See below...

On Tue, 23 Mar 2010 17:21:43 -0000, "GT" <ContactGT_rem_ove_(a)hotmail.com> wrote:

>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>news:3gjhq5dq2sum13hpmphq30endngpjiotqf(a)4ax.com...
>> See below...
>> On Tue, 23 Mar 2010 11:47:59 -0000, "GT" <ContactGT_rem_ove_(a)hotmail.com>
>> wrote:
>>
>>>I have a few views based on CTreeCtrl and CListCtrl. The list is set to
>>>details view, so never uses large icons. I define an image list for them
>>>and
>>>add the icons as follows:
>>>
>>>int nColorDepth = CWindowDC(this).GetDeviceCaps(BITSPIXEL);
>>>m_ImageList.Create(16, 16, nColorDepth > 16 ? ILC_COLOR32 :
>>>ILC_COLOR24|ILC_MASK, 1, 1);
***
I can't even read that or parse it. Note that if you EVER use the e?t:f style expression
you MUST write it as (e>t:f) with parentheses or you have no real idea how the compiler is
going to di the associations; for example, I believe as you have written it, the ILC_MASK
is ONLY present in the case where nColorDepth is <= 16. Also, use whitespace around all
binary operators to make them stand out. I might have used the ::GetSystemMetrics to get
the dimension of the small icon, instead of hardwiring 16.
***
>>>m_ImageList.Add(app->LoadIcon(IDI_FolderBlue));
>>>etc etc for each icon.
***
I would be more inclined to do this as a wide bitmap (which is how I usually do it) and
load the bitmap, then tell the imagelist to use the bitmap (this allows sizes that are not
square, because you are not using icons).
****
>>>I then use SetImageList to apply the icons to the list or tree.

>
>OK, thanks Joe. My list controls are hard-coded to details view style, so I
>never need the larger 'icon' type views.
>
>So, I could make a series of bitmaps each 32x16 and I load them into an
>imagelist. I could then use that imagelist for my tree and list controls.
>Would this give me tree items with 'images' that are 32x16 in size? I
>presume, I simply have to change one number in my above code (a 16 to a 32)
>as follows:
***
As I said, what I do is a bitmap n*32x16 wide, where n is the number of images. Depending
on the use of the imagelist, the first image (the 0th position) may nor may not be used;
in the cases where it isn't, I put two red diagonal lines across the image to indicate it
is the unused image, just to make it obvious what is going on.
>
>int nColorDepth = CWindowDC(this).GetDeviceCaps(BITSPIXEL);
>m_ImageList.Create(32, 16, nColorDepth > 16 ? ILC_COLOR32 :
>ILC_COLOR24|ILC_MASK, 1, 1);
****
Since you'e added 16x15 icons, I don't think you can change the size at this point. When
I do the creation of my imaglist, I then load the above-described bitmap and use it as the
basis of the image list. THe imagelist chops it at 32-wide units.
joe

****
>
>And also change the line that loads the images, as it loads icons at the
>moment:
>m_ImageList.Add(app->LoadIcon(IDI_FolderBlue));
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm