Exercise 3: Mark the Application as DPI-Aware

In this exercise, you mark the application as DPI-aware to opt out of the DPI virtualization. To do so, first add the DPI-aware manifest entry to the application. This manifest entry tells Windows that the application is DPI-aware, so Windows disables DPI virtualization. Then run the application, compare the UI at the 144 DPI setting to the UI at the 96 DPI setting, and finally jot down any UI issues.

For this exercise, continue using the project file from the previous exercise.

Task 1 - Add the DPI-Aware Manifest Entry to the Application

  1. On the Visual Studio Project menu, click HandsOnLabProperties.
  2. In the HandsOnLab Property Pages dialog box, expand the Configuration Properties, expand the Manifest Tool, and then click Input and Output.
  3. In the right pane, in the Additional Manifest Files text box, type DeclareDPIAware.manifest, as shown in the following screen shot, and then click OK.

    Note:
    Help

    The project files for this module contain a file named DeclareDPIAware.manifest. The following is the file content:

    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
    <asmv3:application>
    <asmv3:windowsSettings xmlns="https://schemas.microsoft.com/SMI/2005/WindowsSettings">
    <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
    </asmv3:application>
    </assembly>

  4. Recompile the application and run the application. The application appears as shown in the following screen shot:

Task 2 - Compare the UI Elements at the 144 DPI Setting to Those at the 96 DPI Setting

The following table shows the UI elements of the application at the 144 DPI setting as compared to those at the 96 DPI setting. Notice that adding the manifest entry to the application disables the DPI virtualization, and thus fixes the blurry issue and keeps the size of the window and buttons the same as those at the 96 DPI setting.

UI element

Appearance at 144 DPI

Size of the window frame

Same

Size of the buttons

Samer

Size of the text

Larger

Clipped text on the buttons

Yes

Clipped text in the window

Yes

Blurry effect

Fixed