J
johnf
Trying to get a see windows messages using IMessageFilter interface however
it does not seem to get all window messages. Specifically I am looking for
the WM_POWERBROADCAST. I override wndproc which shows the msg successfully
but nothing shows up when using IMessageFilter. Am i misunderstanding
something? Here is sample code:
public class MyFilter : IMessageFilter
{
const int WM_POWERBROADCAST = 0x0218;
public bool PreFilterMessage(ref Message m)
{
if m.Msg == WM_POWERBROADCAST)
{
Console.WriteLine("Power Broadcast recieved.");
}
return false;
}
}
class MainForm : Form
{
public MainForm() //MainForm's constructor
{
}
public static void Main()
{
Application.AddMessageFilter(new MyFilter());
Application.Run(new MainForm());
}
}
it does not seem to get all window messages. Specifically I am looking for
the WM_POWERBROADCAST. I override wndproc which shows the msg successfully
but nothing shows up when using IMessageFilter. Am i misunderstanding
something? Here is sample code:
public class MyFilter : IMessageFilter
{
const int WM_POWERBROADCAST = 0x0218;
public bool PreFilterMessage(ref Message m)
{
if m.Msg == WM_POWERBROADCAST)
{
Console.WriteLine("Power Broadcast recieved.");
}
return false;
}
}
class MainForm : Form
{
public MainForm() //MainForm's constructor
{
}
public static void Main()
{
Application.AddMessageFilter(new MyFilter());
Application.Run(new MainForm());
}
}