I think the way to go here is processing the WM_ACTIVE message and then checking if the fMinimized parameter is not zero. You can find more information on how to declare this messages in your code in here.
I will try figure out how to exactly code this in C# and prove the hypothesis. However you maybe faster than me and figure it out.
Also check the functions DefWindowProc and WindowProc, which are used to process the messages. Functions are declared in your code like this:
First have the include:
using System.Runtime.InteropServices;
then in the class declare like this
[DllImport("coredll.dll")]
static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, UIntPtr wParam,
IntPtr lParam);
There is another thing you could do, this is more a "philosophical" workaround. INMO the smart minimize X is confusing for users, that is why I don't like to include it. Instead I provide a button at the right lower corner of the form that says "close" or "back", which uses the close method of the form. I used it in all forms to keep a standard. This is less ambiguous for windows users because they may assume that the X in windows mobile is the same X in windows for PC.
If for some reason you need to minimize your app or send it to the background use the following code:
using System.Runtime.InteropServices;
...
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
[DllImport("coredll.dll")]
static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_MINIMIZED = 6;
...
...
public void HideForm()
{
ShowWindow(this.Handle, SW_MINIMIZED);
}
}
WindowProc
method for normalForm
s, so how can I make use of this advice? Or am I missing something here... – Patrolman