I've noticed something odd with some controls and Windows font scaling. Admittedly, this is an older version of wxWidgets (2.9.5), but it's what I'm stuck working with for the time being.
I've got a bunch of radioboxes. If I manually set the font size to something large and run it, the radioboxes size properly for the larger font size. All the text is shown, etc. That doesn't seem to be a problem with other controls. The menu bar resizes properly, wxTextControls resize, wxButtons resize, etc.
But if I just turn the Windows font size up to 125% or 150%, and run the program, the radioboxes DON'T show all the labels. They're truncated, the radiobox too narrow to contain all the labels. (To be specific: I am not changing the Windows font WHILE the program is executing. I change it, then run the program).
What's the difference between creating a radiobox with the SetFont() set to an arbitrarily large font size, and using a "normal" font size but setting the Windows font size to 150%? Why are all my radioboxes not properly expanding to accommodate the increased size of the selection labels under one case, but are under the other?
And more importantly -- how do I fix it?
Question about Windows Font scaling
Re: Question about Windows Font scaling
Is your application marked as "dpi aware" through the manifest?
I assume you're using sizers and no hardcoded values for position and/or sizes?
2.9.5 is pretty old indeed. I would suggest you make a small test with both 2.9.5 and the latest wx version from GIT. If the latest version fixes it, you should upgrade. There were many improvements related to "High DPI" support over the last few months. The changes in your code should be minimal.
I assume you're using sizers and no hardcoded values for position and/or sizes?
2.9.5 is pretty old indeed. I would suggest you make a small test with both 2.9.5 and the latest wx version from GIT. If the latest version fixes it, you should upgrade. There were many improvements related to "High DPI" support over the last few months. The changes in your code should be minimal.
Use the source, Luke!
Re: Question about Windows Font scaling
Yes, sizers and no hardcoded sizes or positions. That was the root of my confusion, as I just got done overhauling the whole thing to dynamic layouts primarily to support larger fonts.doublemax wrote: ↑Thu Apr 30, 2020 8:05 pm Is your application marked as "dpi aware" through the manifest?
I assume you're using sizers and no hardcoded values for position and/or sizes?
2.9.5 is pretty old indeed. I would suggest you make a small test with both 2.9.5 and the latest wx version from GIT. If the latest version fixes it, you should upgrade. There were many improvements related to "High DPI" support over the last few months. The changes in your code should be minimal.
As to the manifest -- Well, darn. That's going to be problematic, as I'm stuck with this version of the library for the near future (updating further means updating the very old-style event setups) and update our compiler, which is at least on the list.
I'm going to have to create a copy of my library and do some testing where I can't contaminate production code. Fantastic.
I don't suppose there's any way to override Window's increasing the font size, or at least limit it to something that works?
Re: Question about Windows Font scaling
Does this affect only radio buttons? If yes, maybe you can find the patch that fixed this in wxWidgets and apply it to your 2.9.x version. E.g. i found this one, but i'm not sure if it's the correct one for your issue:
https://github.com/wxWidgets/wxWidgets/ ... db97f6ee87
https://github.com/wxWidgets/wxWidgets/ ... db97f6ee87
Use the source, Luke!
-
- Earned some good credits
- Posts: 147
- Joined: Mon Sep 01, 2014 10:14 am
Re: Question about Windows Font scaling
Probably i have a solution:
Declarations:
wxApp::OnOnit():
On my Notebook this scales all wxFonts, but only fonts. So, fonts will be large in small windows on high-resoltion-displays.
Best,
Frank
Declarations:
Code: Select all
#define _DPI_AWARENESS
// The function: SetProcessDPIAware seems to be missing
#ifdef __WXMSW__
typedef BOOL WINAPI (*SetProcessDPIAwareFunc)();
#endif
class clsApp : public wxApp {
private:
void MSWEnableHiDPI()
{
#ifdef __WXMSW__
HMODULE m_user32Dll = LoadLibrary(L"User32.dll");
if(m_user32Dll) {
SetProcessDPIAwareFunc pFunc = (SetProcessDPIAwareFunc)GetProcAddress(m_user32Dll, "SetProcessDPIAware");
if(pFunc) {
pFunc();
}
FreeLibrary(m_user32Dll);
m_user32Dll = NULL;
}
#endif
}
[.YOUR CODE.]
};
Code: Select all
bool clsApp::OnInit() {
#ifdef _DPI_AWARENESS
//--------- DPI-Awareness -------------------------------
MSWEnableHiDPI(); // Enable HiDPI on Windows
#endif
[.YOUR CODE.]
};
On my Notebook this scales all wxFonts, but only fonts. So, fonts will be large in small windows on high-resoltion-displays.
Best,
Frank
Re: Question about Windows Font scaling
Setting DPI awareness is normally not done in code but in the application manifest.
wxWidgets now have, unfortunately not perfect, per monitor DPI awareness support.