Question to GetContentScaleFactor()

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Herb
Earned a small fee
Earned a small fee
Posts: 15
Joined: Wed Dec 07, 2016 12:26 pm

Question to GetContentScaleFactor()

Post by Herb »

Hello,

on my Win 7 64-bit system I have developed a GUI application. My IDE is codeblocks with TDM-GCC 4.9.2.
The next step is, to also support hiDPI monitors.
Because I do not have such a monitor (at the moment) I tried to simulate this with setting the screen-text-scaling of Win7 to e.g. 150%.
My application has also a manifest file that defines it as "dpiAware".

I compile this application with wxWidgets 3.1.0 and also 3.0.3.
Running the compiled "3.1.0-Exe" the return value of GetContentScaleFactor() is 1.50 (because of the system setting).
But the "3.0.3-Exe" always returns GetContentScaleFactor()= 1.00 although the scaling is set to 150%.

Does someone know what I have to do in order to get also GetContentScaleFactor()= 1.50 with my "3.0.3-Exe".
Thanks for your help in advance.

Best regards
Herb
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 469
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Question to GetContentScaleFactor()

Post by New Pagodi »

I don't think the 3.0.x branch supports dpiawareness. It may not be possible to add it in that branch since the developers like to maintain APi/ABI compatibility. You should be able to get equivalent info using native windows calls like:

Code: Select all

    double scaleFactor = GetContentScaleFactor();

#ifdef __WINDOWS__
#if wxCHECK_VERSION(3, 0, 0) && !wxCHECK_VERSION(3, 1, 0)
    HDC hdcMeasure = ::CreateCompatibleDC(NULL);
    scaleFactor = ::GetDeviceCaps(hdcMeasure, LOGPIXELSX) / 96.0f;
    ::DeleteDC(hdcMeasure);
#endif
#endif // __WINDOWS__
(You'll need to link with gdi32 to make that work). I don't currently have a set of 3.0 libraries, so that should work, but I haven't tested it.
Post Reply