Taskbar Utilities

Taskbar Utilities

Postby Daniel Garcia-Gil » Wed Nov 26, 2008 3:18 pm

i hope this work for someone

Code: Select all  Expand view
#include "fivewin.ch"

function MainTest()

   local oWnd, oBar
   local oTB := TaskBar()
   local n := 0

   DEFINE WINDOW oWnd TITLE "Test Task Bar"

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar  ;
      ACTION  oTB:HideShowTaskBar() ;
      MESSAGE "Muestra/Oculta TaskBar"

   DEFINE BUTTON OF oBar ;
      ACTION oTB:HideShowClock();
      MESSAGE "Muestra/Oculta Reloj"

    DEFINE BUTTON OF oBar ;
      ACTION oTB:HideShowStartButton();
      MESSAGE "Muestra Oculta StartButton"


    DEFINE BUTTON OF oBar ;
      ACTION ( oTB:EnaDisTaskBar( ) ) ;
      MESSAGE "Enable/ Disable TaskBar"

    DEFINE BUTTON OF oBar ;
      ACTION ( oTB:EnaDisStartButton( ) ) ;
      MESSAGE "Enable/ Disable StartButton"

    DEFINE BUTTON OF oBar ;
      ACTION ( oTB:HideShowSysTray() ) ;
      MESSAGE "Enable/ Disable StartButton"

    DEFINE BUTTON OF oBar ;
      ACTION ( oTB:HideShowIcons() ) ;
      MESSAGE "Enable/ Disable Icons"

    DEFINE BUTTON OF oBar ;
      ACTION ( oTB:HideShowQuickStar() ) ;
      MESSAGE "Enable/ Disable QuickStar"

    DEFINE BUTTON OF oBar ;
      ACTION ( oTB:HideShowTask() ) ;
      MESSAGE "Enable/ Disable Task"
     
   DEFINE BUTTON OF oBar ;
      ACTION ( oTB:TransTaskBar( n+=10 ) ) ;
      MESSAGE "Enable/ Disable Task"

   DEFINE BUTTON OF oBar ;
      ACTION ( oTB:Default() ) ;
      MESSAGE "Enable/ Disable Task"


 
   SET MESSAGE OF oWnd TO "Class TaskBar" CENTERED

   ACTIVATE WINDOW oWnd


//////////////////////////////////////////////////////////////////////////////
// CLASS TaskBar
// Clase que permite ocultar y desaparecer elementos de la barra de tareas de windows
// la variable lForce se usa para obligar la accion en cada metodo
// si se desea mostrar/ocultar forzosamente un elemnto usar lForce := .t. / .f.
// segun la nesecidad, pero cada metodo lo hace automaticamente dependiendo del estado
// nLevel en el methodo TransTaskBar indica el nivel porcentual de transparencia
// methodo default, restaura los valores forzando todos los elementos a .t. y 0 % transparecia
///////////////////////////////////////////////////////////////////////////////////
// CLASS TaskBar
// Hide/Show windows TaskBar element
// lForce variable used for force "action" into each methods
// to show use lForce = .t., to Hide lForce = .f.
// nLevel variable used into TransTaskBar method is porcentual level transparent
// method default, rsstore initial values, force all element to .t. 0% transparent
///////////////////////////////////////////////////////////////////////////////

#define SW_HIDE               0 
#define SW_NORMAL            1 
#define GW_HWNDNEXT             2
#define GW_CHILD                  5
#define GWL_EXSTYLE               -20
#define N_STATUS_ED               1
#define N_STATUS_VI               2
#define WS_EX_LAYERED           524288
#define LWA_ALPHA                  2



class TaskBar


method HideShowTaskBar( lForce )          
method HideShowStartButton( lForce )
method HideShowClock( lForce )
method EnaDisTaskBar( lForce )
method EnaDisStartButton( lForce )
method HideShowSysTray( lForce )
method HideShowIcons( lForce )
method HideShowQuickStar( lForce )
method HideShowTask( lForce )
method TransTaskBar( nLevel )
method Default()

endclass



method Default()   class TaskBar
   ::HideShowTaskBar( .t. )
   ::HideShowStartButton( .t. )
   ::HideShowClock( .t. )
   ::EnaDisTaskBar( .t. )
   ::EnaDisStartButton( .t. )
   ::HideShowSysTray( .t. )
   ::HideShowIcons( .t. )
   ::HideShowQuickStar( .t. )
   ::HideShowTask( .t. )
   ::TransTaskBar( 0 )
return


Method HideShowStartButton( lForce ) class TaskBar
Local hChild

default lForce := NIL

    If ( hChild:=fhStartButton() ) != 0
       ShowHide( hChild, lForce )
    endif
hChild := NIL
return nil


Method HideShowClock( lForce ) class TaskBar
local hChild

default lForce := NIL

    If ( hChild := fhClock() ) != 0
       ShowHide( hChild, lForce )
    endif
   
hChild = NIL
return NIL

Method HideShowTaskBar( lForce ) class TaskBar
local hTrayWnd

default lForce := NIL

    If ( hTrayWnd := fhTaskBar() )  != 0
       ShowHide( hTrayWnd, lForce )
    endif
hTrayWnd = NIL

return NIL

Method HideShowSystray( lForce ) class TaskBar
Local hNotifyWnd

default lForce := NIL

    If ( hNotifyWnd := fhTrayNotify() ) != 0
      ShowHide( hNotifyWnd, lForce )
    Endif
   
hTrayNotifyWnd = NIL   
return


method HideShowIcons( lForce ) class TaskBar
local hSysPager
default lForce := NIL

    If ( hSysPager := fhSysPager() ) != 0
      ShowHide( hSysPager, lForce )
    Endif
   
hSysPager = NIL   

return         

method HideShowQuickStar( lForce ) class TaskBar
local hQuickStar
default lForce := NIL

    If ( hQuickStar := fhQuickStar() ) != 0
       ShowHide( hQuickStar, lForce ) 
    Endif
   
hQuickStar = NIL   

return         


method HideShowTask( lForce ) class TaskBar
local hTask
default lForce := NIL

    If ( hTask := fhTask() ) != 0
       ShowHide( hTask, lForce ) 
    Endif
   
hTask = NIL   

return         


method  EnaDisTaskBar( lForce ) class TaskBar
Local hTrayWnd
default lForce := NIL
    hTrayWnd = fhTaskBar()
    If hTrayWnd != 0
       if lForce == NIL
         EnableWindow(hTrayWnd, if ( IsWindowEnabled( hTrayWnd ),.f.,.t.) )
      else
         if lForce
            EnableWindow(hTrayWnd, .t.)
         else
            EnableWindow(hTrayWnd, .f.)
         Endif
      endif
    Endif
hTrayWnd = NIL   
return

method  EnaDisStartButton( lForce ) class TaskBar
Local hStartB
default lForce := NIL

    If ( hStartB := fhStartButton()) != 0
       if lForce == NIL
         EnableWindow(hStartB, if ( IsWindowEnabled( hStartB ),.f.,.t.) )
      else
         if lForce
            EnableWindow(hStartB, .t. )
         else
            EnableWindow(hStartB, .f. )
         Endif
      endif
    Endif
hStartB = NIL
return


method TransTaskBar( nLevel ) class TaskBar
Local nTrans, nOldStyle, hTrayWnd

    nTrans = 255 - Max(0, Min( Int( nLevel*255/100),255 ) )
   
    If ( hTrayWnd := fhTaskBar() ) != 0
      nOldStyle = GetWindowLong(hTrayWnd, GWL_EXSTYLE)
      SetWindowLong(hTrayWnd, GWL_EXSTYLE, nOr(nOldStyle, WS_EX_LAYERED))
      SetLayeredWindowAttributes(hTrayWnd, 0, nTrans, LWA_ALPHA)
    Endif

return


static function fhClock
Local hChild

      hChild       := GetWindow( fhTrayNotify(), GW_CHILD )
    do while upper( GetClassName ( hChild ) ) != "TRAYCLOCKWCLASS"
       hChild := GetWindow (hChild, GW_HWNDNEXT)
    enddo

return hChild


static function fhStartButton
local hTrayWnd, hChild

    hTrayWnd    := fhTaskBar()
    hChild       := GetWindow ( hTrayWnd, GW_CHILD )
    do while upper( GetClassName ( hChild ) ) != "BUTTON"
       hChild := GetWindow(hChild, GW_HWNDNEXT)
    enddo

return hChild

static Function fhTrayNotify()
local hChild

    hChild       := GetWindow ( fhTaskBar(), GW_CHILD )
    do while upper( GetClassName ( hChild ) ) != "TRAYNOTIFYWND"
       hChild := GetWindow(hChild, GW_HWNDNEXT)
    enddo

return hChild

static Function fhSysPager()

      hChild       := GetWindow( fhTrayNotify(), GW_CHILD )
    do while upper( GetClassName ( hChild ) ) != "SYSPAGER"
       hChild := GetWindow (hChild, GW_HWNDNEXT)
    enddo
   
return hChild

static Function fhQuickStar()
local hChild

    hChild       := GetWindow ( fhTaskBar(), GW_CHILD )
    do while upper( GetClassName ( hChild ) ) != "REBARWINDOW32"
       hChild := GetWindow(hChild, GW_HWNDNEXT)
    enddo
    hChild       := GetWindow ( hChild, GW_CHILD )
    do while upper( GetClassName ( hChild ) ) != "TOOLBARWINDOW32"
       hChild := GetWindow(hChild, GW_HWNDNEXT)
    enddo
      
   
return hChild

static Function fhTask()
local hChild

    hChild       := GetWindow ( fhTaskBar(), GW_CHILD )
    do while upper( GetClassName ( hChild ) ) != "REBARWINDOW32"
       hChild := GetWindow(hChild, GW_HWNDNEXT)
    enddo
    hChild       := GetWindow ( hChild, GW_CHILD )
    do while upper( GetClassName ( hChild ) ) != "MSTASKSWWCLASS"
       hChild := GetWindow(hChild, GW_HWNDNEXT)
    enddo
      
   
return hChild


static function fhTaskBar
return FindWindow("Shell_TrayWnd", 0)

static procedure ShowHide( hWnd, lForce )

      if lForce == NIL
        ShowWindow(hWnd, if( IsWindowVisible( hWnd ), SW_HIDE, SW_NORMAL ) )
    else
        if lForce
           ShowWindow(hWnd, SW_NORMAL )
        else
           ShowWindow(hWnd, SW_HIDE  )
        endif
    endif
   
return
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 94 guests