Consider overriding WinForms' CreateHandle/DestroyHandle
The WinForms control currently makes use of ISupportInitialize
to attach the media player's HWND, but there are a few drawbacks:
- An empty BeginInit() method, just because it's an interface implementation
- Doesn't call Detach() when the control is destroyed
I've just came through these methods, and I'm wondering if that could help us:
- https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.createhandle?view=windowsdesktop-6.0
- https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.destroyhandle?view=windowsdesktop-6.0
The suggested change could look like this:
protected override void CreateHandle()
{
base.CreateHandle();
Attach();
}
protected override void DestroyHandle()
{
Detach();
base.DestroyHandle();
}
What do you think ?