Nop! Not WM_LBUTTONUP nor WM_NCLBUTTONUP fire! I tested it in Spy++, it showes that the WM_LBUTTONUP fires but the application does not receive it, and even if it receives, there is no way to check if the mouse is on exactly on the minimize button! And there is something else, although the Spy++ reports that the WM_LBUTTONUP fires, the MSDN tells that, the WM_LBUTTONUP message would be sent to the window, just when the mouse is on the ClientArea of the window. Anyway, I changed my code to this:
private const int WM_NCLBUTTONDOWN = 0xA1;
private const int WM_NCLBUTTONUP = 0xA2;
bool filterOff = true;
Message message = new Message();
bool internalMessage = false;
\[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")\]
protected override void WndProc(ref Message m)
{
if (m.Msg == WM\_NCLBUTTONDOWN && m.WParam == (IntPtr)0x8)
{
if (internalMessage)
{
internalMessage = false;
}
else
{
message = m;
if (filterOff)
{
Message mes = new Message();
mes.HWnd = this.Handle;
mes.Msg = 162;
mes.WParam = m.WParam;
mes.LParam = IntPtr.Zero;
this.WndProc(ref mes);
}
return;
}
}
else if (m.Msg == WM\_NCLBUTTONUP && m.WParam == (IntPtr)0x8)
{
internalMessage = true;
this.WndProc(ref message);
return;
}
base.WndProc(ref m);
}
private void Form\_KeyUp(object sender, KeyEventArgs e)
{
if(e.KeyCode.ToString() == "Escape")
{
if (!filterOff) { filterOff = true; }
else
{
filterOff = false;
}
}
}
and when I recieve the WM_NCLBUTTONUP, I send a WM_NCLBUTTONDOWN message to the window, myself, but I don't like it! There have to be someway to make the WM_NCLBUTTONDOWN be sent to the window!:doh: It is driving me crazy! I have to solve this!:confused:
Sojaner!