Groups | Blog | Home
all groups > dotnet drawing api > september 2005 >

dotnet drawing api : Problems with GetHicon method


simone.poste NO[at]SPAM libero.it
9/28/2005 4:58:42 AM
I've a problem converting System.Drawing.Bitmap in System.Drawing.Icon
using the GetHicon method.

This is my code sample :


private void pSetIco(int parNumImg)
{
System.Drawing.Bitmap b;
b=new Bitmap(this.ilIcons.Images[parNumImg]);
this.StartIcon.Icon = Icon.FromHandle(b.GetHicon());
}

There are no runtime errors but the result icon is a black box.
I've try to save the bitmap to a file and the file is ok.

Can anyone help me?
simone.poste NO[at]SPAM libero.it
9/28/2005 9:29:40 AM
I fill shoure that the bitmap in the imagelist is ok and the size is
16x16. I've try to save che bitmap after extrat it from the imagelist.

b.Save("Image.bmp",System.Drawing.Imaging.ImageFormat.Bmp);

I've also try to save the bitmap as Icon and that to load an icon from
this file but the system gives me a cast conversion error.
Lloyd Dupont
9/28/2005 10:59:28 PM
vu que moi ca marche bien je suspecte 2 choses:
1. this.ilIcons.Images[parNumImg];
kesako? t'es sur que c'est une bitmap correct?

2. p'tet que GetHicon marche que sur des bitmap qui on une taille d'icone
standart?
(16x16, 32x32, 48x48, 64x64, 96x96, 128x128)
ou un nombre de couleur standart (au pif j'dirais 16 & 256 couleurs, mais
j'ai vu des icones plus riches)


--
If you're in a war, instead of throwing a hand grenade at the enemy, throw
one of those small pumpkins. Maybe it'll make everyone think how stupid war
is, and while they are thinking, you can throw a real grenade at them.
Jack Handey.
[quoted text, click to view]

simone.poste NO[at]SPAM libero.it
10/7/2005 5:50:09 AM
I've solved the problem :
before the Main sub there was a directive : [STAThread]

Deleting this code line my application running well.

But now my question is : why till 1 month ago I can run application
with[STAThread] without problem and today it doesn't work? And more
What does [STAThread] means?
AddThis Social Bookmark Button