编一个VB程序,运行时显示任务栏,关闭时隐藏任务栏

 我来答
捌零老陈
2010-10-26 · TA获得超过727个赞
知道大有可为答主
回答量:1414
采纳率:100%
帮助的人:806万
展开全部
'主要不知道你是修改任务栏还是程序本身在任务的显示

Option Explicit

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Private Const SW_SHOW = 5
Private Const SW_HIDE = 0
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_APPWINDOW = &H40000

Public Sub ShownInTaskBar(ByVal hWnd As Long, Optional bShow As Boolean = True)
Dim lExStyles As Long

lExStyles = GetWindowLong(hWnd, GWL_EXSTYLE)

If bShow Xor (lExStyles And WS_EX_APPWINDOW) = 0 Then Exit Sub

ShowWindow hWnd, SW_HIDE
SetWindowLong hWnd, GWL_EXSTYLE, lExStyles Xor WS_EX_APPWINDOW
ShowWindow hWnd, SW_SHOW
End Sub

' 在系统任务栏上显示
Private Sub Command1_Click()
ShownInTaskBar Me.hWnd, false '不显示在任务栏
cancel = 0 '不关闭
End Sub

' 从系统任务栏上隐藏
Private Sub Command2_Click()
ShownInTaskBar Me.hWnd, true '显示在任务栏
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式