PRWIN9012016: Cannot Change Single-Line Edit Control Color

ID Number: Q67204

3.00

WINDOWS

buglist3.00 fixlist3.10

Summary:

PROBLEM ID WIN9012016

SYMPTOMS

When a WM_CTLCOLOR message is sent to a single-line edit control,

the color of the interior is not changed properly.

CAUSE

The edit control is painted twice: first as specified in the

WM_CTLCOLOR message and again using the default colors.

RESOLUTION

Microsoft has confirmed this to be a problem in Windows version

3.0. There are two methods to work around this problem:

- Create a multiline edit control that is one line in height.

Note: Do not include ES_AUTOVSCROLL as part of the edit control

style or the edit control will accept multiple lines of input.

-or-

- Add the following code to the WM_CTLCOLOR processing

(hBackgroundBrush is the handle to a brush of the color desired

for the edit control background):

if (CTLCOLOR_MSGBOX == HIWORD(lParam))

return (DWORD)hBackgroundBrush;

This problem was corrected in Windows version 3.1.

Additional reference words: 3.00 SR# G901025-163