I'm facing a small problem with my message boxes. If I run the program directly (as in, double clicking it and using it from there), they work fine.
I have some .ext files than when double clicked, run through the program (they are associated with my program). Now when message boxes run through there, they are shown, but they are minimized and I have to manually click them on the Task Bar to see them.
Does anyone know why this is? I have this code running in my Program.cs:
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var MyForm = new Form1();
if (args.Length != 0)
{
MyForm.RunMsg(); // this is a function I am calling
Application.Exit();
}
else
Application.Run(MyForm);
}
Any help would be appreciated. And yes I can confirm the message boxes are only minimized when running the .ext files.
I very seriously doubt they are actually minimized. Much more likely is that they are hidden behind the window of another application. Yes, that's likely in this scenario because you don't create a window right away. You probably crunch on the passed file for a while, then try to tell the user that you are done. Too late to still be able to acquire the focus, Windows has very strict rules about this to avoid the "throw a window in the user's face" syndrome. Not just annoying, it is also likely to fail because the user might accidentally close the window while mousing or keyboarding without even noticing that there was a window. If you ever accidentally started a Windows Update install then you know what I mean (now fixed).
Don't use a message box. Either create a progress form so that you can acquire the focus and show progress or use a NotifyIcon.