[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Icons changing in ImageList for version 5 ListView

(Mike Mitchell)

7/20/2011 3:52:00 PM

I've added three icons to an ImageList named SmallImages. UseMaskColor
is unchecked.

The icons appear correctly when I run the app and hit a test button to
apply one of the icons in ListView. (This is a version 5 ListView BTW
and matching ImageList control.)

However, when I return to design mode, then immediately run the app
again, the icons have changed. They now look crap.

The icons are 16x16x256.

Here are screenshots:
http://www.littletyke.myzen.co.uk/ic...

(Scroll down a bit to see the 'bad' icons.)

I'm not modifying the icons at run-time in any way. In Form_Load I
have:

lvwFiles.SmallIcons = SmallImages

Then I have a command button for testing:

lvwFiles.SelectedItem.SmallIcon = "partial"

and it displays fine the FIRST time the app is run (in IDE).
Thereafter, when app is subsequently run, with no change to ImageList,
the icon looks like one of those in the lower screenshot.

Again, I've searched the web, but cannot (yet) find any reason why
this is happening.

MM
6 Answers

Abhishek

7/20/2011 4:13:00 PM

0

it happens with me too, try using 256 color icon (that is the max imagelist
can support) or use 256 color bitmap with maskcolor. export those icons with
magenta maskcolor using any icon editor and save them as bmp. if you still
want to use icons, then load a icon at runtime on a picturebox, then one by
one add those to the imagelist using code.

not sure why this happens, surely a bug in imagelist, I think it happens
when a user's screen resolution is 32-bit color and vb6 see it as error so
it lower the quality of icons to 16 color. that is why I always use 256
color bitmaps in imagelist.

--
abhishek

"MM" <kylix_is@yahoo.co.uk> wrote in message
news:uisd27ho50jk57tli23s75vjiut0ddnah3@4ax.com...
| I've added three icons to an ImageList named SmallImages. UseMaskColor
| is unchecked.
|
| The icons appear correctly when I run the app and hit a test button to
| apply one of the icons in ListView. (This is a version 5 ListView BTW
| and matching ImageList control.)
|
| However, when I return to design mode, then immediately run the app
| again, the icons have changed. They now look crap.
|
| The icons are 16x16x256.
|
| Here are screenshots:
| http://www.littletyke.myzen.co.uk/ic...
|
| (Scroll down a bit to see the 'bad' icons.)
|
| I'm not modifying the icons at run-time in any way. In Form_Load I
| have:
|
| lvwFiles.SmallIcons = SmallImages
|
| Then I have a command button for testing:
|
| lvwFiles.SelectedItem.SmallIcon = "partial"
|
| and it displays fine the FIRST time the app is run (in IDE).
| Thereafter, when app is subsequently run, with no change to ImageList,
| the icon looks like one of those in the lower screenshot.
|
| Again, I've searched the web, but cannot (yet) find any reason why
| this is happening.
|
| MM


(Mike Mitchell)

7/20/2011 5:55:00 PM

0

On Wed, 20 Jul 2011 21:43:26 +0530, "Abhishek"
<abhishek007p@hotmail.com> wrote:

>it happens with me too, try using 256 color icon (that is the max imagelist
>can support) or use 256 color bitmap with maskcolor. export those icons with
>magenta maskcolor using any icon editor and save them as bmp. if you still
>want to use icons, then load a icon at runtime on a picturebox, then one by
>one add those to the imagelist using code.
>
>not sure why this happens, surely a bug in imagelist, I think it happens
>when a user's screen resolution is 32-bit color and vb6 see it as error so
>it lower the quality of icons to 16 color. that is why I always use 256
>color bitmaps in imagelist.

I'll try doing what you suggest, thanks.

A follow-up: I can't get by head around the UseMaskColor and the Color
tab. You've got BackColor and MaskColor in Properties. In the Color
Set combo you've got a choice between Standard Colors and Windows
System Colors, and then there's the Color Palette with the options
<Custom...> and Black.

What on earth is this all supposed to mean?!! I've played around with
all the settings, but I haven't a clue what Microsoft was thinking
here.

MM

(Mike Mitchell)

7/20/2011 7:23:00 PM

0

On Wed, 20 Jul 2011 21:43:26 +0530, "Abhishek"
<abhishek007p@hotmail.com> wrote:

>it happens with me too, try using 256 color icon (that is the max imagelist
>can support) or use 256 color bitmap with maskcolor. export those icons with
>magenta maskcolor using any icon editor and save them as bmp. if you still
>want to use icons, then load a icon at runtime on a picturebox, then one by
>one add those to the imagelist using code.
>
>not sure why this happens, surely a bug in imagelist, I think it happens
>when a user's screen resolution is 32-bit color and vb6 see it as error so
>it lower the quality of icons to 16 color. that is why I always use 256
>color bitmaps in imagelist.

Okay, final post today. I've given up trying to insert pictures at
design time. I tried 256 colours (.ico), then I tried 8 colours, but
still the icons got screwed the second time the app was run.

Then I adopted your approach: I placed three image controls on the
form and put the relevant icon (with 256 colours) in each one (at
design time). Then in Form_Load I load the ImageList:

SmallImages.ListImages.Add , "fail", imgFail.Picture
SmallImages.ListImages.Add , "partial", imgPartial.Picture
SmallImages.ListImages.Add , "success", imgSuccess.Picture

And finally tie the ImageList to the ListView:

lvwFiles.SmallIcons = SmallImages

This works every time I run the app now!

I might try one last time tomorrow with your further suggestion,
namely 256 colour bitmaps instead of icons. However, it's no real
sweat doing what I've just done above, via image controls.

MM

MikeD

7/20/2011 9:15:00 PM

0



"MM" <kylix_is@yahoo.co.uk> wrote in message
news:09ae27pee1hrn80h6pqr91sa7cj8430vfb@4ax.com...
>
> Then I adopted your approach: I placed three image controls on the
> form and put the relevant icon (with 256 colours) in each one (at
> design time). Then in Form_Load I load the ImageList:
>
> SmallImages.ListImages.Add , "fail", imgFail.Picture
> SmallImages.ListImages.Add , "partial", imgPartial.Picture
> SmallImages.ListImages.Add , "success", imgSuccess.Picture
>

It probably wouldn't make all that much difference with only 3 images, but
instead of using Image controls you might want to put your icons in a
resource file and then use LoadResPicture to assign from the resource to
your ImageList. If you had a lot of images (intentionally arbitrary since "a
lot" means a different number to different people), this would definitely be
a better approach. At the very least, though, you should be using a control
array for your Image controls. Define constants to use for the index of
each Image control in the control array. If you do decide to go with the
icons in a resource file, use the same numeric value for the icon resource
ID as the index of the Image control in the control array. That'll make
things easier (for example, you can then use a loop). You could get by with
having only one Image control on your form at design-time and load
additional Image controls into the control array at runtime. But again,
with only 3 images, not a big deal to do things this way.

--
Mike


(Mike Mitchell)

7/21/2011 5:49:00 AM

0

On Wed, 20 Jul 2011 17:15:07 -0400, "MikeD" <nobody@nowhere.edu>
wrote:

>
>
>"MM" <kylix_is@yahoo.co.uk> wrote in message
>news:09ae27pee1hrn80h6pqr91sa7cj8430vfb@4ax.com...
>>
>> Then I adopted your approach: I placed three image controls on the
>> form and put the relevant icon (with 256 colours) in each one (at
>> design time). Then in Form_Load I load the ImageList:
>>
>> SmallImages.ListImages.Add , "fail", imgFail.Picture
>> SmallImages.ListImages.Add , "partial", imgPartial.Picture
>> SmallImages.ListImages.Add , "success", imgSuccess.Picture
>>
>
>It probably wouldn't make all that much difference with only 3 images, but
>instead of using Image controls you might want to put your icons in a
>resource file and then use LoadResPicture to assign from the resource to
>your ImageList. If you had a lot of images (intentionally arbitrary since "a
>lot" means a different number to different people), this would definitely be
>a better approach. At the very least, though, you should be using a control
>array for your Image controls. Define constants to use for the index of
>each Image control in the control array. If you do decide to go with the
>icons in a resource file, use the same numeric value for the icon resource
>ID as the index of the Image control in the control array. That'll make
>things easier (for example, you can then use a loop). You could get by with
>having only one Image control on your form at design-time and load
>additional Image controls into the control array at runtime. But again,
>with only 3 images, not a big deal to do things this way.

Oh, indeed I totally agree with your comments, thanks BTW. The three
image controls I whacked onto the form were just a quick and dirty
solution to see whether it would work. In addition to your suggestions
(although I've used resource files in the past and find them usually a
PITA to implement), there's also a PictureClip control I seem to
recall that I haven't used for ages. (Although on just reading up
about it a few moments ago, it also seems like another PITA.) The
resource file approach looks like the most sophisticated solution
really.

But, yes, there are only a few images in this app. Yesterday I started
looking at vbaccelerator's replacement ImageList control, then read
the small print that it's not suitable as a plug-in replacement for
the MS ListView or TreeView, but only for Steve's own vbaccelerator
alternatives.

MM

Abhishek

7/21/2011 2:27:00 PM

0

When working with resource file, you need to be aware of vb6 bug, if you
place 16x16 icon in resource file, vb6 might return it 32x32. fix is
available here http://vb.mvps.org... look for Repair Distorted,
Shrunken Icons

and there is another bug related to form icon
look for Form Icon Bug Fix Demo
http://www.mvps.org/vbvision/grouped...