slaadvak
slaadvak

Reputation: 4779

Windows Default Icon shown on MessageBox

In the MainWindow constructor, before showing my MainWindow, I'm doing some checks that could prompt a MessageBox dialog. When this happens, an ugly Windows Default Icon is showing up in the Windows taksbar with the message box title beside.

I already set an Icon for my application in Properties -> Applicaton -> Resources -> Icon.

I tried to call InitializeComponent() before calling MessageBox.Show, but it doesn't change anything.

Once my application is fully launched (I exit the MainWindow constructor), the proper icon appears in the taskbar.

Is there a way to prevent this ugly icon from showing at all, or to replace it with my own ?

Upvotes: 1

Views: 3249

Answers (4)

rguarascia.ts
rguarascia.ts

Reputation: 813

As mentioned above, go to properties of your form, set the Icon to the one you wish ALSO go to Project > (name of project) Properties > Applications (tab) and set Icon there (at the bottom). Also you can change the icon of the messagebox with

MessageBox.Show("Foo", "Bar", MessageBoxButtons.OK, MessageBoxIcon.Warning);

Read more here

Upvotes: 1

Thomas Weller
Thomas Weller

Reputation: 59303

Do not show the message box from within the constructor. At this time the object (the form) is not fully created yet.

Try the form's Load event instead.

Upvotes: 0

HackerMan
HackerMan

Reputation: 914

if you are using visual studio.....go to properties window and change the icon property

enter image description here

Upvotes: 0

Raúl Otaño
Raúl Otaño

Reputation: 4760

This should only happens en Debug time. Try running with ctrl+f5, or excecuting the .exe file directly.

Upvotes: 1

Related Questions