Strange interaction between Visual Basic controls and .NET controls

95 Views Asked by At

I have a VB6 form like this:

enter image description here

The form is composed of a classic ActiveX CommandButton and a .NET UserControl (specifically, a WinForm) containing 2 WinForm Buttons. The UserControl is, of course, COM visible and inserted in VB6 using the VBControlExtender in the following way:

Option Explicit
Dim WinFormButtons  As VBControlExtender

Private Sub Form_Load()

    Set WinFormButtons = Controls.Add("DemoInteropNet.UserControlTest", "WinFormButtons", Picture1)
    WinFormButtons.Visible = True
    WinFormButtons.Height = Picture1.Height
    WinFormButtons.Width = Picture1.Width
End Sub

Demo:

Demo

As you can see from the demo sample, the WinForm buttons work correctly until I interact with the VB6 button. From that moment on, they become completely blocked (as evidenced by the change in style), do not raise events, and do not do anything at all. The only way to "unblock" them is to double-click in the area where they are located.

Do you have any idea about the reason for this behavior?

Of course, I have already tried everything:

  • Focus

  • ZOrder

  • Refresh

  • Redraw

  • Various Events

  • Various Container methods

  • etc. etc.

0

There are 0 best solutions below