• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

Create new icon for Form

I have a class that subclasses Windows.Forms.Form and I want to set the icon to something other than default. I see that I can use this.Icon to set it, but how to I create an Icon from an png that is a Resource?
0
allelopath
Asked:
allelopath
  • 6
  • 2
2 Solutions
 
p_davisCommented:
0
 
p_davisCommented:
just downloaded and tried it -- works fine/

the trial version is free but some of the functionality is unavailable but withing 1 minute i had an .ico file from a jpg
0
 
p_davisCommented:
here's the link for download

http://icofx.ro/
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
allelopathAuthor Commented:
I don't think this is what I'm looking for. I think I should be able to do it in code, something like:

Icon myIcon = new Icon ("myfile.png");
this.setIcon(myIcon);

but obviously its not that simple.
0
 
p_davisCommented:
sorry didn't realize you wanted runtime capability
//i think this will work.

               

Icon icon = System.Drawing.Icon.FromHandle(yourBitMap.GetHicon());
0
 
p_davisCommented:
sorry you will have to load your png into the bitmap class.
0
 
allelopathAuthor Commented:
I have the image as a Resource, accessible like so:
Image newImage = global::MyProject.Properties.Resources.myImageResource;
Can this be used?(sorry to change the question on you)
0
 
p_davisCommented:
yes you can but you will have put that image into a new bitmap class object, which is actually from the image class. however image doesnt have the .GetHicon() method.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now