• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision28274 (tree)
Time2018-07-08 22:12:20
Authorstefankueng

Log Message

Merged revision(s) r28257, r28269, r28272, r28273 from trunk:
* * Extend the high-dpi helper class with the new Win10 APIs * Use the Win10 API's if they're available * Since DPI values for X and Y are always the same, remove the specific methods and leave only a generic method * adjust code to use the new generic methods
* Don't stop monitoring a repository for connection errors: only show the error but keep monitoring.
* Adjust the background icon size for high dpi monitors.
* Scale the buttons and icons for high-dpi screens.

Change Summary

Incremental Difference

--- branches/1.10.x/src/TortoiseUDiff/MainWindow.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseUDiff/MainWindow.cpp (revision 28274)
@@ -115,11 +115,11 @@
115115 {
116116 ::SetWindowPos(m_hWndEdit, HWND_TOP,
117117 rect.left, rect.top,
118- rect.right - rect.left, rect.bottom - rect.top - int(30 * CDPIAware::Instance().ScaleFactorY()),
118+ rect.right - rect.left, rect.bottom - rect.top - int(30 * CDPIAware::Instance().ScaleFactor()),
119119 SWP_SHOWWINDOW);
120120 ::SetWindowPos(m_FindBar, HWND_TOP,
121- rect.left, rect.bottom - int(30 * CDPIAware::Instance().ScaleFactorY()),
122- rect.right - rect.left, int(30 * CDPIAware::Instance().ScaleFactorY()),
121+ rect.left, rect.bottom - int(30 * CDPIAware::Instance().ScaleFactor()),
122+ rect.right - rect.left, int(30 * CDPIAware::Instance().ScaleFactor()),
123123 SWP_SHOWWINDOW);
124124 }
125125 else
@@ -216,11 +216,11 @@
216216 GetClientRect(*this, &rect);
217217 ::SetWindowPos(m_hWndEdit, HWND_TOP,
218218 rect.left, rect.top,
219- rect.right - rect.left, rect.bottom - rect.top - int(30 * CDPIAware::Instance().ScaleFactorY()),
219+ rect.right - rect.left, rect.bottom - rect.top - int(30 * CDPIAware::Instance().ScaleFactor()),
220220 SWP_SHOWWINDOW);
221221 ::SetWindowPos(m_FindBar, HWND_TOP,
222- rect.left, rect.bottom - int(30 * CDPIAware::Instance().ScaleFactorY()),
223- rect.right - rect.left, int(30 * CDPIAware::Instance().ScaleFactorY()),
222+ rect.left, rect.bottom - int(30 * CDPIAware::Instance().ScaleFactor()),
223+ rect.right - rect.left, int(30 * CDPIAware::Instance().ScaleFactor()),
224224 SWP_SHOWWINDOW);
225225 ::SetFocus(m_FindBar);
226226 SendEditor(SCI_SETSELECTIONSTART, 0);
--- branches/1.10.x/src/TortoiseMerge/BaseView.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseMerge/BaseView.cpp (revision 28274)
@@ -496,12 +496,7 @@
496496 m_lfBaseFont.lfCharSet = DEFAULT_CHARSET;
497497 m_lfBaseFont.lfWeight = bBold ? FW_BOLD : FW_NORMAL;
498498 m_lfBaseFont.lfItalic = (BYTE) bItalic;
499- CDC * pDC = GetDC();
500- if (pDC)
501- {
502- m_lfBaseFont.lfHeight = -MulDiv((DWORD)CRegDWORD(L"Software\\TortoiseMerge\\FontSize", 10), GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72);
503- ReleaseDC(pDC);
504- }
499+ m_lfBaseFont.lfHeight = -CDPIAware::Instance().PointsToPixels((DWORD)CRegDWORD(L"Software\\TortoiseMerge\\FontSize", 10));
505500 wcsncpy_s(m_lfBaseFont.lfFaceName, (LPCTSTR)(CString)CRegString(L"Software\\TortoiseMerge\\FontName", L"Consolas"), _countof(m_lfBaseFont.lfFaceName) - 1);
506501 if (!m_apFonts[nIndex]->CreateFontIndirect(&m_lfBaseFont))
507502 {
@@ -1655,10 +1650,10 @@
16551650 {
16561651 // multiline
16571652 bMultiline = true;
1658- pDC->MoveTo(origin.x, yMiddle- CDPIAware::Instance().ScaleY(2));
1659- pDC->LineTo(origin.x+GetCharWidth()-CDPIAware::Instance().ScaleX(1), yMiddle-CDPIAware::Instance().ScaleY(2));
1660- pDC->LineTo(origin.x+GetCharWidth()-CDPIAware::Instance().ScaleX(1), yMiddle+CDPIAware::Instance().ScaleY(2));
1661- pDC->LineTo(origin.x, yMiddle+ CDPIAware::Instance().ScaleY(2));
1653+ pDC->MoveTo(origin.x, yMiddle- CDPIAware::Instance().Scale(2));
1654+ pDC->LineTo(origin.x+GetCharWidth()-CDPIAware::Instance().Scale(1), yMiddle-CDPIAware::Instance().Scale(2));
1655+ pDC->LineTo(origin.x+GetCharWidth()-CDPIAware::Instance().Scale(1), yMiddle+CDPIAware::Instance().Scale(2));
1656+ pDC->LineTo(origin.x, yMiddle+ CDPIAware::Instance().Scale(2));
16621657 }
16631658 else if (GetLineLength(nLineIndex) == 0)
16641659 bMultiline = true;
@@ -1673,32 +1668,32 @@
16731668 case EOL_AUTOLINE:
16741669 case EOL_CRLF:
16751670 // arrow from top to middle+2, then left
1676- pDC->MoveTo(origin.x+GetCharWidth()-CDPIAware::Instance().ScaleX(1), rc.top+ CDPIAware::Instance().ScaleY(1));
1677- pDC->LineTo(origin.x+GetCharWidth()-CDPIAware::Instance().ScaleX(1), yMiddle);
1671+ pDC->MoveTo(origin.x+GetCharWidth()-CDPIAware::Instance().Scale(1), rc.top+ CDPIAware::Instance().Scale(1));
1672+ pDC->LineTo(origin.x+GetCharWidth()-CDPIAware::Instance().Scale(1), yMiddle);
16781673 case EOL_CR:
16791674 // arrow from right to left
1680- pDC->MoveTo(origin.x+GetCharWidth()-CDPIAware::Instance().ScaleX(1), yMiddle);
1675+ pDC->MoveTo(origin.x+GetCharWidth()-CDPIAware::Instance().Scale(1), yMiddle);
16811676 pDC->LineTo(origin.x, yMiddle);
1682- pDC->LineTo(origin.x+CDPIAware::Instance().ScaleX(4), yMiddle+CDPIAware::Instance().ScaleY(4));
1677+ pDC->LineTo(origin.x+CDPIAware::Instance().Scale(4), yMiddle+CDPIAware::Instance().Scale(4));
16831678 pDC->MoveTo(origin.x, yMiddle);
1684- pDC->LineTo(origin.x+CDPIAware::Instance().ScaleX(4), yMiddle-CDPIAware::Instance().ScaleY(4));
1679+ pDC->LineTo(origin.x+CDPIAware::Instance().Scale(4), yMiddle-CDPIAware::Instance().Scale(4));
16851680 break;
16861681 case EOL_LFCR:
16871682 // from right-upper to left then down
1688- pDC->MoveTo(origin.x+GetCharWidth()-CDPIAware::Instance().ScaleX(1), yMiddle-CDPIAware::Instance().ScaleY(2));
1689- pDC->LineTo(xMiddle, yMiddle-CDPIAware::Instance().ScaleY(2));
1690- pDC->LineTo(xMiddle, rc.bottom-CDPIAware::Instance().ScaleY(1));
1691- pDC->LineTo(xMiddle+CDPIAware::Instance().ScaleX(4), rc.bottom-CDPIAware::Instance().ScaleY(5));
1692- pDC->MoveTo(xMiddle, rc.bottom-CDPIAware::Instance().ScaleY(1));
1693- pDC->LineTo(xMiddle-CDPIAware::Instance().ScaleX(4), rc.bottom-CDPIAware::Instance().ScaleY(5));
1683+ pDC->MoveTo(origin.x+GetCharWidth()-CDPIAware::Instance().Scale(1), yMiddle-CDPIAware::Instance().Scale(2));
1684+ pDC->LineTo(xMiddle, yMiddle-CDPIAware::Instance().Scale(2));
1685+ pDC->LineTo(xMiddle, rc.bottom-CDPIAware::Instance().Scale(1));
1686+ pDC->LineTo(xMiddle+CDPIAware::Instance().Scale(4), rc.bottom-CDPIAware::Instance().Scale(5));
1687+ pDC->MoveTo(xMiddle, rc.bottom-CDPIAware::Instance().Scale(1));
1688+ pDC->LineTo(xMiddle-CDPIAware::Instance().Scale(4), rc.bottom-CDPIAware::Instance().Scale(5));
16941689 break;
16951690 case EOL_LF:
16961691 // arrow from top to bottom
16971692 pDC->MoveTo(xMiddle, rc.top);
1698- pDC->LineTo(xMiddle, rc.bottom-CDPIAware::Instance().ScaleY(1));
1699- pDC->LineTo(xMiddle+CDPIAware::Instance().ScaleX(4), rc.bottom-CDPIAware::Instance().ScaleY(5));
1700- pDC->MoveTo(xMiddle, rc.bottom-CDPIAware::Instance().ScaleY(1));
1701- pDC->LineTo(xMiddle-CDPIAware::Instance().ScaleX(4), rc.bottom-CDPIAware::Instance().ScaleY(5));
1693+ pDC->LineTo(xMiddle, rc.bottom-CDPIAware::Instance().Scale(1));
1694+ pDC->LineTo(xMiddle+CDPIAware::Instance().Scale(4), rc.bottom-CDPIAware::Instance().Scale(5));
1695+ pDC->MoveTo(xMiddle, rc.bottom-CDPIAware::Instance().Scale(1));
1696+ pDC->LineTo(xMiddle-CDPIAware::Instance().Scale(4), rc.bottom-CDPIAware::Instance().Scale(5));
17021697 break;
17031698 case EOL_FF: // Form Feed, U+000C
17041699 case EOL_NEL: // Next Line, U+0085
@@ -2070,11 +2065,11 @@
20702065 if ((xposreal > 0) || (nSpaces > 0))
20712066 {
20722067 CPen * oldPen = pDC->SelectObject(&pen);
2073- pDC->MoveTo(xposreal + rc.left + CDPIAware::Instance().ScaleX(2), y);
2074- pDC->LineTo((xpos + nSpaces * GetCharWidth()) + rc.left - CDPIAware::Instance().ScaleX(2), y);
2075- pDC->LineTo((xpos + nSpaces * GetCharWidth()) + rc.left - CDPIAware::Instance().ScaleX(6), y - CDPIAware::Instance().ScaleY(4));
2076- pDC->MoveTo((xpos + nSpaces * GetCharWidth()) + rc.left - CDPIAware::Instance().ScaleX(2), y);
2077- pDC->LineTo((xpos + nSpaces * GetCharWidth()) + rc.left - CDPIAware::Instance().ScaleX(6), y + CDPIAware::Instance().ScaleY(4));
2068+ pDC->MoveTo(xposreal + rc.left + CDPIAware::Instance().Scale(2), y);
2069+ pDC->LineTo((xpos + nSpaces * GetCharWidth()) + rc.left - CDPIAware::Instance().Scale(2), y);
2070+ pDC->LineTo((xpos + nSpaces * GetCharWidth()) + rc.left - CDPIAware::Instance().Scale(6), y - CDPIAware::Instance().Scale(4));
2071+ pDC->MoveTo((xpos + nSpaces * GetCharWidth()) + rc.left - CDPIAware::Instance().Scale(2), y);
2072+ pDC->LineTo((xpos + nSpaces * GetCharWidth()) + rc.left - CDPIAware::Instance().Scale(6), y + CDPIAware::Instance().Scale(4));
20782073 pDC->SelectObject(oldPen);
20792074 }
20802075 }
@@ -2088,8 +2083,8 @@
20882083 pLastSpace = pszChars + 1;
20892084 if (xpos >= 0)
20902085 {
2091- const int cxWhitespace = CDPIAware::Instance().ScaleX(2);
2092- const int cyWhitespace = CDPIAware::Instance().ScaleY(2);
2086+ const int cxWhitespace = CDPIAware::Instance().Scale(2);
2087+ const int cyWhitespace = CDPIAware::Instance().Scale(2);
20932088 // draw 2-logical pixel rectangle, like Scintilla editor.
20942089 pDC->FillSolidRect(xpos + rc.left + GetCharWidth() / 2 - cxWhitespace/2, y,
20952090 cxWhitespace, cyWhitespace, m_WhiteSpaceFg);
--- branches/1.10.x/src/TortoiseProc/LogDialog/LogDlg.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/LogDialog/LogDlg.cpp (revision 28274)
@@ -7739,8 +7739,8 @@
77397739 #define MONITORMODE_TOOLBARBUTTONCOUNT 10
77407740 TBBUTTON tbb[MONITORMODE_TOOLBARBUTTONCOUNT] = { 0 };
77417741 // create an image list containing the icons for the toolbar
7742- const int iconSizeX = int(24 * CDPIAware::Instance().ScaleFactorX());
7743- const int iconSizeY = int(24 * CDPIAware::Instance().ScaleFactorX());
7742+ const int iconSizeX = int(24 * CDPIAware::Instance().ScaleFactor());
7743+ const int iconSizeY = int(24 * CDPIAware::Instance().ScaleFactor());
77447744 if (!m_toolbarImages.Create(iconSizeX, iconSizeY, ILC_COLOR32 | ILC_MASK, MONITORMODE_TOOLBARBUTTONCOUNT, 4))
77457745 return false;
77467746 auto iString = ::SendMessage(m_hwndToolbar, TB_ADDSTRING,
@@ -8733,8 +8733,7 @@
87338733 {
87348734 if ((SVN_ERROR_IN_CATEGORY(SVNError->apr_err, SVN_ERR_AUTHN_CATEGORY_START)) ||
87358735 (SVN_ERROR_IN_CATEGORY(SVNError->apr_err, SVN_ERR_AUTHZ_CATEGORY_START)) ||
8736- (SVNError->apr_err == SVN_ERR_RA_DAV_FORBIDDEN) ||
8737- (SVNError->apr_err == SVN_ERR_RA_CANNOT_CREATE_SESSION))
8736+ (SVNError->apr_err == SVN_ERR_RA_DAV_FORBIDDEN))
87388737 {
87398738 item.authfailed = true;
87408739 }
@@ -8754,7 +8753,6 @@
87548753 if ((SVN_ERROR_IN_CATEGORY(SVNError->apr_err, SVN_ERR_AUTHN_CATEGORY_START)) ||
87558754 (SVN_ERROR_IN_CATEGORY(SVNError->apr_err, SVN_ERR_AUTHZ_CATEGORY_START)) ||
87568755 (SVNError->apr_err == SVN_ERR_RA_DAV_FORBIDDEN) ||
8757- (SVNError->apr_err == SVN_ERR_RA_CANNOT_CREATE_SESSION) ||
87588756 (SVNError->apr_err == SVN_ERR_WC_NOT_WORKING_COPY))
87598757 {
87608758 item.authfailed = true;
--- branches/1.10.x/src/TortoiseProc/RepositoryBar.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/RepositoryBar.cpp (revision 28274)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2017 - TortoiseSVN
3+// Copyright (C) 2003-2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -25,6 +25,7 @@
2525 #include "SVNHelpers.h"
2626 #include "WaitCursorEx.h"
2727 #include "CommonAppUtils.h"
28+#include "DPIAware.h"
2829
2930 #define IDC_URL_COMBO 10000
3031 #define IDC_REVISION_BTN 10001
@@ -100,9 +101,11 @@
100101 rbbi.fMask |= RBBS_CHILDEDGE;
101102 int bandpos = 0;
102103 // Create the "Back" button control to be added
103- rect = CRect(0, 0, 24, 24);
104+ auto size = CDPIAware::Instance().Scale(24);
105+ auto iconSize = GetSystemMetrics(SM_CXSMICON);
106+ rect = CRect(0, 0, size, size);
104107 m_btnBack.Create(L"BACK", WS_CHILD | WS_TABSTOP | BS_PUSHBUTTON | BS_ICON, rect, this, IDC_BACK_BTN);
105- m_btnBack.SetImage(CCommonAppUtils::LoadIconEx(IDI_BACKWARD, 16, 16, LR_DEFAULTCOLOR));
108+ m_btnBack.SetImage(CCommonAppUtils::LoadIconEx(IDI_BACKWARD, iconSize, iconSize, LR_DEFAULTCOLOR));
106109 m_btnBack.SetWindowText(L"");
107110 m_btnBack.Invalidate();
108111 rbbi.lpText = L"";
@@ -115,9 +118,9 @@
115118 if (!InsertBand(bandpos++, &rbbi))
116119 return false;
117120 // Create the "Forward" button control to be added
118- rect = CRect(0, 0, 24, 24);
121+ rect = CRect(0, 0, size, size);
119122 m_btnForward.Create(L"FORWARD", WS_CHILD | WS_TABSTOP | BS_PUSHBUTTON | BS_ICON, rect, this, IDC_FORWARD_BTN);
120- m_btnForward.SetImage(CCommonAppUtils::LoadIconEx(IDI_FORWARD, 16, 16, LR_DEFAULTCOLOR));
123+ m_btnForward.SetImage(CCommonAppUtils::LoadIconEx(IDI_FORWARD, iconSize, iconSize, LR_DEFAULTCOLOR));
121124 m_btnForward.SetWindowText(L"");
122125 m_btnForward.Invalidate();
123126 rbbi.lpText = L"";
@@ -131,7 +134,7 @@
131134 return false;
132135
133136 // Create the "URL" combo box control to be added
134- rect = CRect(0, 0, 100, 400);
137+ rect = CRect(0, 0, CDPIAware::Instance().Scale(100), CDPIAware::Instance().Scale(400));
135138 m_cbxUrl.Create(WS_CHILD | WS_TABSTOP | CBS_DROPDOWN, rect, this, IDC_URL_COMBO);
136139 m_cbxUrl.SetURLHistory(true, false);
137140 m_cbxUrl.SetFont(font);
@@ -143,18 +146,18 @@
143146 rbbi.clrBack = ::GetSysColor(COLOR_BTNFACE);
144147 rbbi.cx = rect.Width();
145148 rbbi.cxMinChild = rect.Width();
146- rbbi.cyMinChild = m_cbxUrl.GetItemHeight(-1) + 10;
149+ rbbi.cyMinChild = m_cbxUrl.GetItemHeight(-1) + CDPIAware::Instance().Scale(10);
147150 if (!InsertBand(bandpos++, &rbbi))
148151 return false;
149152
150153 // Reposition the combobox for correct redrawing
151154 m_cbxUrl.GetWindowRect(rect);
152- m_cbxUrl.MoveWindow(rect.left, rect.top, rect.Width(), 300);
155+ m_cbxUrl.MoveWindow(rect.left, rect.top, rect.Width(), CDPIAware::Instance().Scale(300));
153156
154157 // Create the "Up" button control to be added
155- rect = CRect(0, 0, 24, m_cbxUrl.GetItemHeight(-1) + 8);
158+ rect = CRect(0, 0, size, m_cbxUrl.GetItemHeight(-1) + CDPIAware::Instance().Scale(8));
156159 m_btnUp.Create(L"UP", WS_CHILD | WS_TABSTOP | BS_PUSHBUTTON | BS_ICON, rect, this, IDC_UP_BTN);
157- m_btnUp.SetImage(CCommonAppUtils::LoadIconEx(IDI_UP, 16, 16, LR_DEFAULTCOLOR));
160+ m_btnUp.SetImage(CCommonAppUtils::LoadIconEx(IDI_UP, iconSize, iconSize, LR_DEFAULTCOLOR));
158161 m_btnUp.SetWindowText(L"");
159162 m_btnUp.Invalidate();
160163 rbbi.lpText = L"";
@@ -168,7 +171,7 @@
168171 return false;
169172
170173 // Create the "Revision" button control to be added
171- rect = CRect(0, 0, 60, m_cbxUrl.GetItemHeight(-1) + 10);
174+ rect = CRect(0, 0, CDPIAware::Instance().Scale(60), m_cbxUrl.GetItemHeight(-1) + CDPIAware::Instance().Scale(10));
172175 m_btnRevision.Create(L"HEAD", WS_CHILD | WS_TABSTOP | BS_PUSHBUTTON, rect, this, IDC_REVISION_BTN);
173176 m_btnRevision.SetFont(font);
174177 temp.LoadString(IDS_REPO_BROWSEREV);
--- branches/1.10.x/src/TortoiseProc/AppUtils.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/AppUtils.cpp (revision 28274)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2017 - TortoiseSVN
3+// Copyright (C) 2003-2018 - TortoiseSVN
44 // Copyright (C) 2015 - TortoiseGit
55
66 // This program is free software; you can redistribute it and/or
@@ -38,6 +38,7 @@
3838 #include "SmartHandle.h"
3939 #include "SVNExternals.h"
4040 #include "CmdLineParser.h"
41+#include "../Utils/DPIAware.h"
4142
4243
4344 bool CAppUtils::GetMimeType(const CTSVNPath& file, CString& mimetype, const SVNRev& rev /*= SVNRev::REV_WC*/)
@@ -602,9 +603,7 @@
602603 void CAppUtils::CreateFontForLogs(CFont& fontToCreate)
603604 {
604605 LOGFONT logFont;
605- HDC hScreenDC = ::GetDC(NULL);
606- logFont.lfHeight = -MulDiv(GetLogFontSize(), GetDeviceCaps(hScreenDC, LOGPIXELSY), 72);
607- ::ReleaseDC(NULL, hScreenDC);
606+ logFont.lfHeight = -CDPIAware::Instance().PointsToPixels(GetLogFontSize());
608607 logFont.lfWidth = 0;
609608 logFont.lfEscapement = 0;
610609 logFont.lfOrientation = 0;
--- branches/1.10.x/src/TortoiseProc/RevisionGraph/RevisionGraphDlgDraw.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/RevisionGraph/RevisionGraphDlgDraw.cpp (revision 28274)
@@ -56,9 +56,7 @@
5656 m_lfBaseFont.lfWeight = bBold ? FW_BOLD : FW_NORMAL;
5757 m_lfBaseFont.lfItalic = (BYTE) bItalic;
5858 m_lfBaseFont.lfStrikeOut = (BYTE) FALSE;
59- CDC * pDC = GetDC();
60- m_lfBaseFont.lfHeight = -MulDiv(m_nFontSize, GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72);
61- ReleaseDC(pDC);
59+ m_lfBaseFont.lfHeight = -CDPIAware::Instance().PointsToPixels(m_nFontSize);
6260 // use the empty font name, so GDI takes the first font which matches
6361 // the specs. Maybe this will help render chinese/japanese chars correctly.
6462 wcsncpy_s(m_lfBaseFont.lfFaceName, L"MS Shell Dlg 2", _countof(m_lfBaseFont.lfFaceName) - 1);
@@ -103,7 +101,7 @@
103101
104102 void CRevisionGraphWnd::ClearVisibleGlyphs (const CRect& rect)
105103 {
106- float glyphSize = CDPIAware::Instance().ScaleX(GLYPH_SIZE) * m_fZoomFactor;
104+ float glyphSize = CDPIAware::Instance().Scale(GLYPH_SIZE) * m_fZoomFactor;
107105
108106 CSyncPointer<CRevisionGraphState::TVisibleGlyphs>
109107 visibleGlyphs (m_state.GetVisibleGlyphs());
@@ -140,7 +138,7 @@
140138 {
141139 enum {POINT_COUNT = 8};
142140
143- float radius = CDPIAware::Instance().ScaleX(CORNER_SIZE) * m_fZoomFactor;
141+ float radius = CDPIAware::Instance().Scale(CORNER_SIZE) * m_fZoomFactor;
144142 PointF points[POINT_COUNT];
145143 CutawayPoints (rect, radius, points);
146144
@@ -174,7 +172,7 @@
174172
175173 // show left & right edges of low boxes as "<===>"
176174
177- float minCutAway = min (CDPIAware::Instance().ScaleX(CORNER_SIZE) * m_fZoomFactor, rect.Height / 2);
175+ float minCutAway = min (CDPIAware::Instance().Scale(CORNER_SIZE) * m_fZoomFactor, rect.Height / 2);
178176
179177 // larger boxes: remove 25% of the shorter side
180178
@@ -426,7 +424,7 @@
426424
427425 // expand it just a little to make it look nicer
428426
429- cover.InflateRect (CDPIAware::Instance().ScaleX(10), CDPIAware::Instance().ScaleY(2), CDPIAware::Instance().ScaleX(10), CDPIAware::Instance().ScaleY(2));
427+ cover.InflateRect (CDPIAware::Instance().Scale(10), CDPIAware::Instance().Scale(2), CDPIAware::Instance().Scale(10), CDPIAware::Instance().Scale(2));
430428
431429 // and now, transfrom it
432430
@@ -484,7 +482,7 @@
484482 , const Color& darkColor
485483 , const Color& penColor)
486484 {
487- float squareSize = CDPIAware::Instance().ScaleX(MARKER_SIZE) * m_fZoomFactor;
485+ float squareSize = CDPIAware::Instance().Scale(MARKER_SIZE) * m_fZoomFactor;
488486
489487 PointF leftBottom (leftTop.X, leftTop.Y + squareSize);
490488 RectF square (leftTop, SizeF (squareSize, squareSize));
@@ -520,11 +518,11 @@
520518
521519 // bitmap source area
522520
523- REAL x = ((REAL)position + (REAL)glyph) * CDPIAware::Instance().ScaleX(GLYPH_BITMAP_SIZE);
521+ REAL x = ((REAL)position + (REAL)glyph) * CDPIAware::Instance().Scale(GLYPH_BITMAP_SIZE);
524522
525523 // screen target area
526524
527- float glyphSize = CDPIAware::Instance().ScaleX(GLYPH_SIZE) * m_fZoomFactor;
525+ float glyphSize = CDPIAware::Instance().Scale(GLYPH_SIZE) * m_fZoomFactor;
528526 RectF target (leftTop, SizeF (glyphSize, glyphSize));
529527
530528 // scaled copy
@@ -533,7 +531,7 @@
533531 {
534532 graphics.graphics->DrawImage ( glyphs
535533 , target
536- , x, 0.0f, (REAL)CDPIAware::Instance().ScaleX(GLYPH_BITMAP_SIZE), (REAL)CDPIAware::Instance().ScaleY(GLYPH_BITMAP_SIZE)
534+ , x, 0.0f, (REAL)CDPIAware::Instance().Scale(GLYPH_BITMAP_SIZE), (REAL)CDPIAware::Instance().Scale(GLYPH_BITMAP_SIZE)
537535 , UnitPixel, NULL, NULL, NULL);
538536 }
539537 else if (graphics.pSVG)
@@ -589,7 +587,7 @@
589587 CSyncPointer<CRevisionGraphState::TVisibleGlyphs>
590588 visibleGlyphs (m_state.GetVisibleGlyphs());
591589
592- float squareSize = CDPIAware::Instance().ScaleX(GLYPH_SIZE) * m_fZoomFactor;
590+ float squareSize = CDPIAware::Instance().Scale(GLYPH_SIZE) * m_fZoomFactor;
593591 if (glyph2 == NoGlyph)
594592 {
595593 PointF leftTop (center.X - 0.5f * squareSize, center.Y - 0.5f * squareSize);
@@ -755,7 +753,7 @@
755753 , int colorIndex )
756754 {
757755 // marker size
758- float squareSize = CDPIAware::Instance().ScaleX(MARKER_SIZE) * m_fZoomFactor;
756+ float squareSize = CDPIAware::Instance().Scale(MARKER_SIZE) * m_fZoomFactor;
759757 float squareDist = min ( (noderect.Height - squareSize) / 2
760758 , squareSize / 2);
761759
@@ -1017,7 +1015,7 @@
10171015 if ((m_hoverIndex != NO_INDEX) || (m_hoverGlyphs != 0))
10181016 {
10191017 index_t nodeIndex = m_hoverIndex == NO_INDEX
1020- ? GetHitNode (point, CSize (CDPIAware::Instance().ScaleX(GLYPH_SIZE), CDPIAware::Instance().ScaleY(GLYPH_SIZE) / 2))
1018+ ? GetHitNode (point, CSize (CDPIAware::Instance().Scale(GLYPH_SIZE), CDPIAware::Instance().Scale(GLYPH_SIZE) / 2))
10211019 : m_hoverIndex;
10221020
10231021 if (nodeIndex >= nodeList->GetCount())
--- branches/1.10.x/src/TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp (revision 28274)
@@ -70,8 +70,8 @@
7070 float origZoom = m_fZoomFactor;
7171
7272 CRect clientRect = GetClientRect();
73- CSize preViewSize (max (CDPIAware::Instance().ScaleX(REVGRAPH_PREVIEW_WIDTH), clientRect.Width() / 4)
74- ,max (CDPIAware::Instance().ScaleY(REVGRAPH_PREVIEW_HEIGHT), clientRect.Height() / 4));
73+ CSize preViewSize (max (CDPIAware::Instance().Scale(REVGRAPH_PREVIEW_WIDTH), clientRect.Width() / 4)
74+ ,max (CDPIAware::Instance().Scale(REVGRAPH_PREVIEW_HEIGHT), clientRect.Height() / 4));
7575
7676 // zoom the graph so that it is completely visible in the window
7777 CRect graphRect = GetGraphRect();
--- branches/1.10.x/src/TortoiseProc/RevisionGraph/StandardNodeSizeAssignment.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/RevisionGraph/StandardNodeSizeAssignment.cpp (revision 28274)
@@ -58,13 +58,13 @@
5858 || ( node->previousInBranch->node->GetPath()
5959 != node->node->GetPath());
6060
61- int height = CDPIAware::Instance().ScaleY(21);
61+ int height = CDPIAware::Instance().Scale(21);
6262 if (node->requiresPath)
6363 {
6464 size_t visibleElementCount = node->node->GetPath().GetDepth()
6565 - node->skipStartPathElements
6666 - node->skipTailPathElements;
67- height += (int)(CDPIAware::Instance().ScaleY(3) + visibleElementCount * 16);
67+ height += (int)(CDPIAware::Instance().Scale(3) + visibleElementCount * 16);
6868 }
6969
7070 // shift (root) nodes down, if their source has been folded
@@ -74,16 +74,16 @@
7474 int shift = (state & ( CGraphNodeStates::COLLAPSED_ABOVE
7575 | CGraphNodeStates::SPLIT_ABOVE)) == 0
7676 ? 0
77- : CDPIAware::Instance().ScaleY(6);
77+ : CDPIAware::Instance().Scale(6);
7878
7979 int extension = (state & ( CGraphNodeStates::COLLAPSED_BELOW
8080 | CGraphNodeStates::SPLIT_BELOW)) == 0
8181 ? 0
82- : CDPIAware::Instance().ScaleY(6);
82+ : CDPIAware::Instance().Scale(6);
8383
8484 // set result
8585
86- node->requiredSize = CSize (CDPIAware::Instance().ScaleX(150), height + extension + shift);
87- node->rect = CRect (0, shift, CDPIAware::Instance().ScaleX(150), height + shift);
86+ node->requiredSize = CSize (CDPIAware::Instance().Scale(150), height + extension + shift);
87+ node->rect = CRect (0, shift, CDPIAware::Instance().Scale(150), height + shift);
8888 }
8989 }
--- branches/1.10.x/src/TortoiseProc/RevisionGraph/RevisionGraphDlg.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/RevisionGraph/RevisionGraphDlg.cpp (revision 28274)
@@ -148,24 +148,24 @@
148148 // that's not faster. So loading it again is what we do.
149149 cBitmap.Attach(LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_REVGRAPHBAR),
150150 IMAGE_BITMAP,
151- CDPIAware::Instance().ScaleX(bmBitmap.bmWidth),
152- CDPIAware::Instance().ScaleY(bmBitmap.bmHeight),
151+ CDPIAware::Instance().Scale(bmBitmap.bmWidth),
152+ CDPIAware::Instance().Scale(bmBitmap.bmHeight),
153153 LR_CREATEDIBSECTION));
154154 cBitmap.GetBitmap(&bmBitmap);
155155
156156
157157 CSize cSize(bmBitmap.bmWidth, bmBitmap.bmHeight);
158- int nNbBtn = cSize.cx/ CDPIAware::Instance().ScaleX(20);
158+ int nNbBtn = cSize.cx/ CDPIAware::Instance().Scale(20);
159159 RGBTRIPLE * rgb = (RGBTRIPLE*)(bmBitmap.bmBits);
160160 COLORREF rgbMask = RGB(rgb[0].rgbtRed, rgb[0].rgbtGreen, rgb[0].rgbtBlue);
161161
162- cImageList.Create(CDPIAware::Instance().ScaleX(20), cSize.cy, ILC_COLOR32|ILC_MASK, nNbBtn, 0);
162+ cImageList.Create(CDPIAware::Instance().Scale(20), cSize.cy, ILC_COLOR32|ILC_MASK, nNbBtn, 0);
163163 cImageList.Add(&cBitmap, rgbMask);
164164 // set the sizes of the button and images:
165165 // note: buttonX must be 7 pixels more than imageX, and buttonY must be 6 pixels more than imageY.
166166 // See the source of SetSizes().
167- m_ToolBar.SetSizes(CSize(CDPIAware::Instance().ScaleX(27), CDPIAware::Instance().ScaleY(26)),
168- CSize(CDPIAware::Instance().ScaleX(20), CDPIAware::Instance().ScaleY(20)));
167+ m_ToolBar.SetSizes(CSize(CDPIAware::Instance().Scale(27), CDPIAware::Instance().Scale(26)),
168+ CSize(CDPIAware::Instance().Scale(20), CDPIAware::Instance().Scale(20)));
169169 m_ToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)cImageList.m_hImageList);
170170 cImageList.Detach();
171171 cBitmap.Detach();
@@ -173,7 +173,7 @@
173173
174174 RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
175175
176-#define SNAP_WIDTH CDPIAware::Instance().ScaleX(60) //the width of the combo box
176+#define SNAP_WIDTH CDPIAware::Instance().Scale(60) //the width of the combo box
177177 // set up the ComboBox control as a snap mode select box
178178 // First get the index of the placeholders position in the toolbar
179179 int zoomComboIndex = 0;
@@ -186,8 +186,8 @@
186186 m_ToolBar.GetItemRect(zoomComboIndex, &rect);
187187
188188 // expand the rectangle to allow the combo box room to drop down
189- rect.top+= CDPIAware::Instance().ScaleY(3);
190- rect.bottom += CDPIAware::Instance().ScaleY(200);
189+ rect.top+= CDPIAware::Instance().Scale(3);
190+ rect.bottom += CDPIAware::Instance().Scale(200);
191191
192192 // then create the combo box and show it
193193 if (!m_ToolBar.m_ZoomCombo.CreateEx(WS_EX_RIGHT, WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL|CBS_DROPDOWN,
@@ -441,7 +441,7 @@
441441 float horzfact = (windowRect.Width() - 4.0f)/(4.0f + graphRect.Width());
442442 float vertfact = (windowRect.Height() - 4.0f)/(4.0f + graphRect.Height());
443443 if ((horzfact < vertfact) && (horzfact < MAX_ZOOM))
444- vertfact = (windowRect.Height() - CDPIAware::Instance().ScaleY(20))/(4.0f + graphRect.Height());
444+ vertfact = (windowRect.Height() - CDPIAware::Instance().Scale(20))/(4.0f + graphRect.Height());
445445
446446 DoZoom (min (MAX_ZOOM, vertfact));
447447 }
@@ -455,7 +455,7 @@
455455 float horzfact = (windowRect.Width() - 4.0f)/(4.0f + graphRect.Width());
456456 float vertfact = (windowRect.Height() - 4.0f)/(4.0f + graphRect.Height());
457457 if ((vertfact < horzfact) && (vertfact < MAX_ZOOM))
458- horzfact = (windowRect.Width() - CDPIAware::Instance().ScaleX(20))/(4.0f + graphRect.Width());
458+ horzfact = (windowRect.Width() - CDPIAware::Instance().Scale(20))/(4.0f + graphRect.Width());
459459
460460 DoZoom (min (MAX_ZOOM, horzfact));
461461 }
--- branches/1.10.x/src/TortoiseProc/RevisionGraph/RevisionGraphWnd.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/RevisionGraph/RevisionGraphWnd.cpp (revision 28274)
@@ -254,7 +254,7 @@
254254 // get node at point or node that is close enough
255255 // so that point may hit a glyph area
256256
257- auto glyphsize = CDPIAware::Instance().ScaleX(GLYPH_SIZE);
257+ auto glyphsize = CDPIAware::Instance().Scale(GLYPH_SIZE);
258258 index_t nodeIndex = GetHitNode(point);
259259 if (nodeIndex == NO_INDEX)
260260 nodeIndex = GetHitNode(point, CSize (glyphsize, glyphsize / 2));
@@ -315,7 +315,7 @@
315315
316316 const CRevisionGraphState::SVisibleGlyph* CRevisionGraphWnd::GetHitGlyph (CPoint point) const
317317 {
318- float glyphSize = CDPIAware::Instance().ScaleX(GLYPH_SIZE) * m_fZoomFactor;
318+ float glyphSize = CDPIAware::Instance().Scale(GLYPH_SIZE) * m_fZoomFactor;
319319
320320 CSyncPointer<const CRevisionGraphState::TVisibleGlyphs>
321321 visibleGlyphs (m_state.GetVisibleGlyphs());
--- branches/1.10.x/src/TortoiseProc/Commands/SettingsCommand.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/Commands/SettingsCommand.cpp (revision 28274)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2007-2008, 2012-2013, 2015 - TortoiseSVN
3+// Copyright (C) 2007-2008, 2012-2013, 2015, 2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@
2121
2222 #include "../Settings/Settings.h"
2323 #include "AppUtils.h"
24+#include "DPIAware.h"
2425
2526 bool SettingsCommand::Execute()
2627 {
@@ -27,9 +28,7 @@
2728 CSettings dlg(IDS_PROC_SETTINGS_TITLE);
2829 dlg.SetTreeViewMode(TRUE, TRUE, TRUE);
2930
30- HDC hdc = ::GetDC(nullptr);
31- int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
32- ::ReleaseDC(nullptr, hdc);
31+ int dpiX = CDPIAware::Instance().GetDPI();
3332 dlg.SetTreeWidth(220 * dpiX / 96); // need to adjust manually if text gets longer
3433 long page = parser.GetLongVal(L"page");
3534 dlg.SetActivePage(page);
--- branches/1.10.x/src/TortoiseProc/AboutDlg.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseProc/AboutDlg.cpp (revision 28274)
@@ -91,10 +91,10 @@
9191
9292 CPictureHolder tmpPic;
9393 tmpPic.CreateFromBitmap(IDB_LOGOFLIPPED);
94- m_renderSrc.Create32BitFromPicture(&tmpPic, CDPIAware::Instance().ScaleX(468), CDPIAware::Instance().ScaleY(64));
95- m_renderDest.Create32BitFromPicture(&tmpPic, CDPIAware::Instance().ScaleX(468), CDPIAware::Instance().ScaleY(64));
94+ m_renderSrc.Create32BitFromPicture(&tmpPic, CDPIAware::Instance().Scale(468), CDPIAware::Instance().Scale(64));
95+ m_renderDest.Create32BitFromPicture(&tmpPic, CDPIAware::Instance().Scale(468), CDPIAware::Instance().Scale(64));
9696
97- m_waterEffect.Create(CDPIAware::Instance().ScaleX(468), CDPIAware::Instance().ScaleY(64));
97+ m_waterEffect.Create(CDPIAware::Instance().Scale(468), CDPIAware::Instance().Scale(64));
9898 SetTimer(ID_EFFECTTIMER, 40, NULL);
9999 SetTimer(ID_DROPTIMER, 1500, NULL);
100100
@@ -112,14 +112,14 @@
112112 {
113113 m_waterEffect.Render((DWORD*)m_renderSrc.GetDIBits(), (DWORD*)m_renderDest.GetDIBits());
114114 CClientDC dc(this);
115- CPoint ptOrigin(CDPIAware::Instance().ScaleX(15), CDPIAware::Instance().ScaleY(20));
115+ CPoint ptOrigin(CDPIAware::Instance().Scale(15), CDPIAware::Instance().Scale(20));
116116 m_renderDest.Draw(&dc,ptOrigin);
117117 }
118118 if (nIDEvent == ID_DROPTIMER)
119119 {
120120 CRect r;
121- r.left = CDPIAware::Instance().ScaleX(15);
122- r.top = CDPIAware::Instance().ScaleY(20);
121+ r.left = CDPIAware::Instance().Scale(15);
122+ r.top = CDPIAware::Instance().Scale(20);
123123 r.right = r.left + m_renderSrc.GetWidth();
124124 r.bottom = r.top + m_renderSrc.GetHeight();
125125 m_waterEffect.Blob(random(r.left,r.right), random(r.top, r.bottom), 5, 800, m_waterEffect.m_iHpage);
@@ -129,8 +129,8 @@
129129
130130 void CAboutDlg::OnMouseMove(UINT nFlags, CPoint point)
131131 {
132- auto dpix15 = CDPIAware::Instance().ScaleX(15);
133- auto dpiy20 = CDPIAware::Instance().ScaleY(20);
132+ auto dpix15 = CDPIAware::Instance().Scale(15);
133+ auto dpiy20 = CDPIAware::Instance().Scale(20);
134134 CRect r;
135135 r.left = dpix15;
136136 r.top = dpiy20;
@@ -141,12 +141,12 @@
141141 {
142142 // dibs are drawn upside down...
143143 point.y -= dpiy20;
144- point.y = CDPIAware::Instance().ScaleY(64) -point.y;
144+ point.y = CDPIAware::Instance().Scale(64) -point.y;
145145
146146 if (nFlags & MK_LBUTTON)
147- m_waterEffect.Blob(point.x - dpix15,point.y, CDPIAware::Instance().ScaleX(10),1600,m_waterEffect.m_iHpage);
147+ m_waterEffect.Blob(point.x - dpix15,point.y, CDPIAware::Instance().Scale(10),1600,m_waterEffect.m_iHpage);
148148 else
149- m_waterEffect.Blob(point.x - dpix15,point.y, CDPIAware::Instance().ScaleX(5),50,m_waterEffect.m_iHpage);
149+ m_waterEffect.Blob(point.x - dpix15,point.y, CDPIAware::Instance().Scale(5),50,m_waterEffect.m_iHpage);
150150
151151 }
152152
--- branches/1.10.x/src/Utils/DPIAware.h (revision 28273)
+++ branches/1.10.x/src/Utils/DPIAware.h (revision 28274)
@@ -16,10 +16,19 @@
1616 // along with this program; if not, write to the Free Software Foundation,
1717 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1818 //
19+#pragma once
20+
1921 class CDPIAware
2022 {
2123 private:
22- CDPIAware() : m_fInitialized(false), m_dpiX(96), m_dpiY(96) {}
24+ CDPIAware()
25+ : m_fInitialized(false)
26+ , m_dpi(96)
27+ , pfnGetDpiForWindow(nullptr)
28+ , pfnGetDpiForSystem(nullptr)
29+ , pfnGetSystemMetricsForDpi(nullptr)
30+ , pfnSystemParametersInfoForDpi(nullptr)
31+ {}
2332 ~CDPIAware() {}
2433 public:
2534 static CDPIAware& Instance()
@@ -29,42 +38,38 @@
2938 }
3039
3140 // Get screen DPI.
32- int GetDPIX() { _Init(); return m_dpiX; }
33- int GetDPIY() { _Init(); return m_dpiY; }
41+ int GetDPI() { _Init(); return m_dpi; }
3442
3543 // Convert between raw pixels and relative pixels.
36- int ScaleX(int x) { _Init(); return MulDiv(x, m_dpiX, 96); }
37- int ScaleY(int y) { _Init(); return MulDiv(y, m_dpiY, 96); }
38- float ScaleFactorX() { _Init(); return m_dpiX / 96.0f; }
39- float ScaleFactorY() { _Init(); return m_dpiY / 96.0f; }
40- int UnscaleX(int x) { _Init(); return MulDiv(x, 96, m_dpiX); }
41- int UnscaleY(int y) { _Init(); return MulDiv(y, 96, m_dpiY); }
44+ int Scale(int x) { _Init(); return MulDiv(x, m_dpi, 96); }
45+ float ScaleFactor() { _Init(); return m_dpi / 96.0f; }
46+ int Unscale(int x) { _Init(); return MulDiv(x, 96, m_dpi); }
4247
4348 // Determine the screen dimensions in relative pixels.
44- int ScaledScreenWidth() { return _ScaledSystemMetricX(SM_CXSCREEN); }
45- int ScaledScreenHeight() { return _ScaledSystemMetricY(SM_CYSCREEN); }
49+ int ScaledScreenWidth() { return _ScaledSystemMetric(SM_CXSCREEN); }
50+ int ScaledScreenHeight() { return _ScaledSystemMetric(SM_CYSCREEN); }
4651
4752 // Scale rectangle from raw pixels to relative pixels.
4853 void ScaleRect(__inout RECT *pRect)
4954 {
50- pRect->left = ScaleX(pRect->left);
51- pRect->right = ScaleX(pRect->right);
52- pRect->top = ScaleY(pRect->top);
53- pRect->bottom = ScaleY(pRect->bottom);
55+ pRect->left = Scale(pRect->left);
56+ pRect->right = Scale(pRect->right);
57+ pRect->top = Scale(pRect->top);
58+ pRect->bottom = Scale(pRect->bottom);
5459 }
5560
5661 // Scale Point from raw pixels to relative pixels.
5762 void ScalePoint(__inout POINT *pPoint)
5863 {
59- pPoint->x = ScaleX(pPoint->x);
60- pPoint->y = ScaleY(pPoint->y);
64+ pPoint->x = Scale(pPoint->x);
65+ pPoint->y = Scale(pPoint->y);
6166 }
6267
6368 // Scale Size from raw pixels to relative pixels.
6469 void ScaleSize(__inout SIZE *pSize)
6570 {
66- pSize->cx = ScaleX(pSize->cx);
67- pSize->cy = ScaleY(pSize->cy);
71+ pSize->cx = Scale(pSize->cx);
72+ pSize->cy = Scale(pSize->cy);
6873 }
6974
7075 // Determine if screen resolution meets minimum requirements in relative pixels.
@@ -74,8 +79,26 @@
7479 }
7580
7681 // Convert a point size (1/72 of an inch) to raw pixels.
77- int PointsToPixels(int pt) { return MulDiv(pt, m_dpiY, 72); }
82+ int PointsToPixels(int pt) { _Init(); return MulDiv(pt, m_dpi, 72); }
7883
84+ // returns the system metrics. For Windows 10, it returns the metrics dpi scaled.
85+ UINT GetSystemMetrics(int nIndex)
86+ {
87+ return _ScaledSystemMetric(nIndex);
88+ }
89+
90+ // returns the system parameters info. If possible adjusted for dpi.
91+ UINT SystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
92+ {
93+ _Init();
94+ UINT ret = 0;
95+ if (pfnSystemParametersInfoForDpi)
96+ ret = pfnSystemParametersInfoForDpi(uiAction, uiParam, pvParam, fWinIni, m_dpi);
97+ if (ret == 0)
98+ ret = ::SystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
99+ return ret;
100+ }
101+
79102 // Invalidate any cached metrics.
80103 void Invalidate() { m_fInitialized = false; }
81104
@@ -86,16 +109,31 @@
86109 {
87110 if (!m_fInitialized)
88111 {
89- HDC hdc = GetDC(nullptr);
90- if (hdc)
112+ auto hUser = ::GetModuleHandle(L"user32.dll");
113+ if (hUser)
91114 {
92- // Initialize the DPI member variable
93- // This will correspond to the DPI setting
94- // With all Windows OS's to date the X and Y DPI will be identical
95- m_dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
96- m_dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
97- ReleaseDC(nullptr, hdc);
115+ pfnGetDpiForWindow = (GetDpiForWindowFN *)GetProcAddress(hUser, "GetDpiForWindow");
116+ pfnGetDpiForSystem = (GetDpiForSystemFN *)GetProcAddress(hUser, "GetDpiForSystem");
117+ pfnGetSystemMetricsForDpi = (GetSystemMetricsForDpiFN *)GetProcAddress(hUser, "GetSystemMetricsForDpi");
118+ pfnSystemParametersInfoForDpi = (SystemParametersInfoForDpiFN *)GetProcAddress(hUser, "SystemParametersInfoForDpi");
98119 }
120+
121+ if (pfnGetDpiForSystem)
122+ {
123+ m_dpi = pfnGetDpiForSystem();
124+ }
125+ else
126+ {
127+ HDC hdc = GetDC(nullptr);
128+ if (hdc)
129+ {
130+ // Initialize the DPI member variable
131+ // This will correspond to the DPI setting
132+ // With all Windows OS's to date the X and Y DPI will be identical
133+ m_dpi = GetDeviceCaps(hdc, LOGPIXELSX);
134+ ReleaseDC(nullptr, hdc);
135+ }
136+ }
99137 m_fInitialized = true;
100138 }
101139 }
@@ -104,29 +142,27 @@
104142 // For example, the value 120 at 120 DPI setting gets scaled down to 96
105143 // X and Y versions are provided, though to date all Windows OS releases
106144 // have equal X and Y scale values
107- int _ScaledSystemMetricX(int nIndex)
145+ int _ScaledSystemMetric(int nIndex)
108146 {
109147 _Init();
110- return MulDiv(GetSystemMetrics(nIndex), 96, m_dpiX);
148+ if (pfnGetSystemMetricsForDpi)
149+ return pfnGetSystemMetricsForDpi(nIndex, m_dpi);
150+ return MulDiv(::GetSystemMetrics(nIndex), 96, m_dpi);
111151 }
112152
113- // This returns a 96-DPI scaled-down equivalent value for nIndex
114- // For example, the value 120 at 120 DPI setting gets scaled down to 96
115- // X and Y versions are provided, though to date all Windows OS releases
116- // have equal X and Y scale values
117- int _ScaledSystemMetricY(int nIndex)
118- {
119- _Init();
120- return MulDiv(GetSystemMetrics(nIndex), 96, m_dpiY);
121- }
122-
123153 private:
154+ typedef UINT STDAPICALLTYPE GetDpiForWindowFN(HWND hWnd);
155+ typedef UINT STDAPICALLTYPE GetDpiForSystemFN();
156+ typedef UINT STDAPICALLTYPE GetSystemMetricsForDpiFN(int nIndex, UINT dpi);
157+ typedef UINT STDAPICALLTYPE SystemParametersInfoForDpiFN(UINT uiAction,UINT uiParam, PVOID pvParam, UINT fWinIni, UINT dpi);
124158
159+ GetDpiForWindowFN * pfnGetDpiForWindow;
160+ GetDpiForSystemFN * pfnGetDpiForSystem;
161+ GetSystemMetricsForDpiFN * pfnGetSystemMetricsForDpi;
162+ SystemParametersInfoForDpiFN * pfnSystemParametersInfoForDpi;
163+
125164 // Member variable indicating whether the class has been initialized
126165 bool m_fInitialized;
127166
128- // X and Y DPI values are provided, though to date all
129- // Windows OS releases have equal X and Y scale values
130- int m_dpiX;
131- int m_dpiY;
167+ int m_dpi;
132168 };
--- branches/1.10.x/src/Utils/MiscUI/AeroControls.cpp (revision 28273)
+++ branches/1.10.x/src/Utils/MiscUI/AeroControls.cpp (revision 28274)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009-2016 - TortoiseSVN
3+// Copyright (C) 2009-2016, 2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -19,6 +19,7 @@
1919 #include "stdafx.h"
2020 #include "AeroControls.h"
2121 #include <VersionHelpers.h>
22+#include "DPIAware.h"
2223 // SDKs prior to Win10 don't have the IsWindows10OrGreater API in the versionhelpers header, so
2324 // we define it here just in case:
2425 #ifndef _WIN32_WINNT_WIN10
@@ -567,7 +568,7 @@
567568
568569 int iState = GetStateFromBtnState(dwStyle, bHot, bFocus, dwCheckState, iPartId, FALSE);
569570
570- int bmWidth = int(ceil(13.0 * GetDeviceCaps(hdcPaint, LOGPIXELSX) / 96.0));
571+ int bmWidth = int(ceil(13.0 * CDPIAware::Instance().GetDPI() / 96.0));
571572
572573 UINT uiHalfWidth = (RECTWIDTH(rcClient) - bmWidth)/2;
573574
--- branches/1.10.x/src/Utils/MiscUI/FilterEdit.cpp (revision 28273)
+++ branches/1.10.x/src/Utils/MiscUI/FilterEdit.cpp (revision 28274)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2007, 2009, 2011-2015, 2017 - TortoiseSVN
3+// Copyright (C) 2007, 2009, 2011-2015, 2017-2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -18,6 +18,7 @@
1818 //
1919 #include "stdafx.h"
2020 #include "FilterEdit.h"
21+#include "DPIAware.h"
2122
2223
2324 const UINT CFilterEdit::WM_FILTEREDIT_INFOCLICKED
@@ -398,11 +399,9 @@
398399
399400 HICON CFilterEdit::LoadDpiScaledIcon(UINT resourceId, int cx96dpi, int cy96dpi)
400401 {
401- CWindowDC dc(this);
402+ int cx = CDPIAware::Instance().PointsToPixels(cx96dpi);
403+ int cy = CDPIAware::Instance().PointsToPixels(cy96dpi);
402404
403- int cx = MulDiv(cx96dpi, dc.GetDeviceCaps(LOGPIXELSX), 96);
404- int cy = MulDiv(cy96dpi, dc.GetDeviceCaps(LOGPIXELSY), 96);
405-
406405 return (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(resourceId), IMAGE_ICON, cx, cy, LR_DEFAULTCOLOR);
407406 }
408407
--- branches/1.10.x/src/Utils/CommonAppUtils.h (revision 28273)
+++ branches/1.10.x/src/Utils/CommonAppUtils.h (revision 28274)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2010-2012, 2014, 2016-2017 - TortoiseSVN
3+// Copyright (C) 2010-2012, 2014, 2016-2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -84,7 +84,8 @@
8484 */
8585 static void ResizeAllListCtrlCols(CListCtrl * pListCtrl);
8686
87- static bool SetListCtrlBackgroundImage(HWND hListCtrl, UINT nID, int width = 128, int height = 128);
87+ static bool SetListCtrlBackgroundImage(HWND hListCtrl, UINT nID);
88+ static bool SetListCtrlBackgroundImage(HWND hListCtrl, UINT nID, int width, int height);
8889
8990 /**
9091 * Creates a .lnk file (a windows shortcut file)
--- branches/1.10.x/src/Utils/CommonAppUtils.cpp (revision 28273)
+++ branches/1.10.x/src/Utils/CommonAppUtils.cpp (revision 28274)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2010-2017 - TortoiseSVN
3+// Copyright (C) 2010-2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -29,6 +29,7 @@
2929 #include "SmartHandle.h"
3030 #include "PreserveChdir.h"
3131 #include "OnOutOfScope.h"
32+#include "DPIAware.h"
3233 #include <WinInet.h>
3334 #include <oleacc.h>
3435 #include <initguid.h>
@@ -317,6 +318,12 @@
317318 }
318319 }
319320
321+bool CCommonAppUtils::SetListCtrlBackgroundImage(HWND hListCtrl, UINT nID)
322+{
323+ auto size = CDPIAware::Instance().Scale(128);
324+ return SetListCtrlBackgroundImage(hListCtrl, nID, size, size);
325+}
326+
320327 bool CCommonAppUtils::SetListCtrlBackgroundImage(HWND hListCtrl, UINT nID, int width /* = 128 */, int height /* = 128 */)
321328 {
322329 ListView_SetTextBkColor(hListCtrl, CLR_NONE);
--- branches/1.10.x/src/TortoiseBlame/TortoiseBlame.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseBlame/TortoiseBlame.cpp (revision 28274)
@@ -1380,13 +1380,13 @@
13801380 TCHAR buf[MAX_PATH] = { 0 };
13811381 swprintf_s(buf, L"*%8d ", 88888888);
13821382 ::GetTextExtentPoint(hDC, buf, (int)wcslen(buf), &width);
1383- m_revWidth = width.cx + CDPIAware::Instance().ScaleX(BLAMESPACE);
1383+ m_revWidth = width.cx + CDPIAware::Instance().Scale(BLAMESPACE);
13841384 blamewidth += m_revWidth;
13851385 if (ShowDate)
13861386 {
13871387 swprintf_s(buf, L"%30s", L"31.08.2001 06:24:14");
13881388 ::GetTextExtentPoint32(hDC, buf, (int)wcslen(buf), &width);
1389- m_dateWidth = width.cx + CDPIAware::Instance().ScaleX(BLAMESPACE);
1389+ m_dateWidth = width.cx + CDPIAware::Instance().Scale(BLAMESPACE);
13901390 blamewidth += m_dateWidth;
13911391 }
13921392 if (ShowAuthor)
@@ -1398,7 +1398,7 @@
13981398 if (width.cx > maxwidth.cx)
13991399 maxwidth = width;
14001400 }
1401- m_authorWidth = maxwidth.cx + CDPIAware::Instance().ScaleX(BLAMESPACE);
1401+ m_authorWidth = maxwidth.cx + CDPIAware::Instance().Scale(BLAMESPACE);
14021402 blamewidth += m_authorWidth;
14031403 }
14041404 if (ShowPath)
@@ -1410,7 +1410,7 @@
14101410 if (width.cx > maxwidth.cx)
14111411 maxwidth = width;
14121412 }
1413- m_pathWidth = maxwidth.cx + CDPIAware::Instance().ScaleX(BLAMESPACE);
1413+ m_pathWidth = maxwidth.cx + CDPIAware::Instance().Scale(BLAMESPACE);
14141414 blamewidth += m_pathWidth;
14151415 }
14161416 ::SelectObject(hDC, oldfont);
@@ -1428,7 +1428,7 @@
14281428 LOGFONT lf = {0};
14291429 lf.lfWeight = FW_NORMAL;
14301430 HDC hDC = ::GetDC(wBlame);
1431- lf.lfHeight = -MulDiv((DWORD)CRegStdDWORD(L"Software\\TortoiseSVN\\BlameFontSize", 10), GetDeviceCaps(hDC, LOGPIXELSY), 72);
1431+ lf.lfHeight = -CDPIAware::Instance().PointsToPixels((DWORD)CRegStdDWORD(L"Software\\TortoiseSVN\\BlameFontSize", 10));
14321432 lf.lfCharSet = DEFAULT_CHARSET;
14331433 CRegStdString fontname = CRegStdString(L"Software\\TortoiseSVN\\BlameFontName", L"Consolas");
14341434 wcscpy_s(lf.lfFaceName, ((tstring)fontname).c_str());
@@ -1562,7 +1562,7 @@
15621562 ::SetBkColor(hDC, ::GetSysColor(COLOR_BTNFACE));
15631563
15641564 RECT edgerc = rc;
1565- edgerc.bottom = edgerc.top + CDPIAware::Instance().ScaleY(HEADER_HEIGHT) /2;
1565+ edgerc.bottom = edgerc.top + CDPIAware::Instance().Scale(HEADER_HEIGHT) /2;
15661566 DrawEdge(hDC, &edgerc, EDGE_BUMP, BF_FLAT|BF_RECT|BF_ADJUST);
15671567
15681568 // draw the path first
@@ -1576,16 +1576,16 @@
15761576 if (str2.size() >= MAX_PATH)
15771577 str2 = str2.substr(0, MAX_PATH-2);
15781578 wcscpy_s(pathbuf, str2.c_str());
1579- PathCompactPath(hDC, pathbuf, edgerc.right-edgerc.left- CDPIAware::Instance().ScaleX(LOCATOR_WIDTH));
1579+ PathCompactPath(hDC, pathbuf, edgerc.right-edgerc.left- CDPIAware::Instance().Scale(LOCATOR_WIDTH));
15801580 }
15811581 else
15821582 {
15831583 wcscpy_s(pathbuf, szViewtitle.c_str());
1584- PathCompactPath(hDC, pathbuf, edgerc.right-edgerc.left- CDPIAware::Instance().ScaleX(LOCATOR_WIDTH));
1584+ PathCompactPath(hDC, pathbuf, edgerc.right-edgerc.left- CDPIAware::Instance().Scale(LOCATOR_WIDTH));
15851585 }
15861586 DrawText(hDC, pathbuf, -1, &edgerc, DT_SINGLELINE|DT_VCENTER);
15871587
1588- rc.top = rc.top + CDPIAware::Instance().ScaleY(HEADER_HEIGHT)/2;
1588+ rc.top = rc.top + CDPIAware::Instance().Scale(HEADER_HEIGHT)/2;
15891589 DrawEdge(hDC, &rc, EDGE_BUMP, BF_FLAT|BF_RECT|BF_ADJUST);
15901590
15911591 RECT drawRc = rc;
@@ -1592,9 +1592,9 @@
15921592
15931593 TCHAR szText[MAX_LOADSTRING] = { 0 };
15941594 LoadString(app.hResource, IDS_HEADER_REVISION, szText, MAX_LOADSTRING);
1595- drawRc.left = CDPIAware::Instance().ScaleX(LOCATOR_WIDTH);
1595+ drawRc.left = CDPIAware::Instance().Scale(LOCATOR_WIDTH);
15961596 DrawText(hDC, szText, -1, &drawRc, DT_SINGLELINE|DT_VCENTER);
1597- int Left = m_revWidth+ CDPIAware::Instance().ScaleX(LOCATOR_WIDTH);
1597+ int Left = m_revWidth+ CDPIAware::Instance().Scale(LOCATOR_WIDTH);
15981598 if (ShowDate)
15991599 {
16001600 LoadString(app.hResource, IDS_HEADER_DATE, szText, MAX_LOADSTRING);
@@ -2038,8 +2038,8 @@
20382038 RECT blamerc;
20392039 RECT sourcerc;
20402040 ::GetClientRect(wMain, &rc);
2041- ::SetWindowPos(wHeader, 0, rc.left, rc.top, rc.right-rc.left, CDPIAware::Instance().ScaleY(HEADER_HEIGHT), 0);
2042- rc.top += CDPIAware::Instance().ScaleY(HEADER_HEIGHT);
2041+ ::SetWindowPos(wHeader, 0, rc.left, rc.top, rc.right-rc.left, CDPIAware::Instance().Scale(HEADER_HEIGHT), 0);
2042+ rc.top += CDPIAware::Instance().Scale(HEADER_HEIGHT);
20432043 blamerc.left = rc.left;
20442044 blamerc.top = rc.top;
20452045 LONG w = GetBlameWidth();
@@ -2051,15 +2051,15 @@
20512051 sourcerc.right = rc.right;
20522052 if (m_colorby != COLORBYNONE)
20532053 {
2054- ::OffsetRect(&blamerc, CDPIAware::Instance().ScaleX(LOCATOR_WIDTH), 0);
2055- ::OffsetRect(&sourcerc, CDPIAware::Instance().ScaleX(LOCATOR_WIDTH), 0);
2056- sourcerc.right -= CDPIAware::Instance().ScaleX(LOCATOR_WIDTH);
2054+ ::OffsetRect(&blamerc, CDPIAware::Instance().Scale(LOCATOR_WIDTH), 0);
2055+ ::OffsetRect(&sourcerc, CDPIAware::Instance().Scale(LOCATOR_WIDTH), 0);
2056+ sourcerc.right -= CDPIAware::Instance().Scale(LOCATOR_WIDTH);
20572057 }
20582058 InvalidateRect(wMain, NULL, FALSE);
20592059 ::SetWindowPos(wEditor, 0, sourcerc.left, sourcerc.top, sourcerc.right - sourcerc.left, sourcerc.bottom - sourcerc.top, 0);
20602060 ::SetWindowPos(wBlame, 0, blamerc.left, blamerc.top, blamerc.right - blamerc.left, blamerc.bottom - blamerc.top, 0);
20612061 if (m_colorby != COLORBYNONE)
2062- ::SetWindowPos(wLocator, 0, 0, blamerc.top, CDPIAware::Instance().ScaleX(LOCATOR_WIDTH), blamerc.bottom - blamerc.top, SWP_SHOWWINDOW);
2062+ ::SetWindowPos(wLocator, 0, 0, blamerc.top, CDPIAware::Instance().Scale(LOCATOR_WIDTH), blamerc.bottom - blamerc.top, SWP_SHOWWINDOW);
20632063 else
20642064 ::ShowWindow(wLocator, SW_HIDE);
20652065 }
--- branches/1.10.x/src/TortoiseIDiff/PicWindow.cpp (revision 28273)
+++ branches/1.10.x/src/TortoiseIDiff/PicWindow.cpp (revision 28274)
@@ -1,6 +1,6 @@
1-// TortoiseIDiff - an image diff viewer in TortoiseSVN
1+// TortoiseIDiff - an image diff viewer in TortoiseSVN
22
3-// Copyright (C) 2006-2016 - TortoiseSVN
3+// Copyright (C) 2006-2016, 2018 - TortoiseSVN
44 // Copyright (C) 2016 - TortoiseGit
55
66 // This program is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
2323 #include "PicWindow.h"
2424 #include <math.h>
2525 #include <memory>
26+#include "../Utils/DPIAware.h"
2627
2728 #pragma comment(lib, "Msimg32.lib")
2829 #pragma comment(lib, "shell32.lib")
@@ -574,7 +575,7 @@
574575 void CPicWindow::DrawViewTitle(HDC hDC, RECT * rect)
575576 {
576577 HFONT hFont = nullptr;
577- hFont = CreateFont(-MulDiv(pSecondPic ? 8 : 10, GetDeviceCaps(hDC, LOGPIXELSY), 72), 0, 0, 0, FW_DONTCARE, false, false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH, L"MS Shell Dlg");
578+ hFont = CreateFont(-CDPIAware::Instance().PointsToPixels(pSecondPic ? 8 : 10), 0, 0, 0, FW_DONTCARE, false, false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH, L"MS Shell Dlg");
578579 HFONT hFontOld = (HFONT)SelectObject(hDC, (HGDIOBJ)hFont);
579580
580581 RECT textrect;
Show on old repository browser