summaryrefslogtreecommitdiff
path: root/src/drivers/WinAPI
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-08-27 06:59:54 +0000
committerManolo Gouy <Manolo>2016-08-27 06:59:54 +0000
commit0e7ad720d1d37d981b775fcaa6e190b27f702e13 (patch)
treef4a4adb531cc78a8499cf60a102f02472c3d5507 /src/drivers/WinAPI
parent5dbfe413ae8bd6aca1dfa36f79bb1168aaa50823 (diff)
Fix Fl_WinAPI_Window_Driver::border_width_title_bar_height() for displays where true DPI is not 96.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11895 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/WinAPI')
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
index 30109bb31..be0bb5cf6 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
@@ -86,31 +86,39 @@ RECT // frame of the decorated window in screen coordinates
// This factor can be set in Windows 10 by
// "Change the size of text, apps and other items" in display settings.
HDC hdc = GetDC(NULL);
- int hs = GetDeviceCaps(hdc, HORZSIZE);
- int hr = GetDeviceCaps(hdc, HORZRES);
- int px = GetDeviceCaps(hdc, LOGPIXELSX);
- //int dhr = GetDeviceCaps(hdc, DESKTOPHORZRES);
+ //int hs = GetDeviceCaps(hdc, HORZSIZE);
+ int hr = GetDeviceCaps(hdc, HORZRES); // pixels visible to the app
+ //int px = GetDeviceCaps(hdc, LOGPIXELSX);
+#ifndef DESKTOPHORZRES
+#define DESKTOPHORZRES 118
+ /* As of 27 august 2016, the DESKTOPHORZRES flag for GetDeviceCaps()
+ has disappeared from Microsoft online doc, but is quoted in numerous coding examples
+ e.g., https://social.msdn.microsoft.com/Forums/en-US/6acc3b21-23a4-4a00-90b4-968a43e1ccc8/capture-screen-with-high-dpi?forum=vbgeneral
+ It is necessary for the computation of the scaling factor at runtime as done here.
+ */
+#endif
+ int dhr = GetDeviceCaps(hdc, DESKTOPHORZRES); // true number of pixels on display
//int vs = GetDeviceCaps(hdc, VERTSIZE);
//int vr = GetDeviceCaps(hdc, VERTRES);
//int py = GetDeviceCaps(hdc, LOGPIXELSY);
//int dvr = GetDeviceCaps(hdc, DESKTOPVERTRES);
ReleaseDC(NULL, hdc);
- scaling = (hs * px) / (hr * 25.4); scaling = int(scaling * 100 + 0.5)/100.;
+ scaling = dhr/float(hr);
+ scaling = int(scaling * 100 + 0.5)/100.; // round to 2 digits after decimal point
+ //fprintf(LOG,
+ // "HORZSIZE=%d %d, HORZRES=%d %d, LOGPIXELSX=%d %d, DESKTOPHORZRES=%d %d scaling=%f bx=%d bt=%d ",
+ // hs,vs,hr,vr,px,py,dhr,dvr,scaling);fflush(LOG);
}
}
if (need_r) {
GetWindowRect(fl_xid(win), &r);
}
if (pscaling) *pscaling = scaling;
-
+
bx = (r.right - r.left - int(win->w() * scaling))/2;
if (bx < 1) bx = 1;
by = bx;
bt = r.bottom - r.top - int(win->h() * scaling) - 2 * by;
-
- //fprintf(LOG,
- // "HORZSIZE=%d %d, HORZRES=%d %d, LOGPIXELSX=%d %d, DESKTOPHORZRES=%d %d scaling=%f bx=%d bt=%d\n",
- // hs,vs,hr,vr,px,py,dhr,dvr,scaling, bx,bt);fflush(LOG);
}
return r;
}