BCGSoft > Developer Area > Per monitor DPI awareness

How to make your application Per monitor DPI aware

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"?>
        xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
        <description>MyApp Application</description>
        <dpiAware xmlns="">true/PM</dpiAware>
        <dpiAwareness xmlns="">PerMonitorV2, PerMonitor</dpiAwareness>
  2. Open Project Settings, switch to Manifest Tools | Input and Output and make the following changes:
    • In Additional Manifest File enter path to your XML file created in (1).
    • Set DPI Awareness to None
  3. Add the following initializations in your application InitInstance source code (add them after call to CBCGPWinApp::InitInstance):
    • globalData.m_bIsDlgWsCaptionStyle = TRUE;
    • globalData.m_bIsMiniFrameWsCaptionStyle = TRUE;

Updating existing application 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 WM_DPICHANGED or WM_DPICHANGED_AFTERPARENT message handler(s).
  5. If you have a custom (CBCGPProp-derived) property with DPI-specific resources, please override OnDPIChanged method and reload these resources.
  6. If you added icons to CBCGPOutlookBarPane, please reload them in WM_DPICHANGED message handler (see BCGPGridExample application).
  7. If you are calling any CBCGPVisualManager methods in your WM_PAINT message handler, we recommend to use CBCGPPaintDC instead of CPaintDC.
  8. Pass pointer to current window to CBCGPInfoBoxRenderer constructor.
  9. If you have a custom, CBCGPCaptionButton-derived caption button class, please pass a pointer to the parent windows to CBCGPCaptionButton constructor.

Back to the Developer Area