Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Mr. Neo on January 02, 2005, 09:31 PM

Title: Hiding from Taskbar
Post by: Mr. Neo on January 02, 2005, 09:31 PM
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?
Title: Re: Hiding from Taskbar
Post by: Newby on January 02, 2005, 09:39 PM
Let Windows Explorer crash, and when it restarts your application won't be there until you click on it! :p

How about Form.ShowInTaskbar?
Title: Re: Hiding from Taskbar
Post by: Stealth on January 02, 2005, 11:28 PM
ShowInTaskbar is read-only at runtime, however, a Google search for "ShowInTaskbar" yielded this link (http://www.devx.com/vb2themax/Tip/18334) as the first result. Looks good.
Title: Re: Hiding from Taskbar
Post by: Newby on January 02, 2005, 11:46 PM
He could change the state in the Properties window, which is what I was aiming for.
Title: Re: Hiding from Taskbar
Post by: Mr. Neo on January 03, 2005, 06:57 AM
Quote from: Stealth on January 02, 2005, 11:28 PM
ShowInTaskbar is read-only at runtime, however, a Google search for "ShowInTaskbar" yielded this link (http://www.devx.com/vb2themax/Tip/18334) as the first result. Looks good.

Thank you Stealth, this is exactly what I was looking for.  Works like a charm.
Title: Re: Hiding from Taskbar
Post by: Blaze on January 03, 2005, 03:25 PM
Wouldn't Me.Hide and Me.Visible do the exact same thing? It seems to work for my applications.
Title: Re: Hiding from Taskbar
Post by: Stealth on January 03, 2005, 04:24 PM
Quote from: Blaze on January 03, 2005, 03:25 PM
Wouldn't Me.Hide and Me.Visible do the exact same thing? It seems to work for my applications.

Those two will disappear the form as well.
Title: Re: Hiding from Taskbar
Post by: Mr. Neo on January 04, 2005, 07:11 AM
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.

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