ID Number: Q22242
2.00 2.03 2.10 3.00 3.10
WINDOWS
Summary:
SYMPTOMS
When text is painted into a window, an area around the text is a
different color than the remainder of the window.
CAUSE
The area around the text is painted with a solid color while the
remainder of the window is painted using a dithered color.
RESOLUTION
To make the area around the text and the remainder of the window
have the same color, perform one of the following two steps:
- Use a solid color for the window background, and use the same
color for the text background. To ensure that a color is a solid
color, use the GetNearestColor function. This function returns
the nearest solid color available to represent the specified
color.
-or-
- Call the SetBkMode function to specify TRANSPARENT mode for the
text. Doing so prevents Windows from painting the area behind
the text. The window background color shows through instead.
More Information:
By default, when an application paints text into its window, Windows
fills the area around the character with the current background color.
Windows always uses a solid color for this purpose.
When an application registers a window class, it specifies a handle to
a brush that Windows uses to paint the window background. On some
output devices, brushes can create dithered colors. On one of these
devices, the area behind painted text might have a different color
than the remainder of the window.
The following code specifies the window background color:
#define ELANGREEN 0x003FFF00
pTemplateClass->hbrBackground = CreateSolidBrush((DWORD)ELANGREEN);
The following code specifies the color used to paint around text and
draws some text into a device context:
#define SZ -1
SetBkColor(hDC, (DWORD)ELANGREEN);
DrawText(hDC, (LPSTR)"text", SZ, (LPRECT)&Rect, DT_BOTTOM);
The color used to paint the area around the text has a yellow cast,
which gives it a slightly different appearance than the window
background color.
A brush may be able to represent a wider color range than the solid
colors because a brush covers an area while a solid color may be used
to paint nominal-width lines (for example, lines that are one device
unit wide) that must be the same color at all locations and angles.
Therefore, the device-driver writer has the option of providing
dithered colors for brushes, but has no such freedom when it comes to
the solid colors for drawing lines.
Additional reference words: 2.00 2.03 2.10 3.00 3.10 2.x TAR59316