PictureBox Control and small icon

PictureBox Control and small icon

Post by Bob Brow » Fri, 07 Dec 2001 11:15:01



I have loaded a icon into a PictureBox control. Using this syntax:

PictureBox1.Picture = ImageList1.ListImage(1).Picture

The ImageList control is set for 16x16 size. The icons all contain various
sizes from 16x16 to 48x48.

In Windows XP, Windows 2000, Windows 98 and Windows ME I get the small icon
in the control  --which is what I want. Under Windows NT 4 I get the 48x48
size icon. I am not sure how I can get the smaller icon size into the
control under NT4. I know that LoadPicture offers a constant value to pass
for setting the icon as small and this does work. The problem is that I do
not wish to install several loose icons in the same folder as the program
(or wherever). I'd prefer they be imbedded. I have tried using the property
page of the PictureBox control and I get the same behavior. I tried
extracting the small icon and saving it but this also did not work for me.

Any suggestions on how to overcome this issue would be greatly appreciated.

JR

 
 
 

PictureBox Control and small icon

Post by J Fren » Sat, 08 Dec 2001 00:59:37


I'm not sure whether this will help, but some time ago I spent days
trying to get the small Icon into a Picturebox (under VB5) - and
eventually solved it using this.  The downside is that it does not
work properly in LargeFont :-

    picIcon.AutoRedraw = False
    ' --- Get the Picture Box Size
    X = picIcon.ScaleWidth / Screen.TwipsPerPixelX
    Y = picIcon.ScaleHeight / Screen.TwipsPerPixelY
    ' --- Get the Small Icon
    hSmall = SendMessage(Me.hwnd, WM_GETICON, ICON_SMALL, 0&)
    ' --- Draw the Icon in the PictureBox
    DrawIconEx picIcon.hdc, 0, 0, hSmall, X, Y, 0, 0, DI_NORMAL


Quote:>I have loaded a icon into a PictureBox control. Using this syntax:

>PictureBox1.Picture = ImageList1.ListImage(1).Picture

>The ImageList control is set for 16x16 size. The icons all contain various
>sizes from 16x16 to 48x48.

>In Windows XP, Windows 2000, Windows 98 and Windows ME I get the small icon
>in the control  --which is what I want. Under Windows NT 4 I get the 48x48
>size icon. I am not sure how I can get the smaller icon size into the
>control under NT4. I know that LoadPicture offers a constant value to pass
>for setting the icon as small and this does work. The problem is that I do
>not wish to install several loose icons in the same folder as the program
>(or wherever). I'd prefer they be imbedded. I have tried using the property
>page of the PictureBox control and I get the same behavior. I tried
>extracting the small icon and saving it but this also did not work for me.

>Any suggestions on how to overcome this issue would be greatly appreciated.

>JR


 
 
 

PictureBox Control and small icon

Post by Bob Brow » Sat, 08 Dec 2001 03:54:17


Thanks for the reply. I do have a follow up question. This call:

hSmall = SendMessage(Me.hwnd, WM_GETICON, ICON_SMALL, 0&)

Is Me.hwnd the handle to the PictureBox control or the Form? I suspect the
Form. But then if it is, how do you get the icon in a ImageList control
using that call? If you can't, and I suspect that is the case, then it
appears you're simply getting an icon assigned to the Form only. If so, then
how do you handle multiple icons like an ImageList?

JR


> I'm not sure whether this will help, but some time ago I spent days
> trying to get the small Icon into a Picturebox (under VB5) - and
> eventually solved it using this.  The downside is that it does not
> work properly in LargeFont :-

>     picIcon.AutoRedraw = False
>     ' --- Get the Picture Box Size
>     X = picIcon.ScaleWidth / Screen.TwipsPerPixelX
>     Y = picIcon.ScaleHeight / Screen.TwipsPerPixelY
>     ' --- Get the Small Icon
>     hSmall = SendMessage(Me.hwnd, WM_GETICON, ICON_SMALL, 0&)
>     ' --- Draw the Icon in the PictureBox
>     DrawIconEx picIcon.hdc, 0, 0, hSmall, X, Y, 0, 0, DI_NORMAL


> >I have loaded a icon into a PictureBox control. Using this syntax:

> >PictureBox1.Picture = ImageList1.ListImage(1).Picture

> >The ImageList control is set for 16x16 size. The icons all contain
various
> >sizes from 16x16 to 48x48.

> >In Windows XP, Windows 2000, Windows 98 and Windows ME I get the small
icon
> >in the control  --which is what I want. Under Windows NT 4 I get the
48x48
> >size icon. I am not sure how I can get the smaller icon size into the
> >control under NT4. I know that LoadPicture offers a constant value to
pass
> >for setting the icon as small and this does work. The problem is that I
do
> >not wish to install several loose icons in the same folder as the program
> >(or wherever). I'd prefer they be imbedded. I have tried using the
property
> >page of the PictureBox control and I get the same behavior. I tried
> >extracting the small icon and saving it but this also did not work for
me.

> >Any suggestions on how to overcome this issue would be greatly
appreciated.

> >JR

 
 
 

PictureBox Control and small icon

Post by J Fren » Sat, 08 Dec 2001 09:47:31



Quote:>Thanks for the reply. I do have a follow up question. This call:

>hSmall = SendMessage(Me.hwnd, WM_GETICON, ICON_SMALL, 0&)

>Is Me.hwnd the handle to the PictureBox control or the Form? I suspect the
>Form. But then if it is, how do you get the icon in a ImageList control
>using that call? If you can't, and I suspect that is the case, then it
>appears you're simply getting an icon assigned to the Form only. If so, then
>how do you handle multiple icons like an ImageList?

Right now that beats me - post an anodyne message and I'll look into
it tomorrow.

>JR



>> I'm not sure whether this will help, but some time ago I spent days
>> trying to get the small Icon into a Picturebox (under VB5) - and
>> eventually solved it using this.  The downside is that it does not
>> work properly in LargeFont :-

>>     picIcon.AutoRedraw = False
>>     ' --- Get the Picture Box Size
>>     X = picIcon.ScaleWidth / Screen.TwipsPerPixelX
>>     Y = picIcon.ScaleHeight / Screen.TwipsPerPixelY
>>     ' --- Get the Small Icon
>>     hSmall = SendMessage(Me.hwnd, WM_GETICON, ICON_SMALL, 0&)
>>     ' --- Draw the Icon in the PictureBox
>>     DrawIconEx picIcon.hdc, 0, 0, hSmall, X, Y, 0, 0, DI_NORMAL


>> >I have loaded a icon into a PictureBox control. Using this syntax:

>> >PictureBox1.Picture = ImageList1.ListImage(1).Picture

>> >The ImageList control is set for 16x16 size. The icons all contain
>various
>> >sizes from 16x16 to 48x48.

>> >In Windows XP, Windows 2000, Windows 98 and Windows ME I get the small
>icon
>> >in the control  --which is what I want. Under Windows NT 4 I get the
>48x48
>> >size icon. I am not sure how I can get the smaller icon size into the
>> >control under NT4. I know that LoadPicture offers a constant value to
>pass
>> >for setting the icon as small and this does work. The problem is that I
>do
>> >not wish to install several loose icons in the same folder as the program
>> >(or wherever). I'd prefer they be imbedded. I have tried using the
>property
>> >page of the PictureBox control and I get the same behavior. I tried
>> >extracting the small icon and saving it but this also did not work for
>me.

>> >Any suggestions on how to overcome this issue would be greatly
>appreciated.

>> >JR

 
 
 

PictureBox Control and small icon

Post by Rocky Clar » Sat, 08 Dec 2001 22:22:06


This will extract the icon at the size set by the ImageList's
ImageWidth/ImageHeight properties:

    Set Picture1.Picture = ImageList1.ListImage(1).ExtractIcon

HTH,
Rocky Clark (Kath-Rock Software)


Quote:> I have loaded a icon into a PictureBox control. Using this syntax:

> PictureBox1.Picture = ImageList1.ListImage(1).Picture

> The ImageList control is set for 16x16 size. The icons all contain various
> sizes from 16x16 to 48x48.

> In Windows XP, Windows 2000, Windows 98 and Windows ME I get the small
icon
> in the control  --which is what I want. Under Windows NT 4 I get the 48x48
> size icon. I am not sure how I can get the smaller icon size into the
> control under NT4. I know that LoadPicture offers a constant value to pass
> for setting the icon as small and this does work. The problem is that I do
> not wish to install several loose icons in the same folder as the program
> (or wherever). I'd prefer they be imbedded. I have tried using the
property
> page of the PictureBox control and I get the same behavior. I tried
> extracting the small icon and saving it but this also did not work for me.

> Any suggestions on how to overcome this issue would be greatly
appreciated.

> JR

 
 
 

PictureBox Control and small icon

Post by Bob Brow » Sun, 09 Dec 2001 08:43:10


Many thanks for the succinct reply. It worked perfectly.

JR


> This will extract the icon at the size set by the ImageList's
> ImageWidth/ImageHeight properties:

>     Set Picture1.Picture = ImageList1.ListImage(1).ExtractIcon

> HTH,
> Rocky Clark (Kath-Rock Software)



> > I have loaded a icon into a PictureBox control. Using this syntax:

> > PictureBox1.Picture = ImageList1.ListImage(1).Picture

> > The ImageList control is set for 16x16 size. The icons all contain
various
> > sizes from 16x16 to 48x48.

> > In Windows XP, Windows 2000, Windows 98 and Windows ME I get the small
> icon
> > in the control  --which is what I want. Under Windows NT 4 I get the
48x48
> > size icon. I am not sure how I can get the smaller icon size into the
> > control under NT4. I know that LoadPicture offers a constant value to
pass
> > for setting the icon as small and this does work. The problem is that I
do
> > not wish to install several loose icons in the same folder as the
program
> > (or wherever). I'd prefer they be imbedded. I have tried using the
> property
> > page of the PictureBox control and I get the same behavior. I tried
> > extracting the small icon and saving it but this also did not work for
me.

> > Any suggestions on how to overcome this issue would be greatly
> appreciated.

> > JR

 
 
 

PictureBox Control and small icon

Post by Rocky Clar » Sun, 09 Dec 2001 08:58:34


You're welcome. The small icon is relatively easy. It's the large icon that
will give you problems. If you notice, when you load an icon into the
ImageList, it always loads the small icon, so even if you set the size to 32
and use extract icon, you will just get the small icon stretched to 32.

Rocky


> Many thanks for the succinct reply. It worked perfectly.

> JR



> > This will extract the icon at the size set by the ImageList's
> > ImageWidth/ImageHeight properties:

> >     Set Picture1.Picture = ImageList1.ListImage(1).ExtractIcon

> > HTH,
> > Rocky Clark (Kath-Rock Software)



> > > I have loaded a icon into a PictureBox control. Using this syntax:

> > > PictureBox1.Picture = ImageList1.ListImage(1).Picture

> > > The ImageList control is set for 16x16 size. The icons all contain
> various
> > > sizes from 16x16 to 48x48.

> > > In Windows XP, Windows 2000, Windows 98 and Windows ME I get the small
> > icon
> > > in the control  --which is what I want. Under Windows NT 4 I get the
> 48x48
> > > size icon. I am not sure how I can get the smaller icon size into the
> > > control under NT4. I know that LoadPicture offers a constant value to
> pass
> > > for setting the icon as small and this does work. The problem is that
I
> do
> > > not wish to install several loose icons in the same folder as the
> program
> > > (or wherever). I'd prefer they be imbedded. I have tried using the
> > property
> > > page of the PictureBox control and I get the same behavior. I tried
> > > extracting the small icon and saving it but this also did not work for
> me.

> > > Any suggestions on how to overcome this issue would be greatly
> > appreciated.

> > > JR

 
 
 

1. Form Icon - How to get small icon

I'm having difficulty with form icons.  I've created a multi-format icon
file with 16x16, 32x32, 48x48, and 64x64 pixel icons.  I've associated the
icon file with a form.  Everything works fine.  However, I want to take the
icon and put it in a picture control.  On two different Win2K SP2 machines,
I seem to be getting different results.  I'm putting the icon in the picture
control like this:

Set picTemp.Picture = UserControl.Parent.Icon

On one machine, it puts the 16x16 icon in the picture control, on the other,
it puts the 32x32 icon in the picture control.  I don't want to squish the
32x32 image, I want to use the 16x16 image.  Is there some way I can
referece the forms icon and specify which format (size) I want?  At runtime
I don't have access to the original .ico file that has the icons.

Thanks in advance,

-jef

2. Bezier surfaces

3. Converting Large Icons to Small Icons

4. Coin: SoXtMouse/SoXtKeyboard

5. how to save standard icon as small icon?

6. Boxplot

7. (XP icons) 32-bits-per-pixel Icons in a Image control

8. A Generic 3D Graphics Kernel V1.4

9. Print/save entire PictureBox w/ child controls

10. Transparent PictureBox control

11. How to save WMF to BMP without PictureBox Control

12. vb6 Picturebox used in activex-control with access report

13. create file from picturebox control