Page 1 of 1
Hide program from being displayed on task bar
Posted: Fri Aug 15, 2003 5:59 am
by LJ
Is there a way to hide a program from being displayed on the task bar?
I'm using the RunProgram command with a flag that stops execution until the second program is closed. Problem, in Windows XP, it's not idiot proof. If someone clicks on the task bar the old window, up comes a blank white window, if they click in the window, Windows XP appends to the title bar (Not Responding), and then when the Window is closed, throws a fatal error and asks if you want it sent to Microsoft.
What I'd like to do is to hide the first Window from the task bar, while the second program runs. So the only program that can be clicked on the task bar is the program that is running. Then, when the second program is closed, the main program is unhide from the task bar. Maybe I'll post this in feature requests, would be a nice option.
Posted: Fri Aug 15, 2003 8:57 am
by CS2001
Try this Code:
Code: Select all
Procedure HideWindowFromShowingInTaskbar(WindowID, NewWindowHandle, show)
If show=1
HideWindow(WindowID,1)
EndIf
SetWindowLong_(WindowID(WindowID),#GWL_HWNDPARENT,NewWindowHandle)
If show=1
HideWindow(WindowID,0)
EndIf
ProcedureReturn
EndProcedure
OpenWindow(1, 0, 0, 0, 0, #PB_Window_ScreenCentered, "Not Needed")
HideWindow(1,1)
OpenWindow(0,0,0,400,100,#PB_Window_ScreenCentered|#PB_Window_SystemMenu, "Not shown in the Taskbar")
CreateGadgetList(WindowID())
ButtonGadget(0, 0, 0, 200, 100, "Hide Window from showing in Taskbar")
ButtonGadget(1, 200, 0, 200, 100, "Show Window in Taskbar")
DisableGadget(1,1)
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadgetID()
Case 0
HideWindowFromShowingInTaskbar(0, WindowID(1), 0)
DisableGadget(0,1)
DisableGadget(1,0)
Case 1
HideWindowFromShowingInTaskbar(0, 0, 1)
DisableGadget(0,0)
DisableGadget(1,1)
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow
I hope it helps.
CS2001
Posted: Fri Aug 15, 2003 12:36 pm
by Kale
Author Danilo (
should of guessed by CallCOM use 
):
Needs CallCOM user lib installed!
Code: Select all
;----------------------------------------
;----------------------------------------
; Hide a Window from the Taskbar
;----------------------------------------
;----------------------------------------
#HideFromTaskbar_QueryInterface = 0
#HideFromTaskbar_AddRef = 4
#HideFromTaskbar_Release = 8
#HideFromTaskbar_HrInit = 12
#HideFromTaskbar_AddTab = 16
#HideFromTaskbar_DeleteTab = 20
#HideFromTaskbar_ActivateTab = 24
#HideFromTaskbar_SetActiveAlt = 28
;
; Hide or UnHide a Window from the Windows Taskbar
;
; STATES: #FALSE (0) = Show Window on Taskbar
; #TRUE (<>0) = Hide Window on Taskbar
;
Procedure HideFromTaskbar(WINDOW, STATE)
Shared proc_HideFromTaskbar_Object
If STATE = 0
CallCOM(#HideFromTaskbar_AddTab,proc_HideFromTaskbar_Object,WINDOW) ; Show on Taskbar
Else
CallCOM(#HideFromTaskbar_DeleteTab,proc_HideFromTaskbar_Object,WINDOW) ; Delete TAB for hWnd from Taskbar
EndIf
EndProcedure
;
; Call at begin of program
;
Procedure InitHideFromTaskbar()
Shared proc_HideFromTaskbar_Object
CoInitialize_(0)
CoCreateInstance_(?CLSID_TaskbarList,0,1,?IID_ITaskbarList,@proc_HideFromTaskbar_Object)
CallCOM(#HideFromTaskbar_HrInit,proc_HideFromTaskbar_Object) ; Init the Object
EndProcedure
;
; Call at end of program
;
Procedure EndHideFromTaskbar()
Shared proc_HideFromTaskbar_Object
CallCOM(#HideFromTaskbar_RELEASE,proc_HideFromTaskbar_Object)
CoUnInitialize_()
EndProcedure
DataSection
CLSID_TaskbarList:
Data.l $56FDF344
Data.w $FD6D,$11D0
Data.b $95,$8A,$00,$60,$97,$C9,$A0,$90
IID_ITaskbarList:
Data.l $56fdf342
Data.w $FD6D,$11D0
Data.b $95,$8A,$00,$60,$97,$C9,$A0,$90
EndDataSection
;----------------------------------------
;----------------------------------------
; end include file
;----------------------------------------
;----------------------------------------
Edit: Added author name, thanks Rings 
Posted: Fri Aug 15, 2003 1:20 pm
by Rings
The author is Danilo
Wow
Posted: Fri Aug 15, 2003 2:43 pm
by LJ
Wow, thanks guys, that is awesome!