What is the for below MFC Macros?
DECLARE_MESSAGE_MAP()
BEGIN_MESSAGE_MAP()
.....
END_MESSAGE_MAP()
What is the for below MFC Macros?
DECLARE_MESSAGE_MAP()
BEGIN_MESSAGE_MAP()
.....
END_MESSAGE_MAP()
Don't even consider porting your application line by line, macro by macro like that. Things just don't work that way. Think of what your MFC application does and then write the functionality with Qt. Corresponding functionality is done in Qt with signals and slots.
J-P Nurmi
krishbhala (5th December 2007)
These are the way MFC implements event handling routines. In the old Win32 API, you created a window class and then implemented a message handler for a window instance that intercepted all windows messages. It was up to you to break out the functionality you needed on a message-by-message basis (usually in a big switch statement), or pass the message on to the windows code.
MFC introduced the message map as a way to handle windows events (in c++) in a more discrete manner - one function per message. This is done in a mechanism (through the macros) that works remarkably like Qt's signal-slot mechanism - it's essentially a way of tying a callback to an instance of a class.
That said, it's very specific to Windows events - Qt's signal-slot is a more general mechanism that goes beyond any particular windowing system's events. Many window events in Qt - such as 'clicked' - are forwarded through signals. Other's aren't and you have to override the base class implementation to intercept them.
Interestingly enough, wxWidgets has somewhat resurrected the message-map idea, but they don't implement a signals-slots mechanism, at all.
Last edited by rickbsgu; 4th December 2007 at 16:23. Reason: spelling error
krishbhala (5th December 2007)
Bookmarks