VB6中任务栏的隐藏

VB6 | 2018-08-30 20:34:15 | 阅读 130 次 | 评论(0)

VB6.0需要使用Windows Api函数实现隐藏和显示任务栏。

  1. FindWindow函数检索句柄到顶层窗口的类名和窗口名称匹配指定的字符串。此功能不搜索子窗口。该功能不执行区分大小写的搜索。

  2. IsWindowVisible函数检索指定窗口的可见性状态。

  3. ShowWindow函数设置指定窗口的显示状态。


  4. Option Explicit
        Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        Private Declare Function IsWindowVisible 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 Sub Command1_Click()
        Dim hwnd As Long
        hwnd = FindWindow("Shell_TrayWnd", "") '取任务栏窗口句柄
        If IsWindowVisible(hwnd) <> 0 Then     '如果任务栏是可视状态
            ShowWindow hwnd, 0                     '隐藏任务栏
        Else                                   
            ShowWindow hwnd, 1                     '显示任务栏
        End If
    End Sub


  5. 测试成功适配Win XP Win7 Win8 Win10

文章评论,共0条
游客请输入验证码
浏览323次
最新评论