Results 1 to 3 of 3

Thread: Replacement for MESSAGE_MAP()

  1. #1
    Join Date
    Nov 2007
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Replacement for MESSAGE_MAP()

    What is the for below MFC Macros?

    DECLARE_MESSAGE_MAP()


    BEGIN_MESSAGE_MAP()
    .....
    END_MESSAGE_MAP()

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Replacement for 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

  3. The following user says thank you to jpn for this useful post:

    krishbhala (5th December 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Earth (Terra)
    Posts
    87
    Thanks
    4
    Thanked 6 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Replacement for MESSAGE_MAP()

    Quote Originally Posted by krishbhala View Post
    What is the for below MFC Macros?

    DECLARE_MESSAGE_MAP()


    BEGIN_MESSAGE_MAP()
    .....
    END_MESSAGE_MAP()
    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

  5. The following user says thank you to rickbsgu for this useful post:

    krishbhala (5th December 2007)

Similar Threads

  1. Console replacement
    By aegis in forum Qt Programming
    Replies: 14
    Last Post: 3rd April 2007, 00:38
  2. Replies: 2
    Last Post: 28th March 2007, 10:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.