# ...hiding the Windows TaskBar

The two little programs in this lesson use the FindWindowA() function to get a 'handle' to an external window, and then hide that window.

The first example will hide the taskbar when it starts up, and will un-hide it on exit. Just for fun, it finds out what screen resolution the user has, and then makes the program window height equal to the screen height.

The window style has been deliberately chosen so that the program does not have minimize and maximize buttons. We don't want to minimize this program into a hidden taskbar, since that would make it very awkward to shut the program down to restore the taskbar again... ;-)

The taskbar has a registered class name of "Shell_TrayWnd", so this is the ( pointer to ) zero terminated string we use as the first parameter in FindWindowA() to get a 'handle' to the taskbar.

Since we can ( safely ? ) assume there is only one taskbar, the second parameter, which is the program's name, can just be NULL.

-- kick-it1.exw

    -- hides taskbar on start-up, restores on exit --
    -- start demo --
    include win32lib.ew

    constant
        CYFULL = w32Func( xGetSystemMetrics, {SM_CYSCREEN} ),
        Win = create( Window, "kick-taskbar", 0, 100, 0, 150, CYFULL, {WS_CAPTION, WS_SYSMENU} ),
        -- new function !
        zFindWindow = registerw32Function( user32, "FindWindowA", {C_POINTER,  C_INT},  C_INT )

    atom ptr,  ok,  taskbarhwnd

    procedure hide_taskbar( integer self,  integer event,  sequence params )
      ptr = allocate_string( "Shell_TrayWnd" )
      taskbarhwnd = w32Func( zFindWindow, { ptr, NULL } )
      --call the ShowWindow() function to hide the taskbar
      ok = w32Func( xShowWindow, {taskbarhwnd, SW_HIDE } )
      free( ptr )
    end procedure

    -- you MUST do this on program exit to get the taskbar back ;-)
    procedure restore_taskbar( integer self,  integer event,  sequence params )
      ok = w32Func( xShowWindow,  {taskbarhwnd,  SW_SHOW } )
    end procedure

    setHandler( Win,  w32HOpen,  routine_id( "hide_taskbar" ) )
    setHandler( Win,  w32HClose,  routine_id( "restore_taskbar" ) )

    WinMain( Win, Normal )
    -- end demo –

Next, the second example, kick-it2.exw.

I won't bother to show the full source code of the second example.
There are only a few minor differences.

The first parameter used in the FindWindowA() function will be the registered class name of the first declared window in any win32lib program. If you poke around in the win32lib.ew source code, you will find that it's:
"Win32Lib AppWindow 1".

We will define the second parameter to be "Euphoria Win32 Tutorials", so if the tutorial 'engine' happens to be running, it will be the program that is hidden.

    -- a little extract --

    procedure hide_tutorial()
      ptr = allocate_string("Win32Lib AppWindow 1")
      ptr2 = allocate_string("Euphoria Win32 Tutorials")
      tutorialhwnd= w32Func( zFindWindow, { ptr, ptr2 } )
      ok = w32Func( xShowWindow, {tutorialhwnd, SW_HIDE } )
      free(ptr)
      free(ptr2)
    end procedure

... end-hiding ...

CONTENTS