I’m working on a smart device with installed Windows Mobile 6.1. I need to completely hide my application (a Form), but i’m not able to do this. I tried to call the Form.Hide method, but it does not have any effects, the form is still open, visible and maximized. I tried also to follow this post:
[DllImport("coredll.dll")]
static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
public Form1()
{
InitializeComponent();
Hide();
}
public new void Hide()
{
const int SW_MINIMIZED = 6;
FormBorderStyle = FormBorderStyle.FixedDialog;
WindowState = FormWindowState.Normal;
ControlBox = true;
MinimizeBox = true;
MaximizeBox = true;
// Since there is no WindowState.Minimize, we have to P/Invoke ShowWindow
ShowWindow(this.Handle, SW_MINIMIZED);
}
But without any effects (again).
What is the proper way to do this work?
An application doesn’t need to have a call to
Application.Run(which requires a Form in the Compact Framework) to operate. If your app doesn’t need a UI, don’t create a Form. You can create a state loop, multithread and just about anything else from theMainentry point without a Form just fine. If you need to process Windows messages, you can always create your own message pump by callingGetMessageandDispatchMessageyourself.