Click to See Complete Forum and Search --> : CEdit custom painting ?


bischofb
May 31st, 1999, 02:22 AM
Hi!

I'd like to use a customized CEdit-control which displays a gray text inside
if the control ist empty, otherwise the
user input (I've seen that in a commercial software but can't remember the
name). I tried to overwrite the OnPaint
but got not the result I wanted. Has anybody done this before?

Ciao,
Alex

Jörg Eckart
May 31st, 1999, 04:06 AM
Hi,

you have to create a message handler for the message ON_WM_CTLCOLORREFLECT and then you can set the text and back color like this:

HBRUSH CMyEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
pDC->SetTextColor(textcol);
pDC->SetBkColor(backcol);

return brush; // brush is a CBrush object, created with CreateSolidBrush(backcol)
}

Greetings, Jörg

bischofb
May 31st, 1999, 04:13 AM
Sorry, we misunderstood. The problem is not setting the colors (it works great the way you described), but doing custom painting (not only changing some colors) inside the CEdit (here: drawing some static, gayed text when the control ist "empty").

Thank you for your reply and I hope it's now more clearly what I want to do.