我创建了一个在后台运行到另一个程序的 VB6 程序。这意味着程序窗口将只在这个其他程序的后面。我正在使用此代码,
Private Declare Function FindWindow1 Lib "User32" Alias "FindWindowA" (ByVal lpclassname As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_HWNDPARENT = -8
Private parenthwnd As Long
Private strTitle As String
Private Sub Form_Load()
strTitle = "My Program" 'Title of the program window
parenthwnd = FindWindow1(vbNullString, strTitle)
Dim R As Long
R = SetWindowLong(parenthwnd, GWL_HWNDPARENT, Me.hWnd)
End Sub
另一个程序将运行这个 VB6 程序,它将自身设置为另一个程序窗口的背景。有用。但是有两个问题。
- 当 VB6 程序执行代码
R = SetWindowLong(parenthwnd, GWL_HWNDPARENT, Me.hWnd)
时,其他程序和 VB6 程序一起进入后台。VB6程序运行时如何激活其他程序? - 当另一个程序关闭时,它有终止VB6程序的代码。但这不会关闭 VB6 程序。我认为这可能是由于运行代码
R = SetWindowLong(parenthwnd, GWL_HWNDPARENT, Me.hWnd)
。如何解决这个问题?