Re: Making the clientarea of a Dialog black

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Wouldn't this be a slightly better solution?

HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hBrush = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

switch (nCtlColor)
{
case CTLCOLOR_DLG: hBrush = (HBRUSH)::GetStockObject (WHITE_BRUSH);
break;
}
return (hBrush);
}


AliR.

"Mark Salsbery [MVP]" <MarkSalsbery[MVP]@newsgroup.nospam> wrote in message
news:uTtoDND4HHA.5852@xxxxxxxxxxxxxxxxxxxxxxx
You could add a handler for WM_ERASEBKGND to your dialog class and draw
the background yourself, something like

BOOL CMyDialog::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(&rect);

pDC->FillSolidRect(&rect, RGB(0x00, 0x00, 0x00));

return TRUE;
}

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++


"RAN" <nijenhuis@xxxxxxx> wrote in message
news:1187271414.136873.145480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

How do i give the clientarea of my dialog a different color than grey ?





.



Relevant Pages

  • Re: Making the clientarea of a Dialog black
    ... You could add a handler for WM_ERASEBKGND to your dialog class and draw the ... BOOL CMyDialog::OnEraseBkgnd(CDC* pDC) ... CRect rect; ...
    (microsoft.public.vc.mfc)
  • Re: Hey can we change the color of Dialog Boxes
    ... Or you could also do the painting in OnEraseBkGnd() as below: ... BOOL CMyDlg::OnEraseBkgnd(CDC* pDC) ... CRect rect; ...
    (microsoft.public.vc.mfc)
  • Re: Taskbar Button and SysMenu ?
    ... And I have found that when the rectangles in the ... where would the modify system menu code be written? ... BOOL CSqBmpBkgdBorderDlg::OnInitDialog ... CRect rect; ...
    (microsoft.public.vc.mfc)
  • Re: CRichEditView doublt
    ... HBRUSH CActivitySummaryDetailView::CtlColor(CDC* pDC, UINT ... HBRUSH CEditViewEx::CtlColor(CDC * pDC, UINT nCtlColor) ... But the only problem that I face is changing the background color to ...
    (microsoft.public.vc.mfc)
  • Re: CEdit white
    ... BOOL CEditWhite::OnEraseBkgnd(CDC* pDC) ... following method (m_brBackgroundBrush is a plain white brush), ... CRect rect; ...
    (microsoft.public.vc.mfc)