views:

346

answers:

7
+2  Q: 

Application Icon

I have 3 icons. When I compile application I use first Icon - main app icon.
And I have 2 other icons in resources.

When I show MessageBox.Show(...) the first app icon appear in task bar. I want to have an ability to change the main icon at runtime at some reason.

A: 

I'm not sure you can change the icon for a standard MessageBox. You might have to make your own MesageBox. Then it's just changing the icon for a standard winform. That has been documented extensively both on MSDN and a lot of pages that can be found with Google.

Vilx-
A: 

Yes. The aim is to have 3 icons 1 - for application exe file 2 - to show on all MessageBoxes, and so on for development version 2 - to show on all MessageBoxes, and so on for production version

Off course it's possible to not to use standart MessageBoxes or change icon in MsBuild.

But it needs to change at runtime. And suggestions?

Hi Xeon, it's easier if you put replies to people's questions on the comment for that question, rather than making a new answer.
Matt Warren
+1  A: 

I don't think it's straight forward, take a look at this article it might help you out.

Matt Warren
A: 

It's not this. It's for changing ShellNotifyIcon. But I need to change Icon for all application at runtime.

A: 

I'm pretty sure that the standard MessageBox.Show() method can't show a custom icon (you can specify from a few different ones in the enumeration, but you can't put an arbitrary one there), but if you have a normal .NET form, just set the 'Icon' property to the image you'd like and it works. When doing this at runtime, the normal suspend/resume layout calls before and after might be necessary, or they might not, I dunno, but it shouldn't be a huge chore to set a property on a form.

Kevin
+1  A: 

You can change the icon that appears inside the message box by using P/Invoke to call the Windows MessageBoxIndirect function.

Tim Robinson
+1  A: 

While it's already mentioned here about P/Invoke - there is a good article about changing icon http://www.codeproject.com/KB/dialog/MessageBoxIndirectCS.aspx if you don't want to write own MessageBox.

Mash