SetBkMode

2.x

  int SetBkMode(hdc, fnBkMode)    
  HDC hdc; /* handle of device context */
  int fnBkMode; /* background mode, */  

The SetBkMode function sets the specified background mode. The background mode defines whether the system removes existing background colors on the drawing surface before drawing text, hatched brushes, or any pen style that is not a solid line.

Parameters

hdc

Identifies the device context.

fnBkMode

Specifies the background mode to be set. This parameter can be one of the following values:

Value Meaning

OPAQUE Background is filled with the current background color before the text, hatched brush, or pen is drawn. This is the default background mode.
TRANSPARENT Background is not changed before drawing.

Return Value

The return value is the previous background mode, if the function is successful.

Example

The following example determines the current background mode by calling the GetBkMode function. If the mode is OPAQUE, the SetBkMode function sets it to TRANSPARENT.

int nBackMode;

nBackMode = GetBkMode(hdc);
if (nBackMode == OPAQUE) {
    TextOut(hdc, 90, 100, "This background mode is OPAQUE.", 31);
    SetBkMode(hdc, TRANSPARENT);
}

See Also

GetBkColor, GetBkMode, SetBkColor