1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function GetWindow( _
ByVal hWnd As IntPtr, _
ByVal uCmd As UInteger) As IntPtr
End Function
Private Enum GetWindowCmd As UInteger
GW_CHILD = 5
End Enum
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindow( _
ByVal hwnd As IntPtr, _
ByVal nCmdShow As Int32) As Boolean
End Function
Private Enum SW As Int32
Hide = 0
ShowNoActivate = 4
Max = 11
End Enum
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function IsWindowVisible(ByVal hwnd As IntPtr) As Boolean
End Function
Private Sub Toggle()
Dim hWnd As IntPtr = FindWindow("ProgMan", Nothing)
hWnd = GetWindow(hWnd, GetWindowCmd.GW_CHILD)
If IsWindowVisible(hWnd) Then
ShowWindow(hWnd, SW.Hide)
Else
ShowWindow(hWnd, SW.ShowNoActivate)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Toggle()
End Sub
End Class |
Partager