Posted: Thu Apr 06, 2006 5:25 pm
				
				@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 
			http://www.purebasic.com
https://www.purebasic.fr/english/
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"))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) 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) 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
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 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