diff --git a/language/np3_af_za/dialogs_af_za.rc b/language/np3_af_za/dialogs_af_za.rc
index 3f7ba2194..bba0f8288 100644
Binary files a/language/np3_af_za/dialogs_af_za.rc and b/language/np3_af_za/dialogs_af_za.rc differ
diff --git a/language/np3_de_de/dialogs_de_de.rc b/language/np3_de_de/dialogs_de_de.rc
index 0db7ff7d3..a3a67cfab 100644
Binary files a/language/np3_de_de/dialogs_de_de.rc and b/language/np3_de_de/dialogs_de_de.rc differ
diff --git a/language/np3_en_gb/dialogs_en_gb.rc b/language/np3_en_gb/dialogs_en_gb.rc
index c8a035e6f..577120888 100644
Binary files a/language/np3_en_gb/dialogs_en_gb.rc and b/language/np3_en_gb/dialogs_en_gb.rc differ
diff --git a/language/np3_en_us/dialogs_en_us.rc b/language/np3_en_us/dialogs_en_us.rc
index 744a3586f..5300f2db8 100644
Binary files a/language/np3_en_us/dialogs_en_us.rc and b/language/np3_en_us/dialogs_en_us.rc differ
diff --git a/language/np3_es_es/dialogs_es_es.rc b/language/np3_es_es/dialogs_es_es.rc
index d969ab33f..b9e411fbc 100644
Binary files a/language/np3_es_es/dialogs_es_es.rc and b/language/np3_es_es/dialogs_es_es.rc differ
diff --git a/language/np3_fr_fr/dialogs_fr_fr.rc b/language/np3_fr_fr/dialogs_fr_fr.rc
index 2a3ae86d7..7fea931aa 100644
Binary files a/language/np3_fr_fr/dialogs_fr_fr.rc and b/language/np3_fr_fr/dialogs_fr_fr.rc differ
diff --git a/language/np3_nl_nl/dialogs_nl_nl.rc b/language/np3_nl_nl/dialogs_nl_nl.rc
index 8d2595799..4b567b045 100644
Binary files a/language/np3_nl_nl/dialogs_nl_nl.rc and b/language/np3_nl_nl/dialogs_nl_nl.rc differ
diff --git a/language/np3_zh_cn/dialogs_zh_cn.rc b/language/np3_zh_cn/dialogs_zh_cn.rc
index 2c55baa96..5838ab597 100644
Binary files a/language/np3_zh_cn/dialogs_zh_cn.rc and b/language/np3_zh_cn/dialogs_zh_cn.rc differ
diff --git a/res/Notepad3.exe.manifest b/res/Notepad3.exe.manifest
index c6c427f95..11c2c9396 100644
--- a/res/Notepad3.exe.manifest
+++ b/res/Notepad3.exe.manifest
@@ -31,7 +31,13 @@
- true
+ true/PM
+
+
+ PerMonitorV2,PerMonitor
+
+
+ false
diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf
index 0b61f888f..0a34ff852 100644
--- a/res/Notepad3.exe.manifest.conf
+++ b/res/Notepad3.exe.manifest.conf
@@ -3,7 +3,7 @@
Notepad3 X_MUI
diff --git a/src/Dialogs.c b/src/Dialogs.c
index 60e25a7fc..9bde2b665 100644
--- a/src/Dialogs.c
+++ b/src/Dialogs.c
@@ -2239,6 +2239,7 @@ INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR
if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); }
hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
+ hbmp = ResizeImageForCurrentDPI(hbmp);
himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0);
ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
@@ -2364,6 +2365,8 @@ INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM
hwndLV = GetDlgItem(hwnd,IDC_ENCODINGLIST);
hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
+ hbmp = ResizeImageForCurrentDPI(hbmp);
+
himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0);
ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
DeleteObject(hbmp);
diff --git a/src/Helpers.c b/src/Helpers.c
index 45dac58e9..cc5f04bbc 100644
--- a/src/Helpers.c
+++ b/src/Helpers.c
@@ -43,6 +43,7 @@
extern HINSTANCE g_hInstance;
extern HMODULE g_hLngResContainer;
extern LANGID g_iPrefLngLocID;
+extern UINT g_uCurrentDPI;
//=============================================================================
//
@@ -300,6 +301,70 @@ DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID)
}
+
+//=============================================================================
+//
+// GetCurrentDPI()
+//
+UINT GetCurrentDPI(HWND hwnd) {
+ UINT dpi = 0;
+ if (IsWin10()) {
+ FARPROC pfnGetDpiForWindow = GetProcAddress(GetModuleHandle(L"user32.dll"), "GetDpiForWindow");
+ if (pfnGetDpiForWindow) {
+ dpi = (UINT)pfnGetDpiForWindow(hwnd);
+ }
+ }
+
+ if (dpi == 0 && IsWin81()) {
+ HMODULE hShcore = LoadLibrary(L"shcore.dll");
+ if (hShcore) {
+ FARPROC pfnGetDpiForMonitor = GetProcAddress(hShcore, "GetDpiForMonitor");
+ if (pfnGetDpiForMonitor) {
+ HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
+ UINT dpiX = 0, dpiY = 0;
+ if (pfnGetDpiForMonitor(hMonitor, 0 /* MDT_EFFECTIVE_DPI */, &dpiX, &dpiY) == S_OK) {
+ dpi = dpiX;
+ }
+ }
+ FreeLibrary(hShcore);
+ }
+ }
+
+ if (dpi == 0) {
+ // FIXME: seems always get 96
+ HDC hDC = GetDC(hwnd);
+ dpi = GetDeviceCaps(hDC, LOGPIXELSX);
+ ReleaseDC(hwnd, hDC);
+ }
+
+ dpi = max(dpi, USER_DEFAULT_SCREEN_DPI);
+ return dpi;
+}
+
+
+
+//=============================================================================
+//
+// ResizeImageForCurrentDPI()
+//
+HBITMAP ResizeImageForCurrentDPI(HBITMAP hbmp)
+{
+ if (hbmp) {
+ BITMAP bmp;
+ if (g_uCurrentDPI > USER_DEFAULT_SCREEN_DPI && GetObject(hbmp, sizeof(BITMAP), &bmp)) {
+ int width = MulDiv(bmp.bmWidth, g_uCurrentDPI, USER_DEFAULT_SCREEN_DPI);
+ int height = MulDiv(bmp.bmHeight, g_uCurrentDPI, USER_DEFAULT_SCREEN_DPI);
+ HBITMAP hCopy = CopyImage(hbmp, IMAGE_BITMAP, width, height, LR_COPYRETURNORG | LR_COPYDELETEORG);
+ if (hCopy) {
+ hbmp = hCopy;
+ }
+ }
+ }
+ return hbmp;
+}
+
+
+
//=============================================================================
//
// PrivateIsAppThemed()
@@ -952,6 +1017,7 @@ void MakeBitmapButton(HWND hwnd,int nCtlId,HINSTANCE hInstance,UINT uBmpId)
BITMAP bmp;
BUTTON_IMAGELIST bi;
HBITMAP hBmp = LoadImage(hInstance,MAKEINTRESOURCE(uBmpId),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
+ hBmp = ResizeImageForCurrentDPI(hBmp);
GetObject(hBmp,sizeof(BITMAP),&bmp);
bi.himl = ImageList_Create(bmp.bmWidth,bmp.bmHeight,ILC_COLOR32|ILC_MASK,1,0);
ImageList_AddMasked(bi.himl,hBmp,CLR_DEFAULT);
@@ -962,6 +1028,7 @@ void MakeBitmapButton(HWND hwnd,int nCtlId,HINSTANCE hInstance,UINT uBmpId)
}
+
//=============================================================================
//
// MakeColorPickButton()
@@ -1033,11 +1100,14 @@ void DeleteBitmapButton(HWND hwnd,int nCtlId)
//
// SendWMSize()
//
-LRESULT SendWMSize(HWND hwnd)
+LRESULT SendWMSize(HWND hwnd, RECT* rc)
{
- RECT rc;
- GetClientRect(hwnd, &rc);
- return (SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(rc.right, rc.bottom)));
+ if (!rc) {
+ RECT _rc;
+ GetClientRect(hwnd, &_rc);
+ return (SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(_rc.right, _rc.bottom)));
+ }
+ return (SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(rc->right, rc->bottom)));
}
diff --git a/src/Helpers.h b/src/Helpers.h
index 560cf141b..f865f111f 100644
--- a/src/Helpers.h
+++ b/src/Helpers.h
@@ -28,7 +28,6 @@
extern WCHAR g_wchIniFile[MAX_PATH];
-
// ============================================================================
#define STRGFY(X) L##(X)
@@ -132,6 +131,9 @@ DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID);
bool SetClipboardTextW(HWND, LPCWSTR);
+UINT GetCurrentDPI(HWND hwnd);
+HBITMAP ResizeImageForCurrentDPI(HBITMAP hbmp);
+
bool PrivateIsAppThemed();
HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR);
bool IsElevated();
@@ -174,7 +176,7 @@ LONG StatusCalcPaneWidth(HWND,LPCWSTR);
int Toolbar_GetButtons(HWND,int,LPWSTR,int);
int Toolbar_SetButtons(HWND,int,LPCWSTR,void*,int);
-LRESULT SendWMSize(HWND);
+LRESULT SendWMSize(HWND, RECT*);
bool IsCmdEnabled(HWND, UINT);
diff --git a/src/Notepad3.c b/src/Notepad3.c
index 3c0fb1876..084971b51 100644
--- a/src/Notepad3.c
+++ b/src/Notepad3.c
@@ -67,6 +67,7 @@ HWND g_hwndReBar = NULL;
HWND hwndEditFrame = NULL;
HWND hwndNextCBChain = NULL;
HICON g_hDlgIcon = NULL;
+UINT g_uCurrentDPI = USER_DEFAULT_SCREEN_DPI;
bool g_bExternalBitmap = false;
@@ -1414,6 +1415,10 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
MsgThemeChanged(hwnd,wParam,lParam);
break;
+ case WM_DPICHANGED:
+ MsgDPIChanged(hwnd, wParam, lParam);
+ break;
+
// update Scintilla colors
case WM_SYSCOLORCHANGE:
UpdateLineNumberWidth();
@@ -1710,6 +1715,8 @@ LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
HINSTANCE hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
+ g_uCurrentDPI = GetCurrentDPI(hwnd);
+
// Setup edit control
g_hwndEdit = CreateWindowEx(
WS_EX_CLIENTEDGE,
@@ -1870,6 +1877,7 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
if (!SearchPath(NULL,g_tchToolbarBitmap,L".bmp",COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmap);
hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
+ hbmp = ResizeImageForCurrentDPI(hbmp);
}
if (hbmp) {
@@ -1878,8 +1886,10 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
else {
LPWSTR toolBarIntRes = (iHighDpiToolBar > 0) ? MAKEINTRESOURCE(IDR_MAINWNDTB2) : MAKEINTRESOURCE(IDR_MAINWNDTB);
hbmp = LoadImage(hInstance, toolBarIntRes, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ hbmp = ResizeImageForCurrentDPI(hbmp);
hbmpCopy = CopyImage(hbmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
}
+
GetObject(hbmp,sizeof(BITMAP),&bmp);
if (!IsXP())
BitmapMergeAlpha(hbmp,GetSysColor(COLOR_3DFACE));
@@ -1896,6 +1906,7 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmapHot);
hbmp = LoadImage(NULL, szTmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
+ hbmp = ResizeImageForCurrentDPI(hbmp);
if (hbmp)
{
GetObject(hbmp,sizeof(BITMAP),&bmp);
@@ -1914,6 +1925,7 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmapDisabled);
hbmp = LoadImage(NULL, szTmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
+ hbmp = ResizeImageForCurrentDPI(hbmp);
if (hbmp)
{
GetObject(hbmp,sizeof(BITMAP),&bmp);
@@ -2092,6 +2104,46 @@ void MsgEndSession(HWND hwnd, UINT umsg)
}
+
+//=============================================================================
+//
+// MsgDPIChanged() - Handle WM_DPICHANGED
+//
+//
+void MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam)
+{
+ g_uCurrentDPI = HIWORD(wParam);
+ DocPos const pos = SciCall_GetCurrentPos();
+
+ HINSTANCE hInstance = (HINSTANCE)(INT_PTR)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
+
+#if 0
+ char buf[64];
+ sprintf_s(buf, COUNTOF(buf), "WM_DPICHANGED: dpi=%u\n", g_uCurrentDPI);
+ SendMessage(g_hwndEdit, SCI_INSERTTEXT, 0, (LPARAM)buf);
+#endif
+
+ Style_ResetCurrentLexer(g_hwndEdit);
+ SciCall_GotoPos(pos);
+
+ // recreate toolbar and statusbar
+ Toolbar_GetButtons(g_hwndToolbar, IDT_FILE_NEW, g_tchToolbarButtons, COUNTOF(g_tchToolbarButtons));
+
+ DestroyWindow(g_hwndToolbar);
+ DestroyWindow(g_hwndReBar);
+ DestroyWindow(g_hwndStatus);
+ CreateBars(hwnd, hInstance);
+
+ RECT* const rc = (RECT*)lParam;
+ SendWMSize(hwnd, rc);
+
+ UpdateUI();
+ UpdateToolbar();
+ UpdateStatusbar(true);
+ UpdateLineNumberWidth();
+}
+
+
//=============================================================================
//
// MsgThemeChanged() - Handle WM_THEMECHANGED
@@ -2147,7 +2199,7 @@ void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam)
DestroyWindow(g_hwndStatus);
CreateBars(hwnd,hInstance);
- SendWMSize(hwnd);
+ SendWMSize(hwnd, NULL);
EditFinalizeStyling(g_hwndEdit, -1);
@@ -4816,7 +4868,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
UpdateToolbar();
ShowWindow(g_hwndReBar,SW_SHOW);
}
- SendWMSize(hwnd);
+ SendWMSize(hwnd, NULL);
break;
@@ -4840,7 +4892,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
UpdateStatusbar(false);
ShowWindow(g_hwndStatus,SW_SHOW);
}
- SendWMSize(hwnd);
+ SendWMSize(hwnd, NULL);
break;
@@ -8225,9 +8277,16 @@ void UpdateLineNumberWidth()
else {
SciCall_SetMarginWidthN(MARGIN_SCI_LINENUM, 0);
}
+
+ int const widthBM = g_bShowSelectionMargin ? MulDiv(16, g_uCurrentDPI, USER_DEFAULT_SCREEN_DPI) : 0;
+ SciCall_SetMarginWidthN(MARGIN_SCI_BOOKMRK, widthBM);
+
+ int const widthCF = (g_bCodeFoldingAvailable && g_bShowCodeFolding) ? MulDiv(13, g_uCurrentDPI, USER_DEFAULT_SCREEN_DPI) : 0;
+ SciCall_SetMarginWidthN(MARGIN_SCI_FOLDING, widthCF);
}
+
//=============================================================================
//
// UpdateSettingsCmds()
diff --git a/src/Notepad3.h b/src/Notepad3.h
index da6a1ea12..603ecd0b3 100644
--- a/src/Notepad3.h
+++ b/src/Notepad3.h
@@ -172,6 +172,7 @@ LRESULT MsgCreate(HWND, WPARAM, LPARAM);
void MsgEndSession(HWND, UINT);
void CreateBars(HWND, HINSTANCE);
void MsgThemeChanged(HWND, WPARAM, LPARAM);
+void MsgDPIChanged(HWND, WPARAM, LPARAM);
void MsgSize(HWND, WPARAM, LPARAM);
void MsgDropFiles(HWND, WPARAM, LPARAM);
LRESULT MsgCopyData(HWND, WPARAM, LPARAM);
diff --git a/src/Styles.c b/src/Styles.c
index 523ba6b0c..d5c479487 100644
--- a/src/Styles.c
+++ b/src/Styles.c
@@ -50,6 +50,7 @@ extern HICON g_hDlgIcon;
extern HWND g_hwndMain;
extern HWND g_hwndDlgCustomizeSchemes;
extern EDITFINDREPLACE g_efrData;
+extern UINT g_uCurrentDPI;
extern int g_iSciFontQuality;
extern const int FontQuality[4];
@@ -5566,6 +5567,14 @@ bool Style_SelectColor(HWND hwnd,bool bForeGround,LPWSTR lpszStyle,int cchStyle,
}
+//=============================================================================
+
+inline static int _GetDPIAwareFractFontSize(float fFontSize)
+{
+ return MulDiv((int)(fFontSize + 0.5), (SC_FONT_SIZE_MULTIPLIER * g_uCurrentDPI), USER_DEFAULT_SCREEN_DPI);
+}
+
+
//=============================================================================
//
// Style_SetStyles()
@@ -5631,13 +5640,10 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle, bool bInitDefault
}
// Size values are relative to BaseFontSize/CurrentFontSize
- POINT dpi = GetSystemDpi();
float fBaseFontSize = _GetCurrentFontSize();
+ fBaseFontSize = (float)max(0.0, fBaseFontSize);
if (Style_StrGetSize(lpszStyle, &fBaseFontSize)) {
- fBaseFontSize = (float)max(0.0, fBaseFontSize);
- fBaseFontSize = (float)MulDiv((int)fBaseFontSize, (dpi.x + dpi.y)/2, USER_DEFAULT_SCREEN_DPI);
- //SendMessage(hwnd, SCI_STYLESETSIZE, iStyle, (int)fBaseFontSize);
- SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, iStyle, (LPARAM)((int)(fBaseFontSize * SC_FONT_SIZE_MULTIPLIER + 0.5)));
+ SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, iStyle, (LPARAM)_GetDPIAwareFractFontSize(fBaseFontSize));
if (iStyle == STYLE_DEFAULT) {
if (bInitDefault) {
_SetBaseFontSize(fBaseFontSize);
@@ -5647,7 +5653,7 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle, bool bInitDefault
}
else if (bInitDefault) {
//SendMessage(hwnd, SCI_STYLESETSIZE, STYLE_DEFAULT, (LPARAM)((int)fBaseFontSize));
- SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, STYLE_DEFAULT, (LPARAM)((int)(fBaseFontSize * SC_FONT_SIZE_MULTIPLIER + 0.5)));
+ SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, STYLE_DEFAULT, (LPARAM)_GetDPIAwareFractFontSize(fBaseFontSize));
}
// Character Set