How can I do a task does not appear in the taskbar?

Just starting out? Need help? Post your questions and find answers here.
User avatar
minimy
Enthusiast
Enthusiast
Posts: 679
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

How can I do a task does not appear in the taskbar?

Post by minimy »

How can I do a task does not appear in the taskbar, knowing the hWnd?
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
Bisonte
Addict
Addict
Posts: 1320
Joined: Tue Oct 09, 2007 2:15 am

Re: How can I do a task does not appear in the taskbar?

Post by Bisonte »

PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: How can I do a task does not appear in the taskbar?

Post by RASHAD »

Hi

Code: Select all

OpenWindow(1, -500, 0, 0, 0, "Not Needed", #PB_Window_Invisible)

OpenWindow(0,0,0,400,100, "Not shown in the Taskbar",#PB_Window_ScreenCentered|#PB_Window_SystemMenu,WindowID(1))
  ButtonGadget(0, 0, 0, 200, 100, "Hide Window from showing in Taskbar")
  ButtonGadget(1, 200, 0, 200, 100, "Show Window in Taskbar")
 
Repeat
  EventID=WaitWindowEvent()
  Select EventID
    Case #PB_Event_Gadget
      Select EventGadget()
         Case 0
                  HideWindow(1,1)

         Case 1
                 HideWindow(1,0)
                 SetActiveWindow(0)
      EndSelect
  EndSelect
Until EventID=#PB_Event_CloseWindow

Egypt my love
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: How can I do a task does not appear in the taskbar?

Post by Danilo »

CallCOM() - that's quite old. :D

Can be used directly with PB Interfaces:

Code: Select all

;----------------------------------------
;----------------------------------------
;  Hide a Window from the Taskbar
;----------------------------------------
;----------------------------------------
EnableExplicit

Global _hideFromTaskbar_Object.ITaskbarList
;
; Hide or UnHide a Window from the Windows Taskbar
;
; STATES: #FALSE (0)    =  Show Window on Taskbar
;         #TRUE  (<>0)  =  Hide Window on Taskbar
;
Procedure HideFromTaskbar(WindowID, State)
    Shared _hideFromTaskbar_Object.ITaskbarList
    If _hideFromTaskbar_Object
        If State = 0
            _hideFromTaskbar_Object\AddTab(WindowID)
        Else
            _hideFromTaskbar_Object\DeleteTab(WindowID)
        EndIf
    EndIf
EndProcedure

;
; Call at begin of program
;
Procedure InitHideFromTaskbar()
    Shared _hideFromTaskbar_Object.ITaskbarList
    CoInitialize_(0)
    If _hideFromTaskbar_Object = 0
        CoCreateInstance_(?CLSID_TaskbarList,0,1,?IID_ITaskbarList,@_hideFromTaskbar_Object)
        If _hideFromTaskbar_Object
            If _hideFromTaskbar_Object\HrInit() <> #S_OK
                _hideFromTaskbar_Object\Release()
                _hideFromTaskbar_Object = 0
            EndIf
        EndIf
    EndIf
    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
EndProcedure

;
; Call at end of program
;
Procedure EndHideFromTaskbar()
    Shared _hideFromTaskbar_Object.ITaskbarList
    If _hideFromTaskbar_Object
        _hideFromTaskbar_Object\Release()
        _hideFromTaskbar_Object = 0
    EndIf
    CoUninitialize_()
EndProcedure

DisableExplicit
;----------------------------------------
;----------------------------------------
;  end include file
;----------------------------------------
;----------------------------------------



Procedure Btn0_Click()
    Static state
    state!1
    HideFromTaskbar(WindowID(0),state)
EndProcedure

InitHideFromTaskbar()

    OpenWindow(0,0,0,200,200,"My PB Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    ButtonGadget(0,10,10,180,25,"Hide/Unhide from Taskbar")
    BindEvent(#PB_Event_Gadget,@Btn0_Click(),0,0)
    
    Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow

EndHideFromTaskbar()
said
Enthusiast
Enthusiast
Posts: 342
Joined: Thu Apr 14, 2011 6:07 pm

Re: How can I do a task does not appear in the taskbar?

Post by said »

If that's ok to have a small title bar, you can use the flag #PB_Window_Tool with OpenWindow()

Code: Select all

  If OpenWindow(0, 0, 0, 230, 90, "example...", #PB_Window_Tool|#PB_Window_SystemMenu|#PB_Window_ScreenCentered)

   Repeat
   Until WaitWindowEvent() = #PB_Event_CloseWindow
 EndIf

User avatar
minimy
Enthusiast
Enthusiast
Posts: 679
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: How can I do a task does not appear in the taskbar?

Post by minimy »

Rashad, Bisonte & said, thanks for helpme! :D
But im lockingfor any thing, like danilo´s solution. :D
Thanks a lot, danilo for your code and time. :D
gretings friends!
If translation=Error: reply="Sorry, Im Spanish": Endif
Post Reply