Share via


How to: Create a Full-Screen Window

The SDK for Windows Mobile-based 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.

Note   If you require even more control over the display than the SHFullScreen function provides, the Game API allows full programmatic access to the display buffer.

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

Example:

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

rb = SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
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.
}

hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
       CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
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);
chgScreen = SHFullScreen(hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | 
                  SHFS_HIDESTARTICON);
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.
}
MoveWindow( hWnd, 
            rect.left, 
            rect.top - MENU_HEIGHT, 
            rect.right, 
            rect.bottom + MENU_HEIGHT, 
            TRUE);

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.

See Also

How to: Prevent Display of Smart Minimize Buttons in Application Windows

Send feedback on this topic to the authors.

© 2005 Microsoft Corporation. All rights reserved.