[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to change color of dialog

Posted on 2006-11-30
8
Medium Priority
?
253 Views
Last Modified: 2013-11-20
I have 2 dialogs which are docked to the bottom & left side of my window. These dialogs have a list control & tree control resp. I want to know how to change the color of these dialogs to light blue.
0
Comment
Question by:Anisha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
8 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 1000 total points
ID: 18044660
Trap the WM_ERASEBKGND message

BOOL CMyDlg::OnEraseBkgnd(CDC* pDC)
{
  CRect rc;
  GetClientRect(&rc);
  pDC->FillSolidRect(RGB(0, 0, 128));  //change the values to give the colour you want
  return TRUE;   //IMPORTANT else it will not be changed
}
0
 
LVL 22

Assisted Solution

by:mahesh1402
mahesh1402 earned 1000 total points
ID: 18044784
What AndyAinscow suggested is right but with just a syntax error..

it should be like pDC->FillSolidRect(&rc,RGB(0, 0, 128)); //use &rc to input client rect

BOOL CMyDlg::OnEraseBkgnd(CDC* pDC)
{
  CRect rc;
  GetClientRect(&rc);
  pDC->FillSolidRect(&rc,RGB(0, 0, 128));  //change the values to give the colour you want
  return TRUE;   //IMPORTANT else it will not be changed
}

//OR

BOOL CMyDialog::OnEraseBkgnd(CDC *pDC)
{
  CRect rect;
  GetClientRect(&rect);
  CBrush myBrush(RGB(255,0,0)); // Solid RED for instance
  CBrush *pOld = pDC->SelectObject(&myBrush);
  BOOL bRes = pDC->PatBlt(0, 0, rect.Width(), rect.Height(), PATCOPY);
  pDC->SelectObject(pOld); // Have to restore old brush
  return bRes;
}

OR http://support.microsoft.com/default.aspx?scid=kb;EN-US;q115087

-MAHESH
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 18044832
oops.
0
 
LVL 2

Expert Comment

by:AshvinPatel
ID: 18107262
add a function wm_ctlcolor handlerr to class by right click on theclass name 'add window msg handler'
now modify the code like this

HBRUSH CLASSNAME::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// return MiBrush;      CDialog MiDlg;
      
      
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, CTLCOLOR_DLG);

      if(nCtlColor==CTLCOLOR_DLG )
 return MiBrush;
else
return hbr;
      
}

define the object of the brush as "MiBrush "
write the
line of code in the oninitdialog()

MiBrush.CreateSolidBrush(RGB(236,233,216));

0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 18372952
split
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question