How to Create a Full-Screen Window

4/19/2010

The SDK for Windows Mobile devices provides the SHFullScreen function to give your application full control over the screen. The Win32 sample HTMLHost demonstrates how to use SHFullScreen in your application.

Remarks

Full-screen applications can be optionally designed to remove the user's access to the Start menu, in which case your application must provide a way for the user to access other applications on the device.

Code Example

The following code example demonstrates how to call SHFullScreen from within the MFC InitInstance function.

Note

To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

BOOL rb;
BOOL chgScreen;
int rc;
RECT rect;
HWND hWnd;

if (rb == FALSE)
{
    // SystemParametersInfo failed.
    rc = MessageBox(NULL, _T("Could not get work area."),
                    _T("Error"), MB_OK);
    if (rc == 0)  // Not enough memory to create MessageBox.
        return E_OUTOFMEMORY;
    return E_FAIL;  // Replace with specific error handling.
}

if (hWnd == NULL)
{
    // CreateWindow failed.
    rc = MessageBox(NULL, _T("Could not create main window."),
                    _T("Error"), MB_OK);
    if (rc == 0)  // Not enough memory to create MessageBox.
        return E_OUTOFMEMORY;
    return E_FAIL;  // Replace with specific error handling.
}

GetWindowRect(hWnd, &rect);

if (chgScreen == FALSE)
{
    // SHFullScreen failed.
    rc = MessageBox(NULL, _T("Could not modify the window."),
                    _T("Error"), MB_OK);
    if (rc == 0)  // Not enough memory to create MessageBox.
        return E_OUTOFMEMORY;
    return E_FAIL;  // Replace with specific error handling.
}

SetWindowPos(hWnd, HWND_TOPMOST,
             rect.left, 
             rect.top - MENU_HEIGHT, 
             rect.right, 
             rect.bottom + MENU_HEIGHT, 
             SWP_SHOWWINDOW);

See Also

Tasks

How to Prevent Display of Smart Minimize Buttons in Application Windows