I
I
inf1k2019-06-10 23:35:09
C++ / C#
inf1k, 2019-06-10 23:35:09

How to make application scaling high dpi?

In my MFC application, I'm trying to expand a dialog box to full screen, but it expands to more than full screen. If on my laptop (win7) it is still possible to configure, then on a high dpi monitor, it generally turns out to be an orgy. Unfortunately, I can't test on a high dpi monitor. so I want to know what I'm doing wrong.
There is the following method for scaling, but it seems to be useless.

HDC screen = ::GetDC(0);
giDpi = GetDeviceCaps(screen, LOGPIXELSX);

int dpiScale(const int &iSrc)
{
  return MulDiv(iSrc, giDpi, 96);
}

Actually further, in the dialog box, and init I do the following:
CRect rect;
  GetParent()->GetWindowRect(&rect);
  SetWindowPos(NULL, 0, 0, rect.Width() - dpiScale(100), rect.Height() - dpiScale(100), SWP_NOREDRAW);

I found scaling information based on the monitor ( GetDpiForMonitor() ), but the essence is the same there.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question