|
-
Aug 25th, 2005, 08:26 PM
#1
Set/Get the ShowInTaskbar property for a window at runtime
VB Code:
'You need 2 command buttons 'cmdToggle' and 'cmdCheck'
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 GWL_EXSTYLE = (-20)
Private Const WS_EX_APPWINDOW = &H40000
Const SW_HIDE = 0
Const SW_NORMAL = 1
Private Sub ShowInTheTaskbar(hwnd As Long, bShow As Boolean)
Dim lStyle As Long
ShowWindow hwnd, SW_HIDE
lStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
If bShow = False Then
If lStyle And WS_EX_APPWINDOW Then
lStyle = lStyle - WS_EX_APPWINDOW
End If
Else
lStyle = lStyle Or WS_EX_APPWINDOW
End If
SetWindowLong hwnd, GWL_EXSTYLE, lStyle
App.TaskVisible = bShow
ShowWindow hwnd, SW_NORMAL
End Sub
Private Function IsVisibleInTheTaskbar(hwnd As Long) As Boolean
Dim lStyle As Long
lStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
If lStyle And WS_EX_APPWINDOW Then
IsVisibleInTheTaskbar = True
End If
End Function
Private Sub cmdToggle_Click()
Static bVisible As Boolean
bVisible = Not IsVisibleInTheTaskbar(Me.hwnd)
ShowInTheTaskbar Me.hwnd, bVisible
End Sub
Private Sub Form_Load()
cmdToggle.Caption = "Toggle visibility"
cmdCheck.Caption = "Check visibility"
End Sub
Last edited by manavo11; Aug 25th, 2005 at 08:49 PM.
Has someone helped you? Then you can Rate their helpful post. 
-
Aug 25th, 2005, 08:36 PM
#2
Re: Set/Get the ShowInTaskbar property for a window
nice code
-
Aug 25th, 2005, 08:40 PM
#3
-
Aug 28th, 2005, 02:23 AM
#4
Re: Set/Get the ShowInTaskbar property for a window at runtime
Is (lStyle-WS_EX_APPWINDOW) the same as (lStyle And Not WS_EX_APPWINDOW) ?
And, doesn't WS_EX_APPWINDOW also have something to do with the form borderstyle?
-
Aug 28th, 2005, 08:01 AM
#5
-
Aug 30th, 2005, 01:02 PM
#6
Re: Set/Get the ShowInTaskbar property for a window at runtime
Great code manavo. I just needed something like this. I'm glad I checked the codebank. 
BTW - In you example cmdCheck does nothing. Just thought I'd let you know.
-
Aug 30th, 2005, 07:46 PM
#7
-
Aug 31st, 2005, 10:07 PM
#8
Re: Set/Get the ShowInTaskbar property for a window at runtime
Nice code Philip! 
WS_EX_???????? = Extended Window Style Or Window Style Extended
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|