HighTechTalks DotNet Forums  

Problems with GetHicon method

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Problems with GetHicon method in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Problems with GetHicon method - 09-28-2005 , 06:58 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?


Reply With Quote
  #2  
Old   
Lloyd Dupont
 
Posts: n/a

Default Re: Problems with GetHicon method - 09-28-2005 , 07:59 AM






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.
<simone.poste (AT) libero (DOT) it> wrote

Quote:
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?




Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: Problems with GetHicon method - 09-28-2005 , 11:29 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.ImageFor mat.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.


Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: Problems with GetHicon method - 10-07-2005 , 07:50 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?


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.