2010-11-08 自由控制顯不顯示ShowInTaskbar (VB) 37132 0 VB 自由控制顯不顯示ShowInTaskbar (VB) '以下加入form1 Private Sub Command1_Click() Call setShowInTaskbar(True, Me.hwnd) '顯示 End Sub Private Sub Command2_Click() Call setShowInTaskbar(False, Me.hwnd) '隱藏 End Sub Private Sub Form_Load() M_Num = GetWindowLong(Me.hwnd, GWL_EXSTYLE) End Sub '以下加入moudle1 Option Explicit Public Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Public Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Public Declare Function ShowWindow Lib "user32" (ByVal hwnd _ As Long, ByVal nCmdShow As Long) As Long Public Const SW_HIDE = 0 Public Const SW_SHOW = 5 Public Const GWL_EXSTYLE = -20 Public Const WS_EX_TOOLWINDOW = 1 Public M_Num As Long Public Sub setShowInTaskbar(Visible As Boolean, hwnd As Long) Dim L As Long L = ShowWindow(hwnd, SW_HIDE) DoEvents L = SetWindowLong(hwnd, GWL_EXSTYLE, IIf(Visible, M_Num, 1)) DoEvents L = ShowWindow(hwnd, SW_SHOW) End Sub 如有錯誤 歡迎指正 回首頁