CEdit transparency

Hi,

I want to have a transparent CEdit control. I derive from CEdit, here are snippets of my code:

BEGIN_MESSAGE_MAP(CEditEx, CEdit)
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()

HBRUSH CEditEx::CtlColor(CDC* pDC, UINT nCtlColor)
{

pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(m_bHasFocus?m_clrTextFocus:m_clrText);

return (HBRUSH)GetStockObject(NULL_BRUSH);

}

The control is transparent, but it doesn't get updated when it changes (for example after writing something and then trying to erase it with backspace). How do I get it updated, am I missing something? When I turn off the transparency and set a regular background color with a solid brush, everything works fine.

Thanks.
[783 byte] By [alav] at [2007-11-20 11:59:15]
# 1 Re: CEdit transparency
Did you handle the WM_ERASEBKGND?
cilu at 2007-11-11 4:01:53 >
# 2 Re: CEdit transparency
No, I didn't, and how should I?

I've based this part of my code mainly on this tutorial: http://www.codeproject.com/editctrl/ctrltrans.asp

And they say nothing there about erasing background...

Edit:

I've tried to handle the message you mentioned:

BOOL CEditEx::OnEraseBkgnd(CDC* pDC)
{
RECT rt;
GetWindowRect(&rt);
pDC->FillRect( &rt, &m_brsBkGnd );
return TRUE;
}

But it doesn't change anything.

Edit2:

And actually it isn't about the background, is it? The problem is that the text entered before stays painted, it doesn't disappear. The new text gets painted over it.

Thanks a lot,
Maciej
alav at 2007-11-11 4:02:53 >