Option ExplicitPrivate Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _ (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _ ByVal lpsz2 As String) As LongPrivate Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_SETHOTKEY = &H32Const HOTKEYF_SHIFT = &H1Const HOTKEYF_CONTROL = &H2Const HOTKEYF_ALT = &H4
'定义窗口以及子窗口的类名Const sTrayWindow = "Shell_TrayWnd"Const sTrayNotify = "TrayNotifyWnd"Const sStartButton = "Button"Const sAppSwitchBar = "ReBarWindow32"Const sAppSwitch = "MSTaskSwWClass"Const sAppIcon = "ToolbarWindow32"Const sTrayClock = "TrayClockWClass"Const sDesktopIcon = "ShellDll_DefView"Const sProgman = "Progman"
Const SW_SHOW = 5Const SW_HIDE = 0
Dim wnd As Long
Private Sub chkWnd_Click(Index As Integer) Dim i As Integer '获得任务栏的窗口句柄 wnd = FindWindow(sTrayWindow, vbNullString) Select Case Index Case 0 Case 1 '根据任务栏窗口句柄获得子窗口的句柄 wnd = FindWindowEx(wnd, 0, sStartButton, vbNullString) Case 2 wnd = FindWindowEx(wnd, 0, sTrayNotify, vbNullString) Case 3 wnd = FindWindowEx(wnd, 0, sAppSwitchBar, vbNullString) wnd = FindWindowEx(wnd, 0, sAppSwitch, vbNullString) Case 4 wnd = FindWindowEx(wnd, 0, sTrayNotify, vbNullString) wnd = FindWindowEx(wnd, 0, sTrayClock, vbNullString) Case 5 '获取桌面的窗口句柄 wnd = FindWindow(sProgman, vbNullString) wnd = FindWindowEx(wnd, 0, sDesktopIcon, vbNullString) Case 6 wnd = FindWindowEx(wnd, 0, sAppSwitchBar, vbNullString) wnd = FindWindowEx(wnd, 0, sAppIcon, vbNullString) Case Else wnd = 0 End Select If chkWnd(Index).Value = 1 Then ShowWindow wnd, SW_HIDE Else ShowWindow wnd, SW_SHOW End IfEnd Sub
Private Sub Command1_Click() Dim i As Integer '清除所有的选项并恢复所有窗口 For i = 0 To 6 chkWnd(i).Value = 0 chkWnd_Click (i) Next iEnd Sub
Private Sub Command2_Click()Form1.WindowState = 1End Sub
Private Sub Form_Load()Dim l As Long Dim wHotkey As Long '设置热键为Ctrl+Alt+A wHotkey = (HOTKEYF_ALT Or HOTKEYF_CONTROL) * 256 + vbKeyA l = SendMessage(Me.hwnd, WM_SETHOTKEY, wHotkey, 0)
chkWnd(0).Caption = "隐藏任务栏" chkWnd(1).Caption = "隐藏开始按钮" chkWnd(2).Caption = "隐藏任务栏图标" chkWnd(3).Caption = "隐藏程序按钮" chkWnd(4).Caption = "隐藏任务栏时钟" chkWnd(5).Caption = "隐藏桌面图标" chkWnd(6).Caption = "隐藏快速运行图标" Command1.Caption = "恢复所有窗口" Command2.Caption = "确定"End Sub
Private Sub Form_Unload(Cancel As Integer) Command1_ClickEnd Sub
Private Sub Label2_Click()Const WEB = "mailto:wgscd@126.com" Dim perjump As Integer ' hyperjumphy perjump = ShellExecute(0&, vbNullString, WEB, vbNullString, vbNullString, vbNormalFocus)
End Sub