C# Programming
07-20-2009, 05:24 AM
Hey all,
I want to intercept windows message that is sent to my program when form is deactivated (or activated, no matter). I can intercept mouse clicks etc. using regular message filter, but I can't intercept WM_NCACTIVATE or WM_ACTIVATE messages, why is that?
I'm trying something like that:
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class MessageFilter : IMessageFilter
{
private const int WM_ACTIVATE = 0x006;
private const int WM_NCACTIVATE = 0x086;
public bool PreFilterMessage(ref Message m)
{
if(m.Msg == WM_NCACTIVATE)
return true;
return false;
}
}
and then in Main:
MessageFilter mf = new MessageFilter();
Application.AddMessageFilter(mf);
I can see using debugger that it doesn't react on activation and deactivation of my form. How to do it correclty?
I want to intercept windows message that is sent to my program when form is deactivated (or activated, no matter). I can intercept mouse clicks etc. using regular message filter, but I can't intercept WM_NCACTIVATE or WM_ACTIVATE messages, why is that?
I'm trying something like that:
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class MessageFilter : IMessageFilter
{
private const int WM_ACTIVATE = 0x006;
private const int WM_NCACTIVATE = 0x086;
public bool PreFilterMessage(ref Message m)
{
if(m.Msg == WM_NCACTIVATE)
return true;
return false;
}
}
and then in Main:
MessageFilter mf = new MessageFilter();
Application.AddMessageFilter(mf);
I can see using debugger that it doesn't react on activation and deactivation of my form. How to do it correclty?