Click to See Complete Forum and Search --> : how to alert windows form control's parent of click event


sambo
December 18th, 2005, 01:32 AM
I created a Windows Forms Control using Managed C++. I then imported into a C# application and placed it onto a form. I added an OnClick event to the C# (parent control) to try to simply handle the click event. But it doesn't seem to be calling OnClick when I click on the UserControl. Do I have to do some funny magic with the Windows Forms Control to make it alert its parent that it has been clicked?

Using MSVS 2005. Still trying to figure out how to create and handle events and messages. Do windows forms even have windows messages? Can I handle the WM_COPYDATA message with a windows forms app?

NoHero
December 18th, 2005, 06:17 AM
Using MSVS 2005. Still trying to figure out how to create and handle events and messages. Do windows forms even have windows messages? Can I handle the WM_COPYDATA message with a windows forms app?

If your form does not have an appropiate handler: Yes. You must overload the protected WndProc method, and then do the processing on your own. Don't forget the base method to avoid problems...

sambo
December 19th, 2005, 12:18 AM
Ok. So how do I properly tell the parent form that my usercontrol has received a click?

NoHero
December 19th, 2005, 04:34 AM
Well, if you click inside a edit control of your user control for example, your user control receives the click inside the edit control. If you want to tell the parent you have to fire the event on your own, AFAIK.

sambo
December 19th, 2005, 11:28 AM
you have to fire the event on your own
Yes, we have established that. :)

Can you please explain how I fire the event. Thanks.

I'm just coming over from c++, so all this .net code is still very foreign to me.

NoHero
December 19th, 2005, 01:47 PM
By calling the proper __event member as it where a function AFAIK