Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMFCButton with Vista Style

I can't seem to get a CMFCButton to be displayed in Vista style in a dialog box application. I'm using VS2008 with MFC Feature Pack.

Here are some steps to reproduce my problem:

  • Create a new MFC Project;
  • Specify a Dialog based project.
  • Add two buttons to the main dialog.
  • Add a variable for each button. Make one of the variables a CButton, the other one a CMFCButton.
  • Compile and run.

test app picture http://img7.imageshack.us/img7/3/testapp.png

As you can see, the CButton has the correct style but the CMFCButton does not.

What I am missing here?

like image 809
djeidot Avatar asked Sep 23 '09 12:09

djeidot


1 Answers

The CMFCButton has the BS_OWNERDRAW style set by default - you can remove it in the OnInitDialog() for your dialog:

mfcButton.ModifyStyle(BS_OWNERDRAW, 0, 0);

However, removing the owner draw style results in many of the methods of CMFCButton being rendered useless (e.g. SetTextColor). You can get the button to render using the current windows theme by setting up the visual manager:

CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

This is done instead of the ModifyStyle above, resulting in buttons that fit the default style but still have the newer rendering features.

like image 134
Steve Beedie Avatar answered Oct 13 '22 19:10

Steve Beedie