Valhalla Legends Forums Archive | Visual Basic Programming | Hiding from Taskbar

AuthorMessageTime
Mr. Neo
I'm trying to make a window that globally floats above everything else, and then also doesn't show up in the taskbar.  I've gotten the globally floating part down by using the SetWindowPos() API which works out nicely.  Now, I'm just a bit stuck on how to get rid of the program from the taskbar.  I found some Delphi sites using the ShowWindow() API, but when I use this in my application it hides the entire taskbar while the application has focus.  Even when the application doesn't have focus, the taskbar appears with the application there and all.

Any ideas?
January 3, 2005, 3:31 AM
Newby
Let Windows Explorer crash, and when it restarts your application won't be there until you click on it! :p

How about Form.ShowInTaskbar?
January 3, 2005, 3:39 AM
Stealth
ShowInTaskbar is read-only at runtime, however, a Google search for "ShowInTaskbar" yielded this link as the first result. Looks good.
January 3, 2005, 5:28 AM
Newby
He could change the state in the Properties window, which is what I was aiming for.
January 3, 2005, 5:46 AM
Mr. Neo
[quote author=Stealth link=topic=10094.msg94183#msg94183 date=1104730080]
ShowInTaskbar is read-only at runtime, however, a Google search for "ShowInTaskbar" yielded this link as the first result. Looks good.
[/quote]

Thank you Stealth, this is exactly what I was looking for.  Works like a charm.
January 3, 2005, 12:57 PM
KkBlazekK
Wouldn't Me.Hide and Me.Visible do the exact same thing? It seems to work for my applications.
January 3, 2005, 9:25 PM
Stealth
[quote author=Blaze link=topic=10094.msg94203#msg94203 date=1104787526]
Wouldn't Me.Hide and Me.Visible do the exact same thing? It seems to work for my applications.
[/quote]

Those two will disappear the form as well.
January 3, 2005, 10:24 PM
Mr. Neo
That link that Stealth provided worked perfectly in Visual Basic.  But, it didn't work at all in REALbasic.  A quick search and a bit of modification yielded this working code.
[code]
Sub ShowInTaskbar(Visible As Boolean, hwnd As Integer)
  Declare Function ShowWindow Lib "user32" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
  Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (hwnd As Integer, nIndex As Integer) As Integer
  Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (hwnd As Integer, nIndex As Integer, dwNewLong As Integer) As Integer
 
  Dim SW_HIDE As Integer
  Dim SW_SHOW As Integer
  Dim GWL_EXSTYLE As Integer
  Dim WS_EX_TOOLWINDOW As Integer
  Dim L As Integer
 
  SW_HIDE = 0
  SW_SHOW = 5
  GWL_EXSTYLE = -20
  WS_EX_TOOLWINDOW = &H80
  L = ShowWindow(hwnd, SW_HIDE)
  If Visible = False Then
    L = SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
  Else
    L = SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
  End If
  L = ShowWindow(hwnd, SW_SHOW)
End Sub[/code]
January 4, 2005, 1:11 PM

Search