2024年3月21日发(作者:)

vb激活窗口

技术爱好 2008-04-08 15:36:04 阅读587 评论0 字号:大中小

Option Explicit

Const SW_MINIMIZE = 6

Const SW_SHOWNORMAL = 1

Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long,

ByVal nCmdShow As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"

(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Dim lngWindow As Long

Private Sub Form_Load()

If stance Then

lngWindow = FindWindow(vbNullString, "测试窗口")

If lngWindow <> 0 Then

If IsIconic(lngWindow) = 0 Then

ShowWindow lngWindow, SW_MINIMIZE

Else

ShowWindow lngWindow, SW_SHOWNORMAL

End If

End If

End

End If

n = "测试窗口"

End Sub

Private Function GetOtherWindowState(ByVal lngHWND As Long) As String

GetOtherWindowState = "普通"

If IsWindow(lngHWND) <> 0 Then

GetOtherWindowState = "没有找到该窗体"

ElseIf IsIconic(lngHWND) <> 0 Then

GetOtherWindowState = "窗体最小化"

ElseIf IsZoomed(lngHWND) <> 0 Then

GetOtherWindowState = "窗体最大化"

End If

End Function

判断别人的窗口的状态 并且在重新运行的时候可以来回切换!