I was trying to subclass common-control's edit box to display a custom background bitmap.
The brush for drawing is created as such:
Then I override OnCtlColor():
This works but only if I set ES_MULTILINE style for the edit box. For a single line control when I move it quickly off the screen and then back it creates this visual artifact.
I made a small MFC app to illustrate the issue. This is a screenshot of what happens:
![Name: ask_img.png
Views: 53
Size: 2.1 KB]()
So what am I doing wrong?
PS. I tried to override OnEraseBkgnd() to redraw background there (see my sample project) using FillRect() but it still didn't fix the issue.
The brush for drawing is created as such:
Code:
CBitmap bmp1;
CBrush brush1;
VERIFY(bmp1.LoadBitmap(IDB_BITMAP1));
VERIFY(brush1.CreatePatternBrush(&bmp1));Code:
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(pWnd->GetDlgCtrlID() == edt1.GetDlgCtrlID())
{
//Use special brush
hbr = edt1.brush1;
pDC->SetBkMode(TRANSPARENT);
}
// TODO: Return a different brush if the default is not desired
return hbr;
}I made a small MFC app to illustrate the issue. This is a screenshot of what happens:
So what am I doing wrong?
PS. I tried to override OnEraseBkgnd() to redraw background there (see my sample project) using FillRect() but it still didn't fix the issue.