开发者

How do i call a MouseDoubleClick event? WinForm

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 sin开发者_StackOverflow社区ce 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


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)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜