Odd click event behavior

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
 
S

Stoitcho Goutsev \(100\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top