In the article Windows CE: Setting an Application to Display Full Screen in C/C++ I discussed how to show an application full screen using C++. I discussed that for a kiosk application that the easiest way to disable the Explorer shell taskbar is to simply not have the Explorer shell launch when the system starts up. But there are cases where having the Explorer shell run underneath the kiosk app has value in some cases. The trouble is that the taskbar will still respond to special keys like the Windows key and suddenly the user has access to the full system. In this article, we will explore disabling the taskbar.
The first step to disable the taskbar is to get a handle to the taskbar window. To do this we will use FindWindow() and the class name of the taskbar which is “HHTaskBar”. We know that the name is HHTaskBar because the code for the taskbar is available in Platform Builder and a review of the code tells us the name. So to get a handle to the taskbar window:
                HWND TaskBar = FindWindow(TEXT("HHTaskBar"), NULL );
Now that we have a handle to the taskbar window, we can send it messages. We could send it a WM_CLOSE message:
                SendMessage(TaskBar, WM_CLOSE, NULL, NULL );
But, that will close the Explore shell, which defeats the purpose which is to keep the Explorer shell running and have access to the APIs that it provides.
Better is to hide the taskbar, not in the sense of setting its auto hide feature which leaves it usable but minimized. Instead we will disable it with a call to EnableWindow():
                EnableWindow( TaskBar, FALSE );
Which also allows us to reenable the taskbar if and when we need to do so.
In the modified full screen application from Windows CE: Setting an Application to Display Full Screen in C/C++, the WinMain() is now:
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPTSTR    lpCmdLine,
                   int       nCmdShow)
{
                MSG msg;
 
                if( lpCmdLine )
                                SignalStarted( _wtol(lpCmdLine) );
                HWND TaskBar = FindWindow(TEXT("HHTaskBar"), NULL );
                if( TaskBar != NULL )
                {
                                EnableWindow( TaskBar, FALSE );
                }
 
                // Perform application initialization:
                if (!InitInstance(hInstance, nCmdShow))
                {
                                if( TaskBar != NULL )
                                {
                                                EnableWindow( TaskBar, TRUE );
                                }
                                return FALSE;
                }
 
                HACCEL hAccelTable;
                hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_DELETEMENEXT));
 
                // Main message loop:
                while (GetMessage(&msg, NULL, 0, 0))
                {
                                if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
                                {
                                                TranslateMessage(&msg);
                                                DispatchMessage(&msg);
                                }
                }
                TaskBar = FindWindow(TEXT("HHTaskBar"), NULL );
                if( TaskBar != NULL )
                {
                                EnableWindow( TaskBar, TRUE );
                }
                return (int) msg.wParam;
}
Which not only disables the taskbar when the application starts, but reenables it when the application exits.
Copyright © 2010 – Bruce Eitman
All Rights Reserved