Hi Igor, Thank you very much. The thing that I don't understand is that how folks such as those from SmartWin++ are able to seemlessly connect functions with Windows messages without using a case statement in a message loop. An example is at the following page: http://smartwin.sourceforge.net/getting_started.php Using your approach, I need to use a case statement inside a message loop. That's what I don't want to do. I am familiar with CRTP that SmartWin++ folks seem to have used as deriving new classes is very easy and the resulting code is very clean. So, I can at least imagine the design behind this library. But I wonder if they have written such case statements in message loops under the hood for every single GUI element. Someone on Boost Users mailing list did provide a solution to this a few months back (I do recall but cannot seem to find that post - I starred it in my thunderbird inbox but I have lost my inbox backup - I can scan the whole boost users list but I have limited time available to accomplish what I want). Best regards, Asif On Thu, Mar 24, 2011 at 4:02 PM, Igor R <boost.lists@gmail.com> wrote:
Yes, exactly. Windows messages (I want to avoid having to write long case statements in message loops) - that's what I mean. I'd be thankful if anyone could point me to the right direction.
// pseudo-code!
// Lets say it's a botton; switch(message) { case WM_LBUTTONDBLCLK: onDoubleClick(message); break; //... };
// member function void onDoubleClick(Message message) { doSomething(message); onDoubleClick_(arg1, arg2); }
// member boost::signals2::signal<void(Arg1, Arg2)> onDoubleClick_;
Now multiple listeners of your button can connect the signal:
struct Handler { void onDoubleClick(Arg1 a1, Arg2 a2); }; button->onDoubleClick.connect(boost::bind(&Handler::onDoubleClick, handler, _1, _2));
This's only a sketch, in real code hou have to care about proper encapsulation, appropriate arguments etc. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users