当前在同一程序中复制并修改部分代码以创建一个按钮,单击该按钮会将Vision应用程序显示在GUI的前面。
Private Sub btVisionCam_Click()
If btVisionCam.Value = 1 Then
lVideo = FindWindow(vbNullString, "CEIVidCap")
If lVideo = 0 Then
lVideo = Shell("C:\machine\appls\CEIVidCap.exe", vbNormalFocus)
End If
End If
End Sub
单击该按钮时,不会将Vision应用程序带到GUI的前面。请帮忙,谢谢!
答案 0 :(得分:0)
创建一个模块并复制以下声明:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
然后,就像您已经在做的那样,在按钮中使用FindWindow
获取窗口句柄,并使用ShowWindow
将其调出:
Dim lnghWnd As Long
lnghWnd = FindWindow(vbNullString, "CEIVidCap")
ShowWindow lnghWnd, 1
nCmdShow
的{{1}}参数支持的值:
ShowWindow
答案 1 :(得分:0)
我当前的VB6代码:
Private Sub btVisionCam_Click()
Dim lnghWnd As Long
If btVisionCam.Value = 1 Then
lnghWnd = FindWindow(vbNullString, "CEIVidCap")
If lnghWnd = 0 Then
lnghWnd = Shell("C:\machine\appls\CEIVidCap.exe", vbNormalFocus)
ShowWindow lnghWnd, 1
End If
End If
End Sub
但是它仍然不能将“ CEIVidCap” Vision应用程序带到GUI的前端。.::(请帮助,谢谢!
答案 2 :(得分:0)
尝试将其设置为前景窗口。
将此添加到您的其他API调用中:
Declare Function Win32_SetForegroundWindow Lib "user32" _
Alias "SetForegroundWindow" ( _
ByVal hWnd As Long) _
As Long
然后添加:
Dim Ret As Long
Ret = Win32_SetForegroundWindow(lnghWnd)
If Ret Then
' Your window should be foreground
End If