Receiving WM_HOTKEY messages

  • Thread starter Thread starter Robert Misiak
  • Start date Start date
R

Robert Misiak

I have an application which runs in the background and displays a
NotifyIcon - Form's are opened depending on user input, but the main class
is not a Form. I use RegisterHotKey() to catch Alt+F11, but since I've
started doing this I've had to inherit my main class from
System.Windows.Forms.Control, so I could override WndProc to check for
WM_HOTKEY. While this works, I'm convinced that there must be a better way
to do this. Does anyone know of a better way?

Thanks,
Robert
 
You might be better off using an application message filter. Check out
Application.AddMessageFilter

--
Bob Powell [MVP]
Visual C#, System.Drawing

The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
 
I haven't tried Bob's suggestion, but if you want to override WndProc you
can do so in your Form class. There's no need to inherit directly from
System.Windows.Forms.Control.

- Magnus
 
Back
Top