How can I trap onclick for all areas on a window?

K

Ken Varn

I have a Windows Form that contains various controls. I want to trap the
onclick event for the entire surface of the main Form including the areas
obstructed by the controls. The problem that I am facing is when I put an
onclick event handler on the main Form, it does not work when clicking on
controls within the Form. I want to trap all onclicks even if they click on
a control. Could someone tell me if there is an easier way than putting an
onclick event handler on every single control in the Form?

--
---------------------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
MailID = varnk
Domain = diebold.com
---------------------------------------------
 
J

Jack Jackson

I have a Windows Form that contains various controls. I want to trap the
onclick event for the entire surface of the main Form including the areas
obstructed by the controls. The problem that I am facing is when I put an
onclick event handler on the main Form, it does not work when clicking on
controls within the Form. I want to trap all onclicks even if they click on
a control. Could someone tell me if there is an easier way than putting an
onclick event handler on every single control in the Form?

No. You can set up the handler with a loop with something like:

For Each ctl As System.Windows.Forms.Control In Me.Controls
AddHandler ctl.Click, Addressof FormClickHandler
Next
 

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