How to hide an external program from the desktop AND taskbar

Just starting out? Need help? Post your questions and find answers here.
Glow
User
User
Posts: 10
Joined: Sun Dec 18, 2005 9:03 pm

Post by Glow »

@PB : The GetWindowLong_(a,#GWL_HWNDPARENT) was indeed the key :) I tried it with GetParent_(hwnd) before, but I had no success with that. Thanks for your effort. It´s all good now :D
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Thanks for your effort. It´s all good now :D

Cool. Use my procedure and it should work with all window types. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

This three code is fantastic

I don't want to be the bad boys :roll:
But, how to do for reappears the windows :D

For this code :

Code: Select all

; RemoveFromTaskbar by PB. 

Procedure RemoveFromTaskbar(hwnd) 
  If IsWindow_(hwnd) 
    a=hwnd : b=GetWindowLong_(a,#GWL_HWNDPARENT) : If b<>0 : a=b : EndIf ; Needed for "TaskAssign.exe". 
    ShowWindow_(a,#SW_HIDE) : GetWindowRect_(a,win.RECT) : w=win\right-win\left : h=win\bottom-win\top 
    SetWindowLong_(a,#GWL_EXSTYLE,#WS_EX_TOOLWINDOW) :  SetWindowPos_(a,0,0,0,w-1,h-1,#SWP_NOMOVE) 
    SetWindowPos_(a,0,0,0,w,h,#SWP_NOMOVE|#SWP_SHOWWINDOW) : ProcedureReturn 1 
  EndIf 
EndProcedure 

Debug RemoveFromTaskbar(FindWindow_(0,"THG Task Assignment Manager V1.0")) 
Debug RemoveFromTaskbar(FindWindow_(0,"Untitled - Notepad")) 
Debug RemoveFromTaskbar(FindWindow_(0,"Calculator"))
This code :

Code: Select all

task_hwnd = FindWindow_(0,"Caption of the external program") 
OpenWindow(2, 0, 0, 0, 0,#PB_Window_Invisible, "") 
SetParent_(task_hwnd, WindowID(2)) 
ShowWindow_(task_hwnd, #SW_HIDE) 
And the last code :

Code: Select all

ShowWindow_(WindowID(#window),#SW_HIDE) 
SetWindowLong_(WindowID(#window),#GWL_EXSTYLE,GetWindowLong_(WindowID(#window),#GWL_EXSTYLE)|#WS_EX_TOOLWINDOW) 
ShowWindow_(WindowID(#window),#SW_SHOW) 
Or perhaps you have a magic code that works with the three functions :D
ImageThe happiness is a road...
Not a destination
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Old Thread :wink:

Code: Select all

Procedure HideFromTaskBar(hWnd.l, Flag.l)
  Protected TBL.ITaskbarList

  CoInitialize_(0)
  If CoCreateInstance_(?CLSID_TaskBarList, 0, 1, ?IID_ITaskBarList, @TBL) = #S_OK
    TBL\HrInit()
    If Flag
      TBL\DeleteTab(hWnd)
    Else
      TBL\AddTab(hWnd)
    EndIf
    TBL\Release()
  EndIf
  CoUninitialize_()
 
  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
Hide and UnHide :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Thanks a lot TS-SOFT

You are always here for help me 8)

Good day for you :D
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

I have again a little problem. :oops:

The function of TS-Soft works fine.

I open my extern application
I reduce her in the taskbar with ShowWindow
I Create a systray icon in the systray
I hide the windows in the taskbar with HideFromTaskBar

All that works fine
I click on the icon in the systray, my extern aplication reappears and his button on the taskbar too.
But when i reduce again my application, the button in taskbar not disappears, normal because i can't catch the event mouse to reduce the application :cry:

Somebody know how catch the event reduce of external windows click ?
Last edited by Kwai chang caine on Mon Jun 30, 2008 3:38 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Well, i use again this function

Code: Select all

Procedure RemoveFromTaskbar(hwnd) 
 
 If IsWindow_(hwnd) 
 
  a = hwnd 
  b = GetWindowLong_(a,#GWL_HWNDPARENT) 
  
  If b <> 0 
   a = b 
  EndIf ; Needed for "TaskAssign.exe". 
  
  ShowWindow_(a, #SW_HIDE) 
  GetWindowRect_(a, win.RECT) 
  w = win \ right - win \ left
  h = win \ bottom - win \ top 
  SetWindowLong_(a, #GWL_EXSTYLE, #WS_EX_TOOLWINDOW) 
  SetWindowPos_(a, 0, 0, 0, w - 1, h - 1, #SWP_NOMOVE) 
  SetWindowPos_(a, 0, 0, 0, w, h, #SWP_NOMOVE|#SWP_SHOWWINDOW)
  ProcedureReturn 1 
 
 EndIf 
 
EndProcedure 
But the reduce button disapears on my extern application :shock:
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

I am not come to do reappear the taskbar button.

I have circle the problem like that :

When i clik a first time, the application appears.
And the second time, she desappears

Code: Select all

Procedure RemoveFromTaskbar(hwnd) 
 
 If IsWindow_(hwnd) 
 
  a = hwnd 
  b = GetWindowLong_(a,#GWL_HWNDPARENT) 
  
  If b <> 0 
   a = b 
  EndIf ; Needed for "TaskAssign.exe". 
  
  ShowWindow_(a, #SW_HIDE) 
  GetWindowRect_(a, win.RECT) 
  w = win \ right - win \ left
  h = win \ bottom - win \ top 
  SetWindowLong_(a, #GWL_EXSTYLE, #WS_EX_TOOLWINDOW) 
  SetWindowPos_(a, 0, 0, 0, w - 1, h - 1, #SWP_NOMOVE) 
  SetWindowPos_(a, 0, 0, 0, w, h, #SWP_NOMOVE|#SWP_SHOWWINDOW)
  ProcedureReturn 1 
 
 EndIf 
 
EndProcedure 

#Clic = 1

#SysIcon = 10
#Sytray = 11
#PopUp = 12

Chemin.s = "c:\Program Files\Prg\"
RunProgram(Chemin + "Prg.exe", "=E:\DON\prg.ini", "")
Delay(1000)

Hwnd = FindWindow_(0, "Barre des titres prg") 
ShowWindow_(Hwnd, 6) ; Descendre la fenetre dans la barre des taches
RemoveFromTaskbar(Hwnd) ; Cacher de la barre des taches


If OpenWindow(#Clic, 0, 0, 0, 0, "", #PB_Window_Invisible )

 HwndClic = WindowID(#Clic)
 hIconSysTray = LoadImage(#SysIcon,"c:\ico.ico")            
 AddSysTrayIcon(#Sytray, HwndClic, hIconSysTray)           
 CreatePopupMenu(#PopUp)                                   
 MenuItem(1,"Quitter"l)                                  
 
 Repeat
  
  Select WaitWindowEvent()
   
   Case #PB_Event_SysTray
    
    Select EventType()
   
     Case #PB_EventType_RightClick  
     
      DisplayPopupMenu(#PopUp, HwndClic)
      
     Case #PB_EventType_LeftClick
      
      HwndLotus = FindWindow_(0, "Barre des titres prg")       

      If IsIconic_(Hwnd)     
       ShowWindow_(Hwnd, 1)
      Else
       ShowWindow_(Hwnd, 6)
      EndIf 
   
    EndSelect
   
   Case #PB_Event_Menu
   
    Select EventMenu()
     Case 1 
      Quit = 1
    EndSelect
 
  EndSelect
 
 Until quit = 1
 
 End

EndIf
ImageThe happiness is a road...
Not a destination
Post Reply