CWebView::SetBackgroundColor Method  
 
BOOL SetBackgroundColor(
  COLORREF rgbBackground  
);

The SetBackgroundColor method changes the background color used behind the page content.

Parameters

rgbBackground
An integer value which specifies the background color.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The background color specifies the fill used by the browser window when there is no content to display or the document itself does not define a background. This value only applies to the WebView host surface and does not affect page transparency. The alpha channel is ignored, and the color is treated as fully opaque.

It is important to note that this setting does not override the background defined by the currently loaded page. If the page specifies its own background color or image, that content will take precedence and may obscure the configured color. For example, setting the background to white will not force web pages to appear white unless the page itself has transparent regions.

Applications can use this method to provide a consistent appearance for empty or loading views, but should not rely on the background color as a substitute for page styling. When a browser instance is first created, the default background color is white.

A COLORREF is a 32-bit value used by the Windows API to represent an RGB color. The low-order byte specifies the red component, the next byte the green component, and the third byte the blue component, in the format 0x00BBGGRR. The high-order byte is unused and should be zero. Note that COLORREF is specific to the Windows API and is not the same as the OLE color system (OLE_COLOR). OLE uses a slightly different encoding that allows system color values to be specified, which are resolved at runtime. Developers should be careful not to confuse the two.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib

See Also