0
votes

I have created a simple propertySheet(CPropertySheet) and a couple of CPropertyPage derived classes.

While running the application, the ProperySheet, Page and tabs are appeared in white color.

I was expecting them to be like normal widow dialog color.

Any clue to make the property sheet, pages background to be like other normal MFC dialogs appears?

I use Visual Studio 2008 MFC without .NET CLR.

3

3 Answers

1
votes

What do you mean 'system color'? Grey (COLOR_BTNFACE) ? What OS are you on? If XP the property sheet should be in COLOR_BTNFACE , Vista/Win7 I don't know what the proper color is. If you don't do anything special, they will show in the system default colors.

0
votes

This is a MFC bug. Use the spy++ monitor your app, you will find your app receives many WM_GETDLGCODE message, and seems enter a dead loop. Yeah, that is the problem.

Microsoft had post a PRB for the problem. please view:PRB: Child CPropertySheet Hangs If Focus Is Switched

In short, add WS_EX_CONTROLPARENT style to your PropertySheet.

   BOOL CMySheet::OnInitDialog()
   {
             ModifyStyleEx (0, WS_EX_CONTROLPARENT);
             return CPropertySheet::OnInitDialog();
   }
0
votes

Process the WM_CTLCOLORDLG message.

case WM_CTLCOLORDLG:
   {
      HDC hdc = (HDC)wParam;
      COLORREF color = GetSysColor(COLOR_3DFACE);
      SetBkColor(hdc, color);
      static HBRUSH brush = CreateSolidBrush(color);
      return (BOOL)brush;
   }