Boost logo

Boost Users :

Subject: Re: [Boost-users] Connecting Windows Messages/Events with Boost callbacks
From: Igor R (boost.lists_at_[hidden])
Date: 2011-03-24 07:02:34


> 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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net