0

I am trying to get a window to use the Windows 10 style and have succeeded in making the button itself be in that style (by modifying the executable file's manifest). However, the text is still very pixelated, reminiscent of the windows-classic style:

Windows-10 Style Button With Classic (Low-Resolution) Text

Setup code:

INITCOMMONCONTROLSEX initCommonControls = {
    .dwSize = sizeof(INITCOMMONCONTROLSEX),
    .dwICC = ICC_STANDARD_CLASSES
};
InitCommonControlsEx(&initCommonControls);

Button-create Code:

HWND startButton = CreateWindowExA(0, "BUTTON", "Start",
    WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_VCENTER,
    startButtonX, startButtonY, startButtonWidth, startButtonHeight, hWnd, NULL, hInstance, NULL);

Application manifest (the section sets the visual style):

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"     xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" manifestVersion="1.0">
  <assemblyIdentity
      version="1.0.0.0"
      processorArchitecture="*"
      name="name.name.name"
      type="win32" />
  <description>a program</description>
  <dependency>
  <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*" />
    </dependentAssembly>
  </dependency>
  <asmv3:application>
     <asmv3:windowsSettings xmlns="https://schemas.microsoft.com/SMI/2016/WindowsSettings">
      <dpiAwareness>PerMonitorV2</dpiAwareness>
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>
cpp plus 1
  • 67
  • 9
  • An [mcve] would be nice – David Heffernan Jan 22 '20 at 21:28
  • 1
    It is up to individual controls to decide how they draw themselves when Visual Styles are enabled. Styles can include fonts for drawing text (see [`DrawThemeText()`](https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-drawthemetext)), but it is still up to each control to decide to use it or not. Since you are using a standard Win32 button, you are at the mercy of how Microsoft decides to draw it, unless you use the `BS_OWNERDRAW` style to draw it yourself. There is no magic API to tell a standard button to draw its text one way or another when it is themed by a Visual Style – Remy Lebeau Jan 22 '20 at 22:07
  • 2
    You need to obtain the [message box font info](https://stackoverflow.com/a/35338788/7571258) (`NONCLIENTMETRICS::lfMessageFont`), create a logical font from it and assign it to the button via `WM_SETFONT`. – zett42 Jan 23 '20 at 01:26
  • 1
    When you use a dialog you get the font set in all its controls for you. If you create controls manually you need to tell them what font to use, as @zett42 describes. – Jonathan Potter Jan 23 '20 at 02:06

0 Answers0