To work around this problem, use the following code to simulate a button click on the container:
NOTE: This solution has only been verified to work with Internet Explorer and Visual Basic 6.0.
Option Explicit
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As _
Any) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Dim f As Boolean
Private Sub UserControl_EnterFocus()
Dim h As Long
Dim i As Long
Dim hLast As Long
If f = False Then
h = UserControl.ContainerHwnd ' Does not work with Visual Basic 5.0.
Call PostMessage(h, WM_LBUTTONDOWN, 0, ByVal 0)
Call PostMessage(h, WM_LBUTTONUP, 0, ByVal 0)
f = True
End If
End Sub
Private Sub UserControl_Show()
UserControl.Text1.SetFocus
End Sub
NOTE: This workaround calls a Windows32 Application Programming Interface (API) in a Visual Basic application. If you use this API incorrectly, the application may stop responding (crash). Please make sure you save your project before you run and test your programs.