The MFC Ribbon Bar and High DPI?

David Webber 136 Reputation points
2020-08-21T17:39:25.967+00:00

Looking at the MFC Ribbon Bar, there seems to be some facility for responding to High DPI in that one can supply alternative images "for High DPI". And for the application button an alternative High DPI image can be provided.

On this latter topic the docs say:

"Specifies the identifier of the high dots per inch (HDPI) Application button icon. When the application runs on a high DPI monitor, HDPI Image is used instead of Image.

I'm puzzled. My new laptop offers 10 different dpi values from 100% (=96dpi) up to 400%. Presumably nine of these are "High DPI"? How does the apparently single HDPI option on the ribbon bar, handle this?

Dave

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,764 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Darran Rowe 1,041 Reputation points
    2020-08-22T15:59:55.97+00:00

    Basically, anything above 100% (96 DPI) is classed as high DPI. But really that is irrelevant, since high DPI is just about the ability to change DPI settings and have your application respond to that and just look good on displays with DPIs other than 100%.
    But the how this generally works is that for the different DPI settings, the ribbon bar will ask for different image sizes. As an example, the Windows API ribbon bar documentation has the section Image Sizes, this shows the relationship between the DPI and the image size that it asks for when it loads each item. Also note that the list isn't exhaustive, you can calculate the size using (96 dpi width or height) * (current dpi/96). So for 192, this is 32 * (192/96) = 32 * 2 = 64 for the large ribbon icons. If you notice, 192/96 is 2, which is the decimal form of 200%, so you can cache this value.
    So to put it simply, all high DPI does is it enables the control to use different image sizes depending on the current DPI settings.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.