tags:

views:

52

answers:

2

In my MouseDoubleClick i may run into a case where i would like to call all the controls in a list with MouseDoubleClick. However i cant call MouseDoubleClick, only add/remove events to the chain.

How do i call MouseDoubleClick/OnMouseDoubleClick?

ATM i workaround the problem since i know the objects MouseDoubleClick function and i pass in the parameters myself calling that specific function. How do i call the event in the case i do not know what function is set to the control MouseDoubleClick

A: 

There are a number of ways you can do this:

  • As you are doing, hard-code the calls directly. Not a very flexible approach.

  • Add your own internal method to call in the controls (e.g implement a special Interface), or an event that you raise to which all the other interested controls subscribe. This only works if you have the source code for all the controls, or make derived UserControls of your own, which could be a lot of work.

  • Post a WM_LBUTTONDBLCLICK message to the underlying window for every control in your list. This should work for any kind of control as long as they don't do anything too naughty in their handlers. Note that you may need to work out fake x,y coordinates within each control to trick it into thinking that the double click was inside its own bounds - double clicks outside control bounds could cause undefined behaviours. And of course, the location of the click within the control can be important (e.g. you can double click on individual items displayed within a list box control)

Jason Williams
A: 

i workaround the problem since i know the objects MouseDoubleClick function and i pass in the parameters myself calling that specific function. How do i call the event in the case i do not know what function is set to the control MouseDoubleClick

acidzombie24