Is there a way, when creating a WinForms Custom Control/User Control, to get a reference at runtime to the form the control is placed on, so as to access various properties of that form? I would rather not pass a reference to the form into the constructor of the control, as, for various reasons, I need to keep a default constructor with no parameters.
One example: I have several Custom Controls that encapsulate Win32 API calls, and some of the calls require Window handles to be passed as parameters. I would like to be able to retrieve the handle of the containing form so I can pass it to the API function.
Another example: I have a Custom Control that provides "toast"-style user notifications. I would like to have the option of opening the notification form in a location relative to the location of the main application form, such as centered on the main window, off to the right, etc. This is not possible, obviously, without knowing the coordinates of the main application's window.
I could resort to using FindWindowEx()-type API calls in some cases, but that feels like a kludge, and would not work in all cases.
Does anyone know if this is possible?