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?
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?
for GUI with C++ look into Qt, if you don't want to spend a bunch of money on microsoft's proprietary crap.
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.
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.