Click to See Complete Forum and Search --> : Change backgroung?


Yoh-hei
April 23rd, 1999, 03:17 AM
Hello:
I build a bitmap the code:
int ControlView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CScrollView::OnCreate(lpCreateStruct) == -1)
return -1;
CClientDC dc(this);
CBitmap bit;
CDC memdc;
m_nMaxX=GetSystemMetrics(SM_CXSCREEN);
m_nMaxY=GetSystemMetrics(SM_CYSCREEN);
memdc.CreateCompatibleDC(&dc);
bit.CreateCompatibleBitmap(&dc,m_nMaxX,m_nMaxY);
CBitmap* pOldBitmap=memdc.SelectObject(&bit);
m_hBrush=(HBRUSH)memdc.SelectStockObject(BLACK_BRUSH);
memdc.SelectObject(m_hBrush);
memdc.PatBlt(0,0,m_nMaxX,m_nMaxY,PATCOPY);

}
I want use BLACK_BRUSH brush background.But it's not work.
Why?Who can tell me?
THank you!

April 23rd, 1999, 04:11 AM
Try add windows message handler WM_CTLCOLOR

April 30th, 1999, 05:57 AM
To change your background brush, put the following code
in your view classes precreatewindow method.


BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
if( !CScrollView::PreCreateWindow(cs) )
{
return FALSE;
}

cs.lpszClass = AfxRegisterWndClass( CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 0, ::CreateSolidBrush(RGB(0,0,0)) );
if( cs.lpszClass != NULL )
{
return TRUE;
}
else
{
return FALSE;
}
}