Skip to content

[BUG]: SetThreadDpiAwarenessContext not working with COINIT_MULTITHREADED #607

@ReinholdH

Description

@ReinholdH

Windows Version

Windows 11, 24H2,OS Build 26100.3476)

Service Installation Method

GitHub

SDK version, if appropriate

MIDI_Preview1.0.3-preview-11.250228-237

Location

Application using Windows MIDI Services SDK (MIDI 2.0)

Type of bug

Application not working as expected

Steps to reproduce

  • Use a multi resolution monitor environment.
  • Open Notation Composer (as privately provided to @Psychlist1972)
  • Open a file
  • Move the open dialog from the 175% resolution monitor to the 100% resolution monitor

Expected behavior

SetThreadDpiAwarenessContext to work with winrt::init_apartment();
(but not only to work with winrt::init_apartment(winrt::apartment_type::single_threaded);)
or alternatively
Windows MIDI Services work with winrt::init_apartment(winrt::apartment_type::single_threaded);

Additional notes

Notation Software's apps are fully DPI V2 aware. The event WM_DPICHANGED is handled everywhere with appropriate actions to scale for the current used monitor. However, some dialogs like CFileDialog and it's inherited classes do not receive aWM_DPICHANGED. In order to deal with that SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED); is used temporarily to achieve a proper DPI scaling when moving dialogs between monitors of different DPI resolutions.

Windows MIDI Services requires winrt::init_apartment(); where apartment_type::multi_threaded is underneath. winrt::init_apartment(); requires that the complete app uses COINIT_MULTITHREADED throughout.

When setting the complete app to COINIT_MULTITHREADED the call SetThreadDpiAwarenessContextdoes not work any longer and dialogs are not properly scaled. See

Image

This is an example where a dialog was opened on a 175% resolution monitor and moved to a 100% monitor.

Metadata

Metadata

Assignees

Labels

won't-fix-externalThird party / external bug in an app or tech.

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions