Share via


Creating a Browser Window (Windows CE 5.0)

Send Feedback

Create a window to provide a work area for the browser by calling the CreateWindowEx function. Parameters of this function specify window attributes, such as the window text and the work area. Once the window is created, call the SetWindowLong function to store this window in GWL_USERDATA. A call to this function associates the browser object with the window.

The following example code shows a method defined in the browser class, CreateBrowserWindow that creates the browser window.

HRESULT CBrowser::CreateBrowserWindow()
{
        RECT rcWorkArea; 
        HRESULT hr = E_FAIL;
// Ensure that the browser window is registered.
        if(!RegisterBrowserWnd())
            goto Exit;
// Retrieve the system's work area in the RECT structure.
        SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
// Create the top-level browser window.
        _hWnd = ::CreateWindowEx(0,
                             TEXT("Browser_main"),
                             TEXT("Sample_Browser"),
                             WS_VISIBLE,
                             rcWorkArea.left,
                             rcWorkArea.top,
                             rcWorkArea.right - rcWorkArea.left,
                             rcWorkArea.bottom - rcWorkArea.top,
                             NULL, NULL, g_hInstance, 0);
        if (!_hWnd)
            goto Exit;
// If the window is created successfully, store this object so the 
//static wrapper can pass calls to the real BrowseWndProc.
        SetWindowLong(_hWnd, GWL_USERDATA, (DWORD)this);
        hr = S_OK;
Exit:
    return hr;
}

In the preceding example code, the call to CreateWindowEx creates a full screen window by passing WS_VISIBLE in the dwStyle parameter. To create an overlapped window, pass WS_OVERLAPPED in dwStyle.

See Also

Creating a Web Browser Object | Creating an Internet Browser

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.