Odd click event behavior

  • Thread starter Thread starter PureCode
  • Start date Start date
P

PureCode

Hi,

I have a UserControl that derives from my own base control (for drawing
purposes). I add a number of controls (label, panel) to this UserControl
using code (this.Controls.Add).

When i try to detect a click on the entire control, it only works when the
mouse is outside of the child controls i added.

this.Click += ..etc and i only get a response from the eventhandler when i
click outside the label and panel (can't detect clicks on the panel either,
due to the fact there is an image drawn over it (transparent image)..
driving me up the walls :) )

Any way to solve this problem?

Thanks,

Pure
 
Hi,

WindowsForms doesn provide any hooks to preview mouse messages or events
send to the child controls. There are method for previewinf only keyboard
input.

There are two solutions that I can see:
1. Hook mouse events of all child contntrols. This might be feasible
solution only for simple and flat control structure.

2. Second solution is to filter out mouse events as they are fetched from
the thread message queue. The following is a example of how to implement
this that I've posted some time ago
http://groups.google.ca/group/micro...Filter+Stoitcho&rnum=3&hl=en#606da6abeae4716a
 
Back
Top