
编一个VB程序,运行时显示任务栏,关闭时隐藏任务栏
展开全部
'主要不知道你是修改任务栏还是程序本身在任务的显示
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询