Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect MFC messages to another object?

Tags:

message

mfc

cwnd

In an instance of a class derived from CWnd, is it possible to forward (redirect) all MFC messages to another object, without writing separate handlers and message mappings for each possible message? Specifically, I'd like to forward all unhandled WM_ messages to another object. If this isn't possible, then is it possible for objects to listen to events that occur within other objects? I can provide details if that would help clarify my question.

Thanks.

like image 837
Geoff Avatar asked Sep 07 '25 01:09

Geoff


1 Answers

You'll need to aim a little lower than MFC. You should override the PreTranslateMessage method of your window and process the messages directly.

Once you have the main message loop, you can pick and choose which ones are handled by your app and which ones are Sent/Posted to another. If you choose to send the message, I'd recommend SendMessageTimeout(...)

like image 112
Brad Bruce Avatar answered Sep 10 '25 02:09

Brad Bruce