How to define single icon for main window and exe file? - c#

Usually I have to set 2 different icons. One in the project's settings tab, and one to the Icon property of main window. Is there a way to define single icon for the whole application (all windows and exe)?
Update: to be more concrete. I have app that is 100kb in size. I want to embed icon that is 300kb in size and want my app to be 400kb instead of 700

You need to set the icon in you project's properties:
For taskbar you need to change your main window's Icon:

When you set your exe icon, WPF will use that for all Windows you create. However, it doesn't do it in debug mode - that's because the "entry point" for your process is the .vshost.exe, not your exe. But if you use Ctrl+F5 (run without debugging), you should find all Windows get the exe icon. You shouldn't have to set it on each Window.
To make it work properly in debug mode, I generally set up a Style which I apply to each window, which sets the application icon.

Related

How can I set two different icons on the same form in Visual Studio?

I want to use two different icons for my Visual Studio program, one for the left side on the window and another for the taskbar. Is there any way to do it? Thank you.
edit: I mean I want to have two different icons, one for the window and another for the taskbar, as you can see in the imagesm because when you upload an icon it automatically puts the same icon for both of the situations mentioned in the images.
# Samuel.
The .ico file can contain multiple images. When you load the .ico file, Windows selects the most suitable image according to the current display mode and system settings to load one of the images.
You could create a multi-size icon with the different image and set the size to 64x64, 32x32, 16x16 respectively. In this way, you can include different images in one icon. Then set the Icon property of the form: select the prepared icon and click open.
When you run, you will get the effect in the picture below.

Place an application's icon into system tray

I'm making a desktop mascot with unity, and I do not want to see the icon appearing on the task bar, I want the icon in the system tray. Is there a way to do this?
PS: This is NOT a windows form (it's a game), so I believe Form.ShowInTaskbar will not work.
I've never programmed in Unity, but I'm assuming you are working in a Windows window. If you make the top level window for the application not appear in the main area of the Taskbar, make the window a "Tool Window" (by setting the WS_EX_TOOLWINDOW extended style on the window), then the window/app will not show up on the taskbar.
I'll leave it to someone how knows enough Unity to tell you how to set that style. Here's a reference to start with (on the Windows side, not the Unity side): Managing Taskbar Buttons

Why does my icon not appear in the title bar?

I have assigned an icon to my application from the Properties window in Solution Explorer in Visual Studio; the application's icon changed successfully but the title bar is still showing the default icon:
I've rebuilt my application but it still displays the default icon. What am I doing wrong?
Because forms have a different icaon configuration than the application. Set the icon on the form, not ONLY on the application.
There is another reason why the icon might not show.
If the ControlBox property of the Form is set to False the icon will not show.
(Sounds like an undesired side effect)
I know that it is a very old issue but I can add the following comment :
Pay attention to the 'FormBorderStyle' property.
If 'FixedToolWindow' or 'SizableToolWindow' are selected, your icon will not appear, even if you specified an icon in the 'Icon' property.
I encountered the same issue.
Good luck.
The form itself has an Icon property you need to set as well.
If you using winform you need to set the icon property of your main form
You didn't mention if you are using winforms or wpf - wpf will place the icon on all windows/forms unless overridden.
Winforms requires individually set icons.

Changing Form's Icon in Visual Studio 2012 C#

I am trying to change the icon of the form (top left) and any other place I see little squares default icon.
I have tried:
Clicking the form, go to "Window Style" and changing the Icon to the .ico file I have on my computer - this shows as if it actually changes - but whenever I debug or publish - it is still the original default Icon.
Going to Project's properties- Resources - adding the Icon as Resource - back to Application under Properties - change "Icon and Manifest" to the resourced Icon. It shows the new Icon next to the browse button - but nothing changes in the actual program.
Note at first the Background Image I had selected for the form wasn't applying either - I would change it via the form - Properties - Appearance - BackgroundImage - Select from computer. Would show as changed but as soon as I would debug or publish or would not be there.
-Added it to my resources and then chose it from the BackgroundImage browse - chose it from project resources and then it worked.
Found a solution:
With the idea that my Background image wasn't working until I had it in the Resources. I went to the Form1_load event and added the following code:
System.Drawing.Icon ico = Properties.Resources.Untitled;
this.Icon = ico;
As "Properties.Resources.Untitled" being my icon that I added to my Resources.
And now seems to be workings as wanted.
You need to change the icon on every form as well using the Icon property of the Form.

How to set Visual-Studio .NET CompactFramework Windows-CE default window size

This C# Windows-CE tablet application needs WindowState Maximized and Size set to 800x480 to completely fill the screen
but any time the winforms design file is opened for editing, the framework resets the Size to 640x480.
The Size then has to be set manually to 800x480 each time.
Is this a framework defect or is there a hard to find configuration setting?
Configuration setting I think, the size is unusual. Tools + Options, Device Tools, Form Factors. Pick the one you used to get your project started, Properties, untick "Show skin" and change the Screen Width and Screen Height values. OK. Close the form designer window and open it again. Beware that your form won't work well on other devices.

Categories

Resources