PDA

View Full Version : Implementing WndProc Override



bbdaffy
12th March 2010, 11:06
Hi,

I am using QT 4.5. Currently I need to implement a sort of keyboard/mouse hook in my QT application. Essentially my application needs to listen for certain hotkeys even when it is not in focus. I read somewhere about RegisterRawInputDevices to allow my application to receive raw input from these devices, but in turn I need to override the WndProc method. Is there a way to do so in a QT application, or is there an equivalent way to implement the same feature using QT's API? Would be grateful for any advice. Thanks in advance.

high_flyer
12th March 2010, 13:49
Its hard to tell exactly what you need based on what you wrote, and probably there are several ways to go about it.
But you might want to check the following:
bool QWidget::winEvent ( MSG * message, long * result )
bool QCoreApplication::winEventFilter ( MSG * msg, long * result )

squidge
12th March 2010, 20:37
RegisterRawInputDevices() seems a little overkill for handling a system-wide hotkey when a much more appropriate function called RegisterHotKey() exists. The later will also take a window handle as an argument and send that window a WM_HOTKEY message, which is much easier to process than overriding WndProc.