感谢您使用微软产品。您可以根据原来程序窗口的Caption获得原来窗口的句柄,显示该窗口,如果你希望被调用程序的子窗口保持输入焦点,可以再把被调用程序的子窗口设为ForegroundWindow,获得输入焦点。涉及FindWindow,ShowWindow,SetForegroundWindow三个API函数。被调用程序的VB代码如下,假设原来程序窗口的Caption为“parent”: Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hwnd As Long) As LongPrivate Declare Function ShowWindow Lib "user32" _ (ByVal hwnd As Long, ByVal nCmdShow As Long) As LongPrivate Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Const SW_MAXIMIZE = 3Private Sub Form_Load() Dim hWindow As Long Dim lngResult As Long Dim lngReturnValue As Long hWindow = FindWindow(vbNullString, "parent") lngReturnValue = ShowWindow(hWindow, SW_MAXIMIZE) lngReturnValue = SetForegroundWindow(Form1.hwnd)
End Sub详细信息请参考以下链接: FindWindow http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/windows_03sn.asp ShowWindow http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/windows_2tdj.asp SetForegroundWindow http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/windows_1eev.asp- 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。======================
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As LongPrivate Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As LongPrivate Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Const SW_MAXIMIZE = 3Private Sub Form_Load() Dim hWindow As Long
Dim lngResult As Long
Dim lngReturnValue As Long hWindow = FindWindow(vbNullString, "parent")
lngReturnValue = ShowWindow(hWindow, SW_MAXIMIZE)
lngReturnValue = SetForegroundWindow(Form1.hwnd)
End Sub详细信息请参考以下链接:
FindWindow
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/windows_03sn.asp
ShowWindow
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/windows_2tdj.asp
SetForegroundWindow
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/windows_1eev.asp- 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。======================