PRB: TextOut Draws Dotted Underscore with Most Colored Text

ID Number: Q74740

3.00

WINDOWS

Summary:

SYMPTOMS

When a character in a text string is preceded by an ampersand (&)

and displayed in color using the DrawText function, the underscore

used to indicate that the character is a keyboard mnemonic is drawn

as a dotted line.

CAUSE

If the text is drawn using any color other than COLOR_WINDOW,

COLOR_WINDOWTEXT, or COLOR_GRAYTEXT, the underscore is drawn with

the PatBlt function using a default gray brush. This results in a

dotted underscore.

The TextOut function may be used in low-memory situations to draw

text on a hard system-modal dialog box. Because of this, TextOut

cannot create GDI objects or perform other allocations that may

cause the Windows Kernel to move memory to satisfy the allocation.

The Windows version 3.0 USER module only caches brushes for the

system colors COLOR_WINDOW, COLOR_WINDOWTEXT, and COLOR_GRAYTEXT.

If the color used in a TextOut call does not match one of these

colors, TextOut cannot create a new colored brush. The brush

selected here is used to draw the underline on the mnemonic

character.

RESOLUTION

When drawing text with a mnemonic in color, an application must

manually draw the underscore two pixels below the character.

The GetCharWidth function can be used to retrieve the exact width

of the character.

Microsoft has confirmed this to be a limitation of Windows version

3.0. We are researching this limitation and will post new

information here as it becomes available.

Additional reference words: 3.00