Skip Navigation LinksBCGSoft > Support > Developer Area > Per monitor DPI awareness

Per monitor DPI awareness

Introduction to Per-Monitor (V2) DPI:

The BCGControlBar library provides full support for per-monitor DPI awareness (introduced in Windows 10). All library controls are automatically scaled when the user moves the application frame, dialog, or floating pane to a monitor with a different DPI or changes the current display scale. In addition, the developer can easily add the DPI PM V2 support to the custom controls using both Windows and our APIs.

Specify Per-Monitor (V2) DPI Awareness in your project:

  1. Create a new XML file in your project folder. You can copy this file from one of our examples/samples. The content of the XML file is (MyApp is your application name):
    <?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="5.1.0.0"
        type="win32"
        name="MyApp.exe"/>
        <description>MyApp Application</description>
        <dependency>
        <dependentAssembly>
        <assemblyIdentity
             type="win32"
             name="Microsoft.Windows.Common-Controls"
             version="6.0.0.0"
             publicKeyToken="6595b64144ccf1df"
             language="*"
             processorArchitecture="*"/>
        </dependentAssembly>
        </dependency>
      <asmv3:application>
        <asmv3:windowsSettings>
          <dpiAware 
              xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
              true/PM
          </dpiAware>
          <dpiAwareness 
              xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
              PerMonitorV2, PerMonitor
          </dpiAwareness>
        </asmv3:windowsSettings>
      </asmv3:application>
    </assembly>
    
  2. In the Visual Studio environment, please open the Project Settings, switch to Manifest Tools | Input and Output, and make the following changes:
    • In the Additional Manifest File, enter the path to your XML file created in (1).
    • Set DPI Awareness to None
  3. Add the following initializations in your application's InitInstance source code (add them after the call to CBCGPWinApp::InitInstance):
    globalData.m_bIsDlgWsCaptionStyle = TRUE;
    globalData.m_bIsMiniFrameWsCaptionStyle = TRUE;

Updating the existing application's source code:

  1. Replace globalData.font*** with globalUtils.GetFont***(pWnd).
  2. globalUtils.ScaleByDPI has a new optional parameter, "current window." Please pass a pointer to the currently used window to this method.
  3. CBCGPToolBar::SetSizes and CBCGPToolBar::SetMenuSizes should receive original (non-scaled) sizes.
  4. If your window class has any DPI-specific resources, please reload them in the WM_DPICHANGED or WM_DPICHANGED_AFTERPARENT message handler(s).
  5. If you have a CBCGPProp-derived property with DPI-specific resources, please override the OnDPIChanged method and reload these resources.
  6. If you added icons to CBCGPOutlookBarPane, please reload them in the WM_DPICHANGED message handler (see the BCGPGridExample application).
  7. If you are calling any CBCGPVisualManager methods in your WM_PAINT message handler, we recommend using CBCGPPaintDC instead of CPaintDC.
  8. Pass the pointer to the current window to the CBCGPInfoBoxRenderer constructor.
  9. If you have a custom CBCGPCaptionButton-derived caption button class, please pass a pointer to the parent window to the CBCGPCaptionButton constructor.

Back to the Developer Area