🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #215

WM_CTLCOLOR & Single Line Edit Controls

#215
From: John R. Scanlon
Date: Wed, 08 Apr 1992 00:26
37 lines
1749 bytes
I'm trying to control the colors of my edit controls by catching the WM_CTLCOLOR
in the parent window procedure and it doesn't seem to be working correctly.
The background for the edit control isn't being changed but the characters are
being colored with the correct foreground and background.  As soon as I backspace
over the characters the background is erased also.

The strange thing about this problem is that this code works in Windows 3.1 but
not 3.0.  It also works if I change the edit control to be ES_MULTILINE.

I'm following an example in Petzold where he does the same thing for scrollbars.  
The code looks like the following:

if ( HIWORD(lParam) == CTLCOLOR_EDIT )
    {
    SetBkColor( wParam, some_color);
    SetTextColor( wParam, some_other_color);

    point.x = point.y = 0
    ClientToScreen( hwnd, &point)
    UnrealizeObject( some_brush);`
    SetBrushOrg( wParam, point.x, point.y);
    
    return( some_brush );
    }

The SetBkColor() and SetTextColor() seem to be working fine because the characters
are printed with the correct foreground/background colors.  

Any suggestions would be greatly appreciated.

Thanx, John


-----
John R. Scanlon                                 | Unify Corporation
jrs@Unify.com             Voice: 916 928 6264   | 3901 Lennane Drive
...!uunet!unify!jrs         FAX: 916 928 6401   | Sacramento, CA 95834-1922
Technical Details
Message-ID: <rihjwss@Unify.Com>
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!csus.edu!csusac!sactoh0!unify!Unify.com!jrs

Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.ms.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!csus.edu!csusac!sactoh0!unify!Unify.com!jrs
From: jrs@Unify.com (John R. Scanlon)
Subject: WM_CTLCOLOR & Single Line Edit Controls
Message-ID: <rihjwss@Unify.Com>
Sender: news@Unify.Com (news admin)
Organization: Unify Corporation
Date: Wed, 8 Apr 92 00:26:54 GMT