-2

I have C++ application which opens other apps with CreateProcessA on Windows 10. These apps could have different settings for DPI Awareness.

So the question is - can I create processes with DPI Awareness set to DPI_AWARENESS_CONTEXT_UNAWARE?

If not - then perhaps I can set DPI_AWARENESS_CONTEXT_UNAWARE for the already created process?

UPD: My application spawns the app and then changes one's position. And if it appears to be another monitor with different DPI then scaled values are supplied.

If the app is DPI awared then after the move completed the dimensions changed according WM_DPICHANGED message values. Spawned apps could have different DPI Aware modes. So idea was to set them one mode and control position and dimensions of all of them with same logic.

htonus
  • 629
  • 1
  • 9
  • 19
  • 3
    Your question isn't clear. DPI awareness is not inherited from the launching process. The apps your process launch will have their DPI awareness set to whatever those apps want. It's not something you should care about or try to change. – Jonathan Potter Jan 30 '19 at 23:15
  • Hi htonus, does the issue solved [here](https://stackoverflow.com/questions/54581535/resolved-how-to-detect-real-screen-resolution-or-scaling-of-the-secondary-moni): detect the resolution of the secondary monitor in the app? – Rita Han Feb 08 '19 at 06:29

1 Answers1

0

If the app does not already have a manifest, you can use SetProcessDpiAwarenessContext to set the awareness. Also check this.

You cannot set the awareness on an existing app unless if injecting a remote thread with CreateRemoteThread, in which case you may cause incompatibilities when forcing something that the app is not aware of.

Michael Chourdakis
  • 10,345
  • 3
  • 42
  • 78
  • CreateRemoteThread will not work, because SetProcessDpiAwarenessContext should be called before the very first window of the target process created. The problem I have is that when my app sends SetWindowPos for the process with proper dimentions (scaled) and the process is DPIawared then it manages to update dimentions by WM_DPICHANGED message. – htonus Jan 30 '19 at 21:39
  • `SetProcessDpiAwarenessContext()` operates on the calling process only, it cannot be used to set dpi awareness for another process. – Remy Lebeau Jan 30 '19 at 22:32
  • @htonus why are you manipulating another process' windows to begin with? What are you trying to accomplish exactly? – Remy Lebeau Jan 30 '19 at 22:33
  • @RemyLebeau who said that this function can operate on a different process? – Michael Chourdakis Jan 30 '19 at 22:36
  • 1
    @Michael it can't, that's the point. But the OP's question implies that he wants to change the DPI setting of another process. – Remy Lebeau Jan 31 '19 at 00:51
  • @RemyLebeau I need to have two windows from different apps be snapped to each other, and when I move one window the second should follow it – htonus Jan 31 '19 at 08:38