You know when an app's main form is minimized, if you left click on
the taskbar icon, the System Menu Restore function is performed. I
would like to disable that. I tried:
private const Int32 WM_SYSCOMMAND = 0x112;
private const Int32 SC_RESTORE = 0xf120;
protected override void WndProc(ref Message m)
{
bool ignore = false;
if (m.Msg == WM_SYSCOMMAND)
{
switch (m.WParam.ToInt32())
{
case SC_RESTORE:
ignore = true;
break;
}
}
if (!ignore)
{
base.WndProc(ref m);
}
}
And that works. But only SOMETIMES.
Any idea what I am doing wrong?
|