diff --git a/language/np3_de_de/dialogs_de_de.rc b/language/np3_de_de/dialogs_de_de.rc index c67b248a2..c083a0aa7 100644 --- a/language/np3_de_de/dialogs_de_de.rc +++ b/language/np3_de_de/dialogs_de_de.rc @@ -53,22 +53,23 @@ END // Dialog // -IDD_MUI_ABOUT DIALOGEX 0, 0, 400, 274 +IDD_MUI_ABOUT DIALOGEX 0, 0, 400, 284 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_NOFAILCREATE | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Über Notepad3" FONT 9, "Segoe UI", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDOK,330,256,50,14 - EDITTEXT IDC_VERSION,80,7,220,14,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - LTEXT "Scintilla Bibliothek Ver:",IDC_SCI_VERSION,80,24,219,8 - LTEXT "Kompiliert mit:",IDC_COMPILER,80,35,218,8 - LTEXT "IDC_COPYRIGHT",IDC_COPYRIGHT,80,52,218,8 - LTEXT "IDC_TRANSL_AUTH",IDC_TRANSL_AUTH,80,64,218,8 - LTEXT "",IDC_WEBPAGE2,190,55,100,8,NOT WS_VISIBLE | WS_DISABLED - CONTROL "",IDC_WEBPAGE,"SysLink",WS_TABSTOP,200,52,100,10 - CONTROL IDR_RIZBITMAP,IDC_RIZONEBMP,"Static",SS_BITMAP | SS_NOTIFY | SS_CENTERIMAGE | SS_REALSIZECONTROL,300,7,84,24,WS_EX_TRANSPARENT - PUSHBUTTON "Kopiere Versions Text",IDC_COPYVERSTRG,304,35,76,14,BS_FLAT - CONTROL "",IDC_RICHEDITABOUT,RICHEDIT_CONTROL_VER,WS_VSCROLL | WS_HSCROLL | WS_TABSTOP | 0x29c4,20,80,360,170 + DEFPUSHBUTTON "OK",IDOK,330,266,50,14 + EDITTEXT IDC_VERSION,80,10,220,24,ES_CENTER | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Scintilla Bibliothek Ver:",IDC_SCI_VERSION,80,34,219,8 + LTEXT "Kompiliert mit:",IDC_COMPILER,80,45,218,8 + LTEXT "IDC_COPYRIGHT",IDC_COPYRIGHT,80,62,218,8 + LTEXT "IDC_TRANSL_AUTH",IDC_TRANSL_AUTH,80,74,218,8 + LTEXT "",IDC_WEBPAGE2,190,65,100,8,NOT WS_VISIBLE | WS_DISABLED + CONTROL "",IDC_WEBPAGE,"SysLink",WS_TABSTOP,200,62,100,10 + //CONTROL IDR_RIZBITMAP,IDC_RIZONEBMP,"Static",SS_BITMAP | SS_NOTIFY,304,10,0,0,WS_EX_TRANSPARENT + CONTROL IDR_RIZBITMAP,IDC_RIZONEBMP,"Static",SS_BITMAP | SS_NOTIFY | SS_REALSIZECONTROL,304,10,78,23,WS_EX_TRANSPARENT + PUSHBUTTON "Kopiere Versions Text",IDC_COPYVERSTRG,304,45,76,14,BS_FLAT + CONTROL "",IDC_RICHEDITABOUT,RICHEDIT_CONTROL_VER,WS_VSCROLL | WS_HSCROLL | WS_TABSTOP | 0x29c4,20,90,360,170 END IDD_MUI_CMDLINEHELP DIALOGEX 0, 0, 300, 210 @@ -307,19 +308,19 @@ BEGIN EDITTEXT IDC_STYLEEDIT_ROOT,181,152,279,12,ES_AUTOHSCROLL LTEXT "",IDC_STYLELABEL,181,171,279,8 EDITTEXT IDC_STYLEEDIT,181,183,279,12,ES_AUTOHSCROLL - PUSHBUTTON "&Farbe...",IDC_STYLEFORE,181,201,41,14 - PUSHBUTTON "&Grund...",IDC_STYLEBACK,227,201,41,14 - PUSHBUTTON "&Schriftart...",IDC_STYLEFONT,273,201,52,14 + PUSHBUTTON "&Farbe...",IDC_STYLEFORE,181,201,46,14 + PUSHBUTTON "&Grund...",IDC_STYLEBACK,232,201,46,14 + PUSHBUTTON "&Schriftart...",IDC_STYLEFONT,283,201,52,14 PUSHBUTTON "&Vorschau",IDC_PREVIEW,330,201,42,14 PUSHBUTTON "&Standard",IDC_STYLEDEFAULT,377,201,42,14 PUSHBUTTON "",IDC_PREVSTYLE,426,201,15,14 PUSHBUTTON "",IDC_NEXTSTYLE,445,201,15,14 - PUSHBUTTON "&Importieren...",IDC_IMPORT,181,233,60,14 - PUSHBUTTON "E&xportieren...",IDC_EXPORT,246,233,60,14 - DEFPUSHBUTTON "OK",IDOK,355,233,50,14 - PUSHBUTTON "Abbrechen",IDCANCEL,410,233,50,14 - GROUPBOX "Information",IDC_INFO_GROUPBOX,180,7,280,127 - LTEXT "Syntax Schemata anpassen",IDC_TITLE,264,25,180,12 + PUSHBUTTON "&Importieren...",IDC_IMPORT,181,232,60,14 + PUSHBUTTON "E&xportieren...",IDC_EXPORT,246,232,60,14 + DEFPUSHBUTTON "OK",IDOK,355,232,50,14 + PUSHBUTTON "Abbrechen",IDCANCEL,410,232,50,14 + GROUPBOX "Information",IDC_INFO_GROUPBOX,181,7,280,127 + LTEXT "Syntax Schemata anpassen",IDC_TITLE,240,20,180,24,SS_CENTERIMAGE EDITTEXT IDC_STYLEEDIT_HELP,197,54,252,74,ES_MULTILINE | ES_READONLY | NOT WS_BORDER END @@ -710,11 +711,11 @@ GUIDELINES DESIGNINFO BEGIN IDD_MUI_ABOUT, DIALOG BEGIN - LEFTMARGIN, 4 - VERTGUIDE, 19 - VERTGUIDE, 340 + LEFTMARGIN, 7 + RIGHTMARGIN, 386 + VERTGUIDE, 7 TOPMARGIN, 7 - BOTTOMMARGIN, 270 + BOTTOMMARGIN, 277 END IDD_MUI_FIND, DIALOG @@ -811,7 +812,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 460 TOPMARGIN, 7 - BOTTOMMARGIN, 247 + BOTTOMMARGIN, 246 END IDD_MUI_TABSETTINGS, DIALOG diff --git a/language/np3_en_us/dialogs_en_us.rc b/language/np3_en_us/dialogs_en_us.rc index 54572daab..c50919c7c 100644 --- a/language/np3_en_us/dialogs_en_us.rc +++ b/language/np3_en_us/dialogs_en_us.rc @@ -53,22 +53,23 @@ END // Dialog // -IDD_MUI_ABOUT DIALOGEX 0, 0, 400, 274 +IDD_MUI_ABOUT DIALOGEX 0, 0, 400, 284 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_NOFAILCREATE | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "About Notepad3" FONT 9, "Segoe UI", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDOK,330,256,50,14 - EDITTEXT IDC_VERSION,80,7,220,14,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - LTEXT "Scintilla Library Version:",IDC_SCI_VERSION,80,24,219,8 - LTEXT "Build with:",IDC_COMPILER,80,35,218,8 - LTEXT "IDC_COPYRIGHT",IDC_COPYRIGHT,80,52,218,8 - LTEXT "IDC_TRANSL_AUTH",IDC_TRANSL_AUTH,80,64,218,8 - LTEXT "",IDC_WEBPAGE2,190,55,100,8,NOT WS_VISIBLE | WS_DISABLED - CONTROL "",IDC_WEBPAGE,"SysLink",WS_TABSTOP,200,52,100,10 - CONTROL IDR_RIZBITMAP,IDC_RIZONEBMP,"Static",SS_BITMAP | SS_NOTIFY | SS_CENTERIMAGE | SS_REALSIZECONTROL,300,7,84,24,WS_EX_TRANSPARENT - PUSHBUTTON "Copy Version Text",IDC_COPYVERSTRG,304,35,76,14,BS_FLAT - CONTROL "",IDC_RICHEDITABOUT,RICHEDIT_CONTROL_VER,WS_VSCROLL | WS_HSCROLL | WS_TABSTOP | 0x29c4,20,80,360,170 + DEFPUSHBUTTON "OK",IDOK,330,266,50,14 + EDITTEXT IDC_VERSION,80,10,220,24, ES_CENTER | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Scintilla Library Version:",IDC_SCI_VERSION,80,34,219,8 + LTEXT "Build with:",IDC_COMPILER,80,45,218,8 + LTEXT "IDC_COPYRIGHT",IDC_COPYRIGHT,80,62,218,8 + LTEXT "IDC_TRANSL_AUTH",IDC_TRANSL_AUTH,80,74,218,8 + LTEXT "",IDC_WEBPAGE2,190,65,100,8,NOT WS_VISIBLE | WS_DISABLED + CONTROL "",IDC_WEBPAGE,"SysLink",WS_TABSTOP,200,62,100,10 + //CONTROL IDR_RIZBITMAP,IDC_RIZONEBMP,"Static",SS_BITMAP | SS_NOTIFY,304,10,0,0,WS_EX_TRANSPARENT + CONTROL IDR_RIZBITMAP,IDC_RIZONEBMP,"Static",SS_BITMAP | SS_NOTIFY | SS_REALSIZECONTROL,304,10,78,23,WS_EX_TRANSPARENT + PUSHBUTTON "Copy Version Text",IDC_COPYVERSTRG,304,45,76,14,BS_FLAT + CONTROL "",IDC_RICHEDITABOUT,RICHEDIT_CONTROL_VER,WS_VSCROLL | WS_HSCROLL | WS_TABSTOP | 0x29c4,20,90,360,170 END IDD_MUI_CMDLINEHELP DIALOGEX 0, 0, 300, 210 @@ -298,11 +299,11 @@ BEGIN END IDD_MUI_STYLECONFIG DIALOGEX 0, 0, 467, 254 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Customize Schemes" FONT 9, "Segoe UI", 400, 0, 0x1 BEGIN - CONTROL "",IDC_STYLELIST,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_SINGLEEXPAND | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,164,240 + CONTROL "",IDC_STYLELIST,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_SINGLEEXPAND | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,164,239 LTEXT "",IDC_STYLELABEL_ROOT,181,141,279,8 EDITTEXT IDC_STYLEEDIT_ROOT,181,152,279,12,ES_AUTOHSCROLL LTEXT "",IDC_STYLELABEL,181,171,279,8 @@ -314,12 +315,12 @@ BEGIN PUSHBUTTON "&Reset",IDC_STYLEDEFAULT,377,201,42,14 PUSHBUTTON "",IDC_PREVSTYLE,426,201,15,14 PUSHBUTTON "",IDC_NEXTSTYLE,445,201,15,14 - PUSHBUTTON "&Import...",IDC_IMPORT,181,233,50,14 - PUSHBUTTON "E&xport...",IDC_EXPORT,237,233,50,14 - DEFPUSHBUTTON "OK",IDOK,355,233,50,14 - PUSHBUTTON "Cancel",IDCANCEL,410,233,50,14 + PUSHBUTTON "&Import...",IDC_IMPORT,181,232,50,14 + PUSHBUTTON "E&xport...",IDC_EXPORT,237,232,50,14 + DEFPUSHBUTTON "OK",IDOK,355,232,50,14 + PUSHBUTTON "Cancel",IDCANCEL,410,232,50,14 GROUPBOX "Info",IDC_INFO_GROUPBOX,181,7,280,127 - LTEXT "Customize Schemes",IDC_TITLE,264,25,180,12 + CTEXT "Customize Schemes",IDC_TITLE,240,20,180,24,SS_CENTERIMAGE EDITTEXT IDC_STYLEEDIT_HELP,197,54,252,74,ES_MULTILINE | ES_READONLY | NOT WS_BORDER END @@ -688,7 +689,7 @@ CAPTION "Font Chooser" FONT 9, "Segoe UI", 400, 0, 0x0 BEGIN LTEXT "&Font:",IDC_STATIC,7,7,127,8 - COMBOBOX IDC_FONT_FAMILY_NAMES,7,16,138,84,CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_HASSTRINGS | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_FONT_FAMILY_NAMES,7,16,138,84,CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP LTEXT "F&ont Style:",IDC_STATIC,154,7,72,8 COMBOBOX IDC_FONT_FACE_NAMES,154,16,84,84,CBS_SIMPLE | WS_VSCROLL | WS_TABSTOP LTEXT "&Size:",IDC_STATIC,247,7,40,8 @@ -710,11 +711,11 @@ GUIDELINES DESIGNINFO BEGIN IDD_MUI_ABOUT, DIALOG BEGIN - LEFTMARGIN, 4 - VERTGUIDE, 19 - VERTGUIDE, 340 + LEFTMARGIN, 7 + RIGHTMARGIN, 386 + VERTGUIDE, 7 TOPMARGIN, 7 - BOTTOMMARGIN, 270 + BOTTOMMARGIN, 277 END IDD_MUI_FIND, DIALOG @@ -811,7 +812,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 460 TOPMARGIN, 7 - BOTTOMMARGIN, 247 + BOTTOMMARGIN, 246 END IDD_MUI_TABSETTINGS, DIALOG diff --git a/res/rizonesoft.bmp b/res/rizonesoft.bmp index fe4e34d9c..63927ed28 100644 Binary files a/res/rizonesoft.bmp and b/res/rizonesoft.bmp differ diff --git a/src/Dialogs.c b/src/Dialogs.c index e23e101d2..18bdcf519 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -715,13 +715,22 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam GetLngStringA(IDS_MUI_ABOUT_RTF_6, pAboutRes, COUNTOF(pAboutRes)); StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes); - // paint richedit box + // paint rich-edit box pAboutInfo = pAboutResource; EDITSTREAM editStreamIn = { (DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallback }; SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn); + DPI_T const dpi = Scintilla_GetWindowDPI(hwnd); + SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, (WPARAM)dpi.y, (LPARAM)USER_DEFAULT_SCREEN_DPI); + CenterDlgInParent(hwnd, NULL); + // TODO: Handle initial DPI-Aware Bitmap drawing + //HWND const hCtrlBmp = GetDlgItem(hwnd, IDC_RIZONEBMP); + //if (hCtrlBmp) { + // UpdateWindowLayoutForDPI(hCtrlBmp, NULL, &dpi); + //} + //PostMessage(hwnd, WM_DPICHANGED, (WPARAM)NULL, (LPARAM)NULL); } break; @@ -733,27 +742,16 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam { UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, NULL); - DPI_T dpi; + DPI_T dpi; dpi.x = LOWORD(wParam); dpi.y = HIWORD(wParam); - - SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, (WPARAM)dpi.y, (LPARAM)USER_DEFAULT_SCREEN_DPI); - - //~~// get current richedit box format - //~~CHARFORMAT2 currentFormat; ZeroMemory(¤tFormat, sizeof(CHARFORMAT2)); currentFormat.cbSize = sizeof(CHARFORMAT2); - //~~currentFormat.dwMask = CFM_ALL2; // CFM_SIZE | CFM_FACE | CFM_CHARSET | CFM_LCID; CFM_ALL; CFM_ALL2; - //~~SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)¤tFormat); - //~~ - //~~//CHARFORMAT dpiCharFmt; ZeroMemory(&dpiCharFmt, sizeof(CHARFORMAT)); dpiCharFmt.cbSize = sizeof(CHARFORMAT); - //~~//dpiCharFmt.dwMask = CFM_ALL; CFM_SIZE; //~ | CFM_FACE; - //~~CHARFORMAT2 dpiCharFmt = currentFormat; - //~~dpiCharFmt.yHeight = (currentFormat.yHeight == 180) ? ScaleIntToDPI_Y(hwnd, 180) : currentFormat.yHeight; // keep size - //~~//~StringCchCopy(dpiCharFmt.szFaceName, COUNTOF(dpiCharFmt.szFaceName), L"Segoe UI"); - //~~SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&dpiCharFmt); + if ((dpi.x == USER_DEFAULT_SCREEN_DPI) || (dpi.y == USER_DEFAULT_SCREEN_DPI)) { + SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, 0, 0); // rich edit problem + } } break; - +#if TRUE case WM_PAINT: { HDC const hDC = GetWindowDC(hwnd); @@ -767,24 +765,99 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam } // --- larger bold condensed version string - int const height = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72); if (hVersionFont) { DeleteObject(hVersionFont); } hVersionFont = GetStockObject(DEFAULT_GUI_FONT); LOGFONT lf; GetObject(hVersionFont, sizeof(LOGFONT), &lf); + int const newHeight = -MulDiv(MulDiv(lf.lfHeight, 3, 2), GetDeviceCaps(hDC, LOGPIXELSY), 72); lf.lfWeight = FW_BOLD; - lf.lfHeight = ScaleIntToDPI_Y(hwnd, height); - lf.lfWidth = 0; // the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts - //StringCchCopy(lf.lfFaceName, LF_FACESIZE, L"Segoe UI"); + lf.lfHeight = ScaleIntToDPI_Y(hwnd, newHeight); + lf.lfWidth = ScaleIntToDPI_X(hwnd, 8); // =0: the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts + StringCchCopy(lf.lfFaceName, LF_FACESIZE, L"Tahoma"); hVersionFont = CreateFontIndirect(&lf); SendDlgItemMessage(hwnd, IDC_VERSION, WM_SETFONT, (WPARAM)hVersionFont, true); ReleaseDC(hwnd, hDC); - - // rich edit control - SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, 0, 0); } return 0; +#else + case WM_PAINT: + { + PAINTSTRUCT ps; + // Get a paint DC for current window. + // Paint DC contains the right scaling to match + // the monitor DPI where the window is located. + HDC hdc = BeginPaint(hwnd, &ps); + + RECT rect; + GetClientRect(hwnd, &rect); + + UINT cx = (rect.right - rect.left); + UINT cy = (rect.bottom - rect.top); + + // Create a compatible bitmap using paint DC. + // Compatible bitmap will be properly scaled in size internally and + // transparently to the app to match current monitor DPI where + // the window is located. + HBITMAP memBitmap = CreateCompatibleBitmap(hdc, cx, cy); + + // Create a compatible DC, even without a bitmap selected, + // compatible DC will inherit the paint DC GDI scaling + // matching the window monitor DPI. + HDC memDC = CreateCompatibleDC(hdc); + + // Selecting GDI scaled compatible bitmap in the + // GDI scaled compatible DC. + HBITMAP oldBitmap = (HBITMAP)SelectObject(memDC, memBitmap); + + // Setting some properties in the compatible GDI scaled DC. + if (hVersionFont) { + DeleteObject(hVersionFont); + } + hVersionFont = GetStockObject(DEFAULT_GUI_FONT); + + SetTextColor(memDC, GetSysColor(COLOR_INFOTEXT)); + SetBkMode(memDC, TRANSPARENT); + SelectObject(memDC, hVersionFont); + + // Drawing content on the compatible GDI scaled DC. + // If the monitor DPI was 150% or 200%, text internally will + // be draw at next integral scaling value, in current example + // 200%. + DrawText(memDC, ctx.balloonText, -1, &rect, + DT_NOCLIP | DT_LEFT | DT_NOPREFIX | DT_WORDBREAK); + + // Copying the content back from compatible DC to paint DC. + // Since both compatible DC and paint DC are GDI scaled, + // content is copied without any stretching thus preserving + // the quality of the rendering. + BitBlt(hdc, 0, 0, cx, cy, memDC, 0, 0); + + // Cleanup. + SelectObject(memDC, oldBitmap); + DeleteObject(memBitmap); + DeleteDC(memDC); + + // At this time the content is presented to the screen. + // DWM (Desktop Window Manager) will scale down if required the + // content to actual monitor DPI. + // If the monitor DPI is already an integral one, for example 200%, + // there would be no DWM down scaling. + // If the monitor DPI is 150%, DWM will scale down rendered content + // from 200% to 150%. + // While not a perfect solution, it's better to scale-down content + // instead of scaling-up since a lot of the details will be preserved + // during scale-down. + // The end result is that with GDI Scaling enabled, the content will + // look less blurry on screen and in case of monitors with DPI setting + // set to an integral value (200%, 300%) the vector based and text + // content will be rendered natively at the monitor DPI looking crisp + // on screen. + + EndPaint(hwnd, &ps); + } break; + +#endif case WM_NOTIFY: { @@ -4592,7 +4665,7 @@ void SetUACIcon(const HMENU hMenu, const UINT nItem) // // UpdateWindowLayoutForDPI() // -void UpdateWindowLayoutForDPI(HWND hWnd, RECT* pRC, DPI_T* pDPI) +void UpdateWindowLayoutForDPI(HWND hWnd, const RECT* pRC, const DPI_T* pDPI) { UINT const uWndFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED; //~ SWP_NOMOVE | SWP_NOSIZE | SWP_NOREPOSITION if (pRC) { @@ -4604,13 +4677,13 @@ void UpdateWindowLayoutForDPI(HWND hWnd, RECT* pRC, DPI_T* pDPI) RECT rc; GetWindowRect(hWnd, &rc); - //MapWindowPoints(NULL, hWnd, (LPPOINT)&rc, 2); + //~MapWindowPoints(NULL, hWnd, (LPPOINT)&rc, 2); LONG const width = rc.right - rc.left; LONG const height = rc.bottom - rc.top; - int dpiScaledX = MulDiv(rc.left, wndDPI.x, USER_DEFAULT_SCREEN_DPI); - int dpiScaledY = MulDiv(rc.top, wndDPI.y, USER_DEFAULT_SCREEN_DPI); - int dpiScaledWidth = MulDiv(width, wndDPI.x, USER_DEFAULT_SCREEN_DPI); - int dpiScaledHeight = MulDiv(height, wndDPI.y, USER_DEFAULT_SCREEN_DPI); + int const dpiScaledX = MulDiv(rc.left, wndDPI.x, USER_DEFAULT_SCREEN_DPI); + int const dpiScaledY = MulDiv(rc.top, wndDPI.y, USER_DEFAULT_SCREEN_DPI); + int const dpiScaledWidth = MulDiv(width, wndDPI.x, USER_DEFAULT_SCREEN_DPI); + int const dpiScaledHeight = MulDiv(height, wndDPI.y, USER_DEFAULT_SCREEN_DPI); SetWindowPos(hWnd, NULL, dpiScaledX, dpiScaledY, dpiScaledWidth, dpiScaledHeight, uWndFlags); } diff --git a/src/Dialogs.h b/src/Dialogs.h index 4d25de86d..cf50ff0a0 100644 --- a/src/Dialogs.h +++ b/src/Dialogs.h @@ -129,9 +129,9 @@ inline int ScaleFloatToDPI_Y(HWND hwnd, float fVal) { DPI_T const dpi = Scintill HBITMAP ConvertIconToBitmap(const HICON hIcon, const int cx, const int cy); void SetUACIcon(const HMENU hMenu, const UINT nItem); -void UpdateWindowLayoutForDPI(HWND hWnd, RECT* pRC, DPI_T* pDPI); -//#define HandleDpiChangedMessage(hW, wP,lP) { DPI_T dpi; dpi.x = LOWORD(wP); dpi.y = HIWORD(wP); \ -// UpdateWindowLayoutForDPI(hW, (RECT*)lP, pRC, DPI_T* pDPI); } +void UpdateWindowLayoutForDPI(HWND hWnd, const RECT* pRC, const DPI_T* pDPI); +//#define HandleDpiChangedMessage(hW,wP,lP) { DPI_T dpi; dpi.x = LOWORD(wP); dpi.y = HIWORD(wP); \ +// UpdateWindowLayoutForDPI(hW, (RECT*)lP, &dpi); } HBITMAP ResizeImageForCurrentDPI(HWND hwnd, HBITMAP hbmp); LRESULT SendWMSize(HWND hwnd, RECT* rc); diff --git a/src/Edit.c b/src/Edit.c index 00bfcabac..907e41aeb 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5891,8 +5891,13 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, NULL); - return !0; // further processing + { + DPI_T dpi; + dpi.x = LOWORD(wParam); + dpi.y = HIWORD(wParam); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, &dpi); + } + return !0; // further processing case WM_ACTIVATE: @@ -7848,7 +7853,12 @@ static INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPA case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, NULL); + { + DPI_T dpi; + dpi.x = LOWORD(wParam); + dpi.y = HIWORD(wParam); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, &dpi); + } return true; @@ -7993,8 +8003,13 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam return true; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, NULL); - return true; + { + DPI_T dpi; + dpi.x = LOWORD(wParam); + dpi.y = HIWORD(wParam); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, &dpi); + } + return true; case WM_DESTROY: DeleteObject(hFontHover); diff --git a/src/Notepad3.c b/src/Notepad3.c index 7ddf15092..51a2d726a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1216,7 +1216,7 @@ bool InitApplication(HINSTANCE hInstance) wc.hInstance = hInstance; wc.hIcon = Globals.hDlgIcon256; wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MUI_MAINMENU); wc.lpszClassName = s_wchWndClass; diff --git a/src/Styles.c b/src/Styles.c index 074439c1a..34ada71cb 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -3967,6 +3967,7 @@ static bool _ApplyDialogItemText(HWND hwnd, INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { static HWND hwndTV; + static HFONT hFontTitle = NULL; static bool fDragging; static PEDITLEXER pCurrentLexer = NULL; static PEDITSTYLE pCurrentStyle = NULL; @@ -4070,15 +4071,11 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar bWarnedNoIniFile = false; - //UpdateWindowLayoutForDPI(hwnd, NULL, NULL); + //~UpdateWindowLayoutForDPI(hwnd, NULL, NULL); + PostMessage(hwnd, WM_DPICHANGED, (WPARAM)NULL, (LPARAM)NULL); } return !0; - case WM_ENABLE: - // modal child dialog should disable main window too - EnableWindow(Globals.hwndMain, (BOOL)wParam); - return !0; - case WM_PAINT: { HDC const hDC = GetWindowDC(hwnd); @@ -4093,48 +4090,40 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar } // Set title font - static HFONT hFontTitle = NULL; - int const height = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72); - if (hFontTitle) - { - DeleteObject(hFontTitle); - } + if (hFontTitle) { DeleteObject(hFontTitle); } hFontTitle = GetStockObject(DEFAULT_GUI_FONT); - LOGFONT lf; - GetObject(hFontTitle, sizeof(LOGFONT), &lf); + LOGFONT lf; GetObject(hFontTitle, sizeof(LOGFONT), &lf); + int const newHeight = -MulDiv(MulDiv(lf.lfHeight,3,2), GetDeviceCaps(hDC, LOGPIXELSY), 72); lf.lfWeight = FW_BOLD; - lf.lfHeight = ScaleIntToDPI_Y(hwnd, height); - lf.lfWidth = 0; // the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts - hFontTitle = CreateFontIndirect(&lf); + lf.lfHeight = ScaleIntToDPI_Y(hwnd, newHeight); + lf.lfWidth = ScaleIntToDPI_X(hwnd, 8); // =0: the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts + StringCchCopy(lf.lfFaceName, LF_FACESIZE, L"Tahoma"); + hFontTitle = CreateFontIndirect(&lf); SendDlgItemMessage(hwnd, IDC_TITLE, WM_SETFONT, (WPARAM)hFontTitle, true); ReleaseDC(hwnd, hDC); } return 0; + case WM_ENABLE: + // modal child dialog should disable main window too + EnableWindow(Globals.hwndMain, (BOOL)wParam); + return !0; + case WM_ACTIVATE: DialogEnableControl(hwnd, IDC_PREVIEW, ((pCurrentLexer == s_pLexCurrent) || (pCurrentLexer == GetCurrentStdLexer()))); return !0; case WM_DESTROY: - { - DeleteBitmapButton(hwnd, IDC_STYLEFORE); - DeleteBitmapButton(hwnd, IDC_STYLEBACK); - DeleteBitmapButton(hwnd, IDC_PREVSTYLE); - DeleteBitmapButton(hwnd, IDC_NEXTSTYLE); - - // free old backup - int cnt = 0; - for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { - if (Style_StylesBackup[cnt]) - { - LocalFree(Style_StylesBackup[cnt]); // StrDup() - Style_StylesBackup[cnt] = NULL; - } - ++cnt; - int i = 0; - while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) + DeleteBitmapButton(hwnd, IDC_STYLEFORE); + DeleteBitmapButton(hwnd, IDC_STYLEBACK); + DeleteBitmapButton(hwnd, IDC_PREVSTYLE); + DeleteBitmapButton(hwnd, IDC_NEXTSTYLE); + + // free old backup + int cnt = 0; + for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { if (Style_StylesBackup[cnt]) { @@ -4142,13 +4131,26 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar Style_StylesBackup[cnt] = NULL; } ++cnt; - ++i; + int i = 0; + while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) + { + if (Style_StylesBackup[cnt]) + { + LocalFree(Style_StylesBackup[cnt]); // StrDup() + Style_StylesBackup[cnt] = NULL; + } + ++cnt; + ++i; + } } + if (hFontTitle) { + DeleteObject(hFontTitle); + hFontTitle = NULL; + } + pCurrentLexer = NULL; + pCurrentStyle = NULL; + iCurStyleIdx = -1; } - pCurrentLexer = NULL; - pCurrentStyle = NULL; - iCurStyleIdx = -1; - } return false; case WM_DPICHANGED: