4

I have the following C++ code (native desktop app) that uses Microsoft's Visual Styles API to draw a close button.

RECT r = DetermineButtonRect();
HANDLE h = OpenThemeData(Handle, L"WINDOW");
DrawThemeBackground(h, hdc, WP_CLOSEBUTTON, CBS_NORMAL, &rect, NULL);
CloseThemeData(h);

This works fine in earlier versions of Windows, but in Windows 8, it insists on drawing in the Windows 7 style. This isn't horrible, but it's still frustrating to not have all of the parts of the application use the same visual style. Here's a screenshot of what this looks like:

close buttons

From top to bottom:

  • The standard Windows 8 close button, using Windows 8's minimalist non-Glass appearance.
  • The standard Windows 8 MDI close button (WP_MDICLOSEBUTTON, looking a bit out of place due to its more pronounced gradient, but that's Microsoft's decision.
  • The close button that I'm drawing myself, using a full-blown Aero Glass style (identical appearance to Windows 7) and looking rather out of place as a result.

Is there any way to get the Visual Styles API to draw Windows 8 style (non-Glass) buttons? Or is there a different API I should be using?

Josh Kelley
  • 56,064
  • 19
  • 146
  • 246
  • 1
    It is a Great Unanswered Question. Dabbled at this before, spent a ridiculous amount of time on it today that I shouldn't have. Nothing, nada, zippo. I'm now 98% sure that this can't be done. – Hans Passant Dec 04 '13 at 23:29
  • @HansPassant - Thanks for taking the time to research this. If you post your comment as an answer, I'll accept it. – Josh Kelley Dec 09 '13 at 14:21

1 Answers1

3

Use WP_SMALLCLOSEBUTTON which appears to work on both Windows 7 and Windows 8 with the correct theme.

arserbin3
  • 6,010
  • 8
  • 36
  • 52
Rick Zarr
  • 118
  • 1
  • 8