Public Declare Function BringWindowToTop Lib "卖雹谈user32"中碰 Alias "BringWindowToTop" (ByVal hwnd As Long) As Long
新仔洞建工程,1个列表框信型list1和3个按钮.全部代码如下:
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Integer
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Const WS_MINIMIZE = &H20000000
Const HWND_TOP = 0
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_SHOWWINDOW = &H40
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Const GWL_STYLE = (-16)
Const SW_RESTORE = 9
Const WS_VISIBLE = &H10000000
Const WS_BORDER = &H800000
Private Sub Command1_Click()
findallapps
End Sub
Private Sub Command2_Click()
Dim hwnd As Long, x As Long, lngww As Long
If List1.ListIndex <0 Then
Beep
Exit Sub
End If
hwnd = List1.ItemData(List1.ListIndex)
lngww = GetWindowLong(hwnd, GWL_STYLE)
If lngww And WS_MINIMIZE Then
x = ShowWindow(hwnd, SW_RESTORE)
End If
x = SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW)
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Command1.Caption = "刷新"
Command2.Caption = "切换"
Command3.Caption = "退出"念坦枯
istask = WS_VISIBLE Or WS_BORDER
findallapps
End Sub
Sub findallapps()
Dim hwcurr As Long, intlen As Long, strtitle$
List1.Clear
hwcurr = GetWindow(Me.hwnd, GW_HWNDFIRST)
Do While hwcurr
If hwcurr <>Me.hwnd And taskwindow(hwcurr) Then
intlen = GetWindowTextLength(hwcurr) + 1
strtitle = Space$(intlen)
intlen = GetWindowText(hwcurr, strtitle, intlen)
If intlen >0 Then
List1.AddItem strtitle
List1.ItemData(List1.NewIndex) = hwcurr
End If
End If
hwcurr = GetWindow(hwcurr, GW_HWNDNEXT)
Loop
End Sub
Function taskwindow(hwcurr As Long) As Long
Dim lngstyle As Long
lngstyle = GetWindowLong(hwcurr, GWL_STYLE)
If (lngstyle And istask) = istask Then
taskwindow = True
End If
End Function
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)