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

  • Thread starter Thread starter Ken Varn
  • Start date Start date
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
---------------------------------------------
 
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
 
Back
Top