Exclude Context Menus from DPI Awareness Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Thu Aug 03, 2017 12:20 pm

Exclude Context Menus from DPI Awareness

Post by Natulux » Tue Jan 09, 2018 2:35 pm

Hey guys,

now that I've learned about DPI Aware(ness) scaling and how to set those settings in a manifest file for Visual Studio (see this thread for more:
viewtopic.php?f=1&t=43968), I discovered new issues with DPI Awareness.
Atm I compile my project with VS2015, which automatically sets DPI Awareness (if enabled), so that my GUI doesnt fill the whole screen (or more even), when the user sets a scaling. But my project also contains a context menu (in this case from a tray icon) and this menu is also scaled back with DPI Awareness. Then again, no other program does that, and if the user zooms in to see better, I do not want my text-based menu to be so small.

Is there a way to EXCLUDE my context menu from DPI Awareness? After all, the awareness is set globally (via manifest) and I wouldn't know how to start with this. I can't turn it off completely, because my GUI needs it.

Any ideas or do you know, where I should start looking?

Greetings
Natu

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3366
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Exclude Context Menus from DPI Awareness

Post by ONEEYEMAN » Tue Jan 09, 2018 3:51 pm

Hi,
You probably better off posting to the wx-dev ML.
Especially if no other program does it....

Just mention you OS and have some screenshots for your application and some other.

Also - keep in mind that the DPI Awareness is not yet finalized - there might still be some changes. But it is better to do that before the next release.

Thank you.

Manolo
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 691
Joined: Mon Apr 30, 2012 11:07 pm

Re: Exclude Context Menus from DPI Awareness

Post by Manolo » Tue Jan 09, 2018 5:43 pm

As Igor said, DPI Awareness in wxWidgets is still a work in development.
See for example this discussion: https://groups.google.com/forum/#!topic ... 0cIJBC92Dg

You can set a font size depending on the current DPI and size (by calling wxGetDisplayPPI and wxDisplaySizeMM). But we aware wx may do its thing too in a near future (wx3.2 ?).

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Thu Aug 03, 2017 12:20 pm

Re: Exclude Context Menus from DPI Awareness

Post by Natulux » Wed Jan 10, 2018 8:10 am

Thank you guys,
I wasn't aware that it is in developement. I had some issues with DPI awareness already, like checkboxes cut off at the top or a sizer not caring about a border size.
Still, there are more and more high DPI displays (like 4k monitor) and I was happy to have at least something.

EDIT:
Do you know of a possibility to increase the size of a context menu as a workaround? I could maybe catch the "WM_DPICHANGED message" myself and react to it.

Thanks for your time anyway.
Natu

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Thu Aug 03, 2017 12:20 pm

Re: Exclude Context Menus from DPI Awareness

Post by Natulux » Wed Jan 10, 2018 10:34 am

I gotta say, I dont really know what it was but I think Ive got a solution here.

I created two manifest, which I add to my project (Add Existing File). I used to include manifest files in the settings via "additional manifest files" before which should do the same, but who knows.
The manifests are:

Compatibility_Manifest.manifest

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
  <application>
    <!-- Windows 10 -->
    <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
    <!-- Windows 8.1 -->
    <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
    <!-- Windows Vista -->
    <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
    <!-- Windows 7 -->
    <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    <!-- Windows 8 -->
    <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
  </application>
</compatibility>
</assembly>
DPI_Manifest.manifest

Code: Select all

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0' xmlns:asmv3='urn:schemas-microsoft-com:asm.v3'>
  <asmv3:application>
    <asmv3:windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
      <!-- fallback for Windows 7 and 8 -->
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
      <!-- falls back to per-monitor if per-monitor v2 is not supported -->
      <!--gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling-->
      <!-- enables GDI DPI scaling -->
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>
Note: GdiScaling did no good for me, so I had it commented out lastly.

Though, the compiler has a complaint:
DPI_Manifest.manifest : manifest authoring warning 81010002: Unrecognized Element "dpiAwareness" in namespace "http://schemas.microsoft.com/SMI/2016/WindowsSettings".
But it doesn't hurt either. And actually, that or compatibility is what helped me scale the menues right.

Additionally, in the settings, I set the following:
Generate Manifest: yes
Embed Manifest: Yes
DPI Awareness: None
Good luck if you run into this issue.

Edit: As far as I can see, I was a little early. The menu itself isnt scaled, but the submenus of that menu are. Strange that. (Win10 only, no different scaling under VM-Win7x64)

Have a great day
Natu

User avatar
rocrail
I live to help wx-kind
I live to help wx-kind
Posts: 174
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: Exclude Context Menus from DPI Awareness

Post by rocrail » Sat May 25, 2019 5:47 am

Hi Natu,

the wx.rc does include the manifest.wx file.
Would it not be better to modify the
⁨include/⁨wx⁩/⁨msw/manifest.wx
file?
Or How can I include my own project dependent manifest?

Any help is very appreciated.
Best regards,
Rob.

Post Reply