Option Explicit
Private Declare Function SetFocusA Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As LongPrivate Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Const WS_EX_MDICHILD As Long = &H40&
Private Const GWL_STYLE = (-16)Private Const GWL_EXSTYLE As Long = (-20)Private Const WS_CHILD = &H40000000Private Const WS_CHILDWINDOW = (WS_CHILD)Dim lngCalculator As Long'把计算器作为子窗体Private Sub Form_Load()Dim lngStyle As Long
Dim lngExStyle As LongShell "calc.exe", vbNormalFocuslngCalculator = FindWindow(vbNullString, "计算器") If lngCalculator > 0 Then SetParent lngCalculator, Me.hwnd SetWindowLong lngCalculator, GWL_EXSTYLE, WS_EX_MDICHILD End IfEnd Sub