Thread: event handler like MFC one?

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    7

    event handler like MFC one?

    hi all. i'm newbie in C++. i wanna make event handler for my simple windows program. So, how i can use event handler like MFC one? is
    still through WndProc or not?

    Thanks before?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    for GUI with C++ look into Qt, if you don't want to spend a bunch of money on microsoft's proprietary crap.

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    7
    thanks for your answer. i like Qt, but i wanna develop my own event handler. so, i put MFC's message maps for example, but i confused with it's coding. i was googling, but i need more references. so do yall have one?

    best regards.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you dig into MFC's event handler code (and I have) you will find they have macros that add code and data members to your class at compile time. When you use DECLARE_MESSAGE_MAP it adds a member to the class and when you DEFINE_MESSAGE_MAP it adds data to said member. Each macro then in the message map definition also adds data in one way or another to the data structure that DEFINE_MESSAGE_MAP created. They differentiate the methods via some very nifty and tricky union structure coupled with a hash on the message being handled so the right method is called.

    I duplicated this in my own system and it worked well but I found it too clunky. Eventually I went with a solution that made heavy use of the observer / listener pattern. In the end the pattern worked much the same as the MFC version but it was cleaner, easier to code, and much easier to maintain and debug.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Control Event Handler
    By carrotcake1029 in forum C# Programming
    Replies: 4
    Last Post: 06-23-2011, 09:29 PM
  2. event handler
    By hkl01 in forum C# Programming
    Replies: 1
    Last Post: 06-10-2006, 08:07 PM
  3. Finding controls from an event handler
    By bennyandthejets in forum C# Programming
    Replies: 2
    Last Post: 07-03-2005, 04:17 AM
  4. event handler for an array of buttons
    By GanglyLamb in forum C# Programming
    Replies: 4
    Last Post: 04-12-2005, 09:52 AM
  5. confused with args for event handler~
    By black in forum C# Programming
    Replies: 3
    Last Post: 03-03-2004, 03:25 AM