I have a compact framework application that needs to be start hidden with Windows. So i created a shortcut in the Startup folder. The application starts fine but to my amazement despite i did a this.Hide()
on the constructor of the form, it still shows.
So i searched and found out that Application.Run() will ALWAYS show the window but OpenNETCF has a Run method in the Application2 class which can make sure that the Form is not shown.
[MTAThread]
static void Main(string[] args)
{
if (args.Length > 0)
{
OpenNETCF.Windows.Forms.Application2.Run (new frmMain("WINDOWS"), false, false);
}
else
{
MessageBox.Show("No Arguments!");
Application2.Run(new frmMain("SELF"));
}
}
And in the frmMain's constructor
public frmMain(string Argument)
{
InitializeComponent();
if (Argument != null && Argument != "")
{
if (Argument == "SELF")
{
//MessageBox.Show("Arugment passed was SELF = No Argument actually");
BringToFront(ApplicationName, ApplicationTitle);
}
else if (Argument == "WINDOWS")
{
//MessageBox.Show("Arugment passed was WINDOWS = Called by Windows");
Minimize();
}
}
}
If the application is started without parameters, everything works fine. I can hide/ minimize the application and starting the application will nicely start the application. But for some obscure reason if it is started by Windows (thus the parameter WINDOWS is passed) clicking on the EXE will not show the form :(
Any ideas what might be causing the issue? Thanx a lot in advance :)
Minimize and BringToFront are P/Invoked from coredll.dll