Hi,
How do I detect when a form is minimizing? specifically when a user
clicks the show desktop button on the taskbar, rather than the
minimize button on a form.
thanks in advance
I spent yesterday puzzling this out and ended up over-riding the
WndProc as follows:
protected override void WndProc(ref Message message)
{
base.WndProc(ref message);
switch (message.Msg)
{
case WM_SYSCOMMAND:
if ((int)message.WParam == SC_MINIMIZE)
{
this.ShowInTaskbar = false;
notifyIcon1.Visible = true;
this.Visible = false;
m_blnInTray = true;
}
break;
}
}
The constants are:
const int SC_RESTORE = 0xF120;
const int WM_SYSCOMMAND = 0x0112;
const int SC_MINIMIZE = 0xF020;
To restore the Window I use:
SendMessage(this.Handle, WM_SYSCOMMAND, SC_RESTORE, IntPtr.Zero);
I couldn't find a .NET way, but if there is one I would appreciate
knowing about it