views:

341

answers:

1

Hello!

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!

+1  A: 

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.

Quibblesome
I_ don't understand you. I need MouseUp and MouseDown defined on Control1.
VansFannel
When you click a link then you get a mouse down, then a mouse up.The problem is that mouse down happens on control 2 (the click on the link). Control 2 THEN disappears and hands control BACK to control 1. Then mouse up event then occurs. This now falls through to control number 1. The way to avoid this is to make all "action/commit" events happen on either mouse up or mouse down. I prefer mouse up myself. Try re-writing the link to use MouseUp instead. You may have to write your own link control to do this, so try just using a button first and handle MouseUP (not click).
Quibblesome
Ok, I've done and it works! Thank you.
VansFannel