Nov 1

I’m not sure if it was able in Windows Mobile 5, but in 6

enum FormWindowState contains just Normal and Maximized, but not Minimized.

 

You can use Form.Hide() minimize your form, but then your app is not visible in Task List, so e.i. you cannot sell your app through Microsoft Marketplace

BTW:

I read in many places, that Marketplace got horrible –> impossible to realize conditions, but conditions are fair and Marketplace will have better quality applications. In result will profit just customers.

Only thing is that you must pay 99USD for every app. Even they doesn’t allowed you to sell through their Marketplace

You must use Native methods to minimize your app. Here is a code:

 

[DllImport("coredll.dll")]
static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int uFlags);

[DllImport("coredll.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("coredll.dll")]
static extern IntPtr FindWindow(string className, string windowName);

public void SetToBackground(Form frm)
{
    SetWindowPos(frm.Handle, 1, frm.Top, frm.Left, 0, 0, 0x0004);
    SetForegroundWindow(FindWindow("DesktopExplorerWindow", "Desktop"));
}

public void SetToForeground(Form frm)
{
    frm.WindowState = FormWindowState.Normal;
}

The trick is very simple. You just changes Z index of your Form and then you MUST bring desktop to front.

It’ don’t have to be Desktop… you must do it because even your app is invisible it’s still visible in Task bar. When you want to show your app set WindowState to Normal or Maximized.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.