Hi Andrew, Thank you for giving me a good example. Though I haven't yet bothered to look into the SmartWin++ source code but I suspect they have done something more smarter. Thank you all. -Asif On Thu, Mar 24, 2011 at 7:12 PM, Andrew Holden < aholden@charteroaksystems.com> wrote:
On Thursday, March 24, 2011 8:42 AM, Igor R wrote:
Using your approach, I need to use a case statement inside a message loop.
As you can see, struct Handler in my example doesn't have any case statements as well. Again: the basic, lowlevel message processing is hidden - in my example in the "button" class, in smart win++ somewhere in WidgetWindow or its base classes. The *users* of the framework do not need to deal with messages as the framework exposes higher-level facilities.
Perhaps you can replace the switch statement with a map or similar (warning: untested):
typedef std::map
MessageMap; MessageMap message_map; LRESULT CALLBACK WindowProc( __in HWND hwnd, __in UINT uMsg, __in WPARAM wParam, __in LPARAM lParam ) { MessageMap::const_iterator handler = message_map.find (uMsg); if (handler != message_map.end()) { return handler->second (hwnd, uMsg, wParam, lParam); } else { return DefWindowProc (hwnd, uMsg, wParam, lParam); } }
You could then insert any handler for any message into message_map. I'm not sure what combiner would be most appropriate here. There is also the question of where message_map should really go. A global variable (as my example implies) probably isn't the best place. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users