Click here to Skip to main content
15,902,908 members
Home / Discussions / Windows Forms
   

Windows Forms

 
AnswerRe: Flickering Problem Pin
Henry Minute12-Sep-09 5:51
Henry Minute12-Sep-09 5:51 
AnswerRe: Flickering Problem Pin
April Fans21-Sep-09 21:46
April Fans21-Sep-09 21:46 
QuestionChange Background image of form runtime Pin
swapnil_bhanagle10-Sep-09 6:15
swapnil_bhanagle10-Sep-09 6:15 
AnswerRe: Change Background image of form runtime Pin
dan!sh 11-Sep-09 6:33
professional dan!sh 11-Sep-09 6:33 
AnswerRe: Change Background image of form runtime Pin
April Fans21-Sep-09 21:44
April Fans21-Sep-09 21:44 
Questionlogical expression editor Pin
r.ps9-Sep-09 19:00
r.ps9-Sep-09 19:00 
QuestionDifferent Icon on the title bar than on the application tab Pin
andy4009-Sep-09 10:50
andy4009-Sep-09 10:50 
AnswerRe: Different Icon on the title bar than on the application tab Pin
Luc Pattyn9-Sep-09 10:57
sitebuilderLuc Pattyn9-Sep-09 10:57 
Hi,

Some comments on applications and icons:

1.
An application typically has two different icons:
- the application itself has an icon at the file level; it gets used by Windows Explorer; you set it as a project property. (right click the project in the solution pane, choose application tab, and specify the icon file/resource there)
- any form can have an icon; it is a Form property, that you can set through Visual Designer. It also shows up in the task bar's button (if the Form shows in task bar). A form’s icon, when set by Visual Designer, gets stored in the Form’s resx file.

2.
You can set a Form’s icon programmatically. An easy way to do that consists of:
- add the ICO file to the project;
- give the file the Build Action “embedded resource” so it gets included in the app’s resources.
- use one of the Icon constructors to get the icon resource, as in:
this.Icon=new Icon(this.GetType(), "name.ico");
- if the icon file is not at the top-level of the solution, add its relative path to the icon name; so if it resides in directory “resources”, change the above constructor statement to …"resources.name.ico");

3.
an icon file can hold multiple icons (icons at different sizes), and Windows will pick one depending on circumstances, so if they do not all look alike, you may get very confused.

4.
I tend to create icons programmatically; the following code converts a (best small,
square) image into a simple icon:

string filename=popupNode.getLongName();
try {
	Bitmap bm=(Bitmap)Image.FromFile(filename);
	if(bm.Width!=32 || bm.Height!=32) {
		bm=new Bitmap(bm, 32, 32);
	}
	Icon icon=Icon.FromHandle(bm.GetHicon());
	bm.Dispose();
	string filename2=Path.ChangeExtension(filename, ".ico");
	Stream stream=new FileStream(filename2, FileMode.Create);
	icon.Save(stream);
	log("Created icon "+filename2);
} catch(Exception exc) {
	log("Failed to create icon from "+filename);
	log(exc.ToString());
}


Smile | :)

Luc Pattyn

Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.


GeneralRe: Different Icon on the title bar than on the application tab Pin
andy4009-Sep-09 11:24
andy4009-Sep-09 11:24 
GeneralRe: Different Icon on the title bar than on the application tab Pin
Luc Pattyn9-Sep-09 11:32
sitebuilderLuc Pattyn9-Sep-09 11:32 
AnswerRe: Different Icon on the title bar than on the application tab Pin
April Fans21-Sep-09 21:45
April Fans21-Sep-09 21:45 
QuestionA problem with Generics [modified] Pin
Henry Minute9-Sep-09 8:03
Henry Minute9-Sep-09 8:03 
QuestionRegions with in a function Pin
εїзεїзεїз8-Sep-09 15:37
εїзεїзεїз8-Sep-09 15:37 
AnswerRe: Regions with in a function Pin
dan!sh 8-Sep-09 22:52
professional dan!sh 8-Sep-09 22:52 
QuestionForm Resizing and Docked Controls Pin
farzadmf8-Sep-09 12:48
farzadmf8-Sep-09 12:48 
AnswerRe: Form Resizing and Docked Controls Pin
Henry Minute8-Sep-09 13:04
Henry Minute8-Sep-09 13:04 
GeneralRe: Form Resizing and Docked Controls Pin
farzadmf8-Sep-09 20:05
farzadmf8-Sep-09 20:05 
GeneralRe: Form Resizing and Docked Controls Pin
Henry Minute9-Sep-09 7:35
Henry Minute9-Sep-09 7:35 
AnswerRe: Form Resizing and Docked Controls Pin
farzadmf9-Sep-09 10:05
farzadmf9-Sep-09 10:05 
GeneralRe: Form Resizing and Docked Controls Pin
Henry Minute9-Sep-09 10:56
Henry Minute9-Sep-09 10:56 
GeneralRe: Form Resizing and Docked Controls Pin
farzadmf9-Sep-09 11:45
farzadmf9-Sep-09 11:45 
GeneralRe: Form Resizing and Docked Controls [Hold the Front Page] Pin
Henry Minute9-Sep-09 11:10
Henry Minute9-Sep-09 11:10 
AnswerRe: Form Resizing and Docked Controls Pin
Zoki Manas8-Sep-09 23:06
Zoki Manas8-Sep-09 23:06 
AnswerRe: Form Resizing and Docked Controls Pin
farzadmf8-Sep-09 23:55
farzadmf8-Sep-09 23:55 
AnswerRe: Form Resizing and Docked Controls Pin
geali_dor9-Sep-09 19:46
geali_dor9-Sep-09 19:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.