Skip to content

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:

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 ?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information