简体   繁体   中英

.NET Compact Framework: Control over a Control OnMouseDown problem

I'm developing a WinForm Windows Mobile 5.0 or above with .Net Compact Framework 2.0 SP2 and C# .

I have two custom controls (two classes that inherits from Control). If I click over a specific location of control1 it shows control2 (control2 is a control of control1). In other words, control2 is a pop up menu that it shows over control1.

Control2 has two linklabel. If user clicks over one of them control2 throws an event to notify control1 about the user's selection.

On control1 I've overrided OnMouseDown, OnMouseUP and OnMouseMove.

Ok. I debugged the code in the case that the user clicks over a linklabel on control2. The event goes through:

  • On control2, linklabel_click method.
  • On control1, control2_customEvent method.
  • And, here is my problem , On control1, OnMouseMove method and the OnMouseUp.

If I click over control2 without clicking a linklabel it also throw control1.OnMouseMove and control1.OnMouseUp.

UPDATED:

Why is firing OnMouseMove and OnMouseUp on control1 if I clicking over control2 ?

Thanks!

It is correct. Mouse down on control 2. Control 2 disappears so the corresponding MouseUp gets called on the control that is now visible (Control1).

To avoid this make both work off either: MouseUp or MouseDown NOT a combination of the two.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM