Change color of the Form
-
Hi.. I'm using a project whose baseclass is CFORMVIEW.. my question is HOW DO YOU CHANGE the COLOR of the FORM??? Thanks...
OnEraseBackground. Draw the colour you want here instead. Alex
-
OnEraseBackground. Draw the colour you want here instead. Alex
Hi ... Sorry to ask you once again ...but I don't seem to understand your response. Is this OnEraseBackground a windows message handler .. and where should I add such windows message handler (I only saw WM_ERASEBKGND on the CMainFrame)? And what's the command to change the color of the Form? Please, elucidate. Thanks for the help. =)
-
Hi ... Sorry to ask you once again ...but I don't seem to understand your response. Is this OnEraseBackground a windows message handler .. and where should I add such windows message handler (I only saw WM_ERASEBKGND on the CMainFrame)? And what's the command to change the color of the Form? Please, elucidate. Thanks for the help. =)
I've just had a look, and the view *does* have WM_ERASEBKGND. There is no command, this is called whenever the area is erased and you will need to draw the background. Something like this:
CRect rc;
GetClientRect(&rc);pDC->FillSolidRect(&rc, RGB(255,0,0));
//Do not call base methodAlex
-
I've just had a look, and the view *does* have WM_ERASEBKGND. There is no command, this is called whenever the area is erased and you will need to draw the background. Something like this:
CRect rc;
GetClientRect(&rc);pDC->FillSolidRect(&rc, RGB(255,0,0));
//Do not call base methodAlex
-
Hi.. I'm using a project whose baseclass is CFORMVIEW.. my question is HOW DO YOU CHANGE the COLOR of the FORM??? Thanks...
Erasebackground will not completly solve your problem nor do I think it is the prefered method. Usesomething like this: void CMainView::OnPaint() { CMainFrame* pFrame; CPaintDC dc(this); // device context for painting pFrame = (CMainFrame*)GetParentFrame(); CString s="Printing Library Demo Program"; pFrame->SetWindowText(s); RECT rc; CBrush cBr(RGB(255,255,0)); GetClientRect(&rc); dc.FillRect(&rc, &cBr); } then to solve the control background problem use this: HBRUSH CMainView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor); if(nCtlColor==CTLCOLOR_STATIC) { HBRUSH hbr2=CreateSolidBrush(RGB(255,255,0)); pDC->SetBkMode(TRANSPARENT); return hbr2; } return hbr; } Class wizard will make both overrides for you Richard ISS Software Dallas Texas