From 962d6ec2da25ff24cfe9bad6ce6daba466db822a Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Fri, 8 May 2020 15:39:16 +0200 Subject: [PATCH] + chg: minor changes for dialog handling on DPI changed --- .editorconfig | 3 + grepWinNP3/src/Resources/grepWin.rc | 16 +-- language/common_res.rc | 13 ++- language/np3_en_us/dialogs_en_us.rc | 2 +- scintilla/win32/PlatWin.cxx | 17 ++- src/Dialogs.c | 58 +++++----- src/Edit.h | 4 +- src/Notepad3.c | 4 +- src/Styles.c | 160 +++++++++------------------- 9 files changed, 118 insertions(+), 159 deletions(-) diff --git a/.editorconfig b/.editorconfig index c6f838a4a..28162d3f4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -30,3 +30,6 @@ charset = utf-8 indent_style = space indent_size = 4 tab_width = 4 + +[language/common_res.rc] +charset = latin1 diff --git a/grepWinNP3/src/Resources/grepWin.rc b/grepWinNP3/src/Resources/grepWin.rc index 14fa7cb52..26c6fd292 100644 --- a/grepWinNP3/src/Resources/grepWin.rc +++ b/grepWinNP3/src/Resources/grepWin.rc @@ -37,10 +37,10 @@ IDI_GREPWIN ICON "grepWinNP3.ico" ///////////////////////////////////////////////////////////////////////////// -// English (United States) resources +// Neutral resources -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #pragma code_page(1252) ///////////////////////////////////////////////////////////////////////////// @@ -401,15 +401,15 @@ BEGIN IDS_ERR_PATHNOTEXIST "Path does not exist or is not accessible!" END -#endif // English (United States) resources +#endif // Neutral resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// German (Switzerland) resources +// Neutral resources -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DES) -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_SWISS +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #pragma code_page(1252) #ifdef APSTUDIO_INVOKED @@ -441,7 +441,7 @@ END #endif // APSTUDIO_INVOKED -#endif // German (Switzerland) resources +#endif // Neutral resources ///////////////////////////////////////////////////////////////////////////// diff --git a/language/common_res.rc b/language/common_res.rc index 596e6c789..65ed68a64 100644 --- a/language/common_res.rc +++ b/language/common_res.rc @@ -1,8 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // Language independant string resources ///////////////////////////////////////////////////////////////////////////// -// encoding: UTF-8 -#pragma code_page(65001) // UTF-8 +// encoding: CP-1252 #include "common_res.h" #define APSTUDIO_READONLY_SYMBOLS @@ -15,6 +14,7 @@ ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS + #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // @@ -69,6 +69,12 @@ IDR_RIZBITMAP BITMAP "rizonesoft.bmp" IDC_COPY CURSOR "Copy.cur" +// ============================================================================= +// Following Text is streamed to RichEdit Control supporting ANSI CP-1252 only +// Unicode characters have to be encoded using '\\uN' squences. +// Example: Küng => K\\u252üng +// ============================================================================= + STRINGTABLE BEGIN @@ -95,7 +101,7 @@ IDS_MUI_ABOUT_CONTRIBS "\ IDS_MUI_ABOUT_LIBS "\ \\cf0 N.Hodgson (Scintilla)\\tab https://www.scintilla.org/\\par\ \\cf0 K.Kosako (Oniguruma Regex)\\tab https://github.com/kkos/oniguruma/\\par\ -\\cf0 Stefan Küng (grepWin)\\tab https://github.com/stefankueng/grepWin/\\par\ +\\cf0 Stefan K\\u252üng (grepWin)\\tab https://github.com/stefankueng/grepWin/\\par\ \\cf0 D.Dyer (NotepadCrypt)\\tab https://www.real-me.net/ddyer/notepad/NotepadCrypt.html\\par\ \\cf0 T.D.Hanson (uthash)\\tab https://troydhanson.github.io/uthash/\\par\ \\cf0 Carbo Kuo (Mozilla's uchardet)\\tab https://www.freedesktop.org/wiki/Software/uchardet/\\par\ @@ -189,7 +195,6 @@ IDS_MUI_ABOUT_RTF_6 "\ END - #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // diff --git a/language/np3_en_us/dialogs_en_us.rc b/language/np3_en_us/dialogs_en_us.rc index 7b69a77d7..d55116b19 100644 --- a/language/np3_en_us/dialogs_en_us.rc +++ b/language/np3_en_us/dialogs_en_us.rc @@ -324,7 +324,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,355,233,50,14 PUSHBUTTON "Cancel",IDCANCEL,410,233,50,14 EDITTEXT IDC_STYLEEDIT_HELP,197,54,252,74,ES_MULTILINE | ES_READONLY | NOT WS_BORDER - SCROLLBAR IDC_RESIZEGRIP,7,233,10,10 + //@@@SCROLLBAR IDC_RESIZEGRIP,7,233,10,10 END IDD_MUI_TABSETTINGS DIALOGEX 0, 0, 174, 114 diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx index 1be74113b..32276fbff 100644 --- a/scintilla/win32/PlatWin.cxx +++ b/scintilla/win32/PlatWin.cxx @@ -3548,9 +3548,11 @@ void Platform_Finalise(bool fromDllMain) noexcept { // #ifdef _WIN64 typedef INT_PTR(FAR WINAPI* FARPROCHWND)(HWND); +typedef INT_PTR(FAR WINAPI* FARPROCDPI)(int, UINT); typedef INT_PTR(FAR WINAPI* FARPROCMONI)(HMONITOR, int, UINT*, UINT*); #else typedef int (FAR WINAPI* FARPROCHWND)(HWND); +typedef int (FAR WINAPI* FARPROCHDPI)(int, UINT); typedef int (FAR WINAPI* FARPROCMONI)(HMONITOR, int, UINT*, UINT*); #endif // _WIN64 @@ -3561,7 +3563,7 @@ DPI_T GetCurrentDPI(HWND hwnd) { if (IsWindows10OrGreater()) { static HMODULE hModule = nullptr; - if (!hModule) { hModule = GetModuleHandle(L"user32.dll"); } + if (!hModule) { hModule = GetModuleHandle(L"User32.dll"); } if (hModule) { FARPROCHWND const pfnGetDpiForWindow = (FARPROCHWND)GetProcAddress(hModule, "GetDpiForWindow"); if (pfnGetDpiForWindow) { @@ -3606,7 +3608,18 @@ DPI_T GetCurrentDPI(HWND hwnd) { // int GetSystemMetricsEx(HWND hwnd, int nIndex) { + if (IsWindows10OrGreater()) { + static HMODULE hModule = nullptr; + if (!hModule) { hModule = GetModuleHandle(L"User32.dll"); } + if (hModule) { + FARPROCHWND const pfnGetDpiForWindow = (FARPROCHWND)GetProcAddress(hModule, "GetDpiForWindow"); + FARPROCDPI const pfnGetSystemMetricsForDpi = (FARPROCDPI)GetProcAddress(hModule, "GetSystemMetricsForDpi"); + if (pfnGetDpiForWindow && pfnGetSystemMetricsForDpi) { + return (int)pfnGetSystemMetricsForDpi(nIndex, (UINT)pfnGetDpiForWindow(hwnd)); + } + } + } return ScaleIntToDPI_Y(hwnd, GetSystemMetrics(nIndex)); } -} +} // namespace Scintilla diff --git a/src/Dialogs.c b/src/Dialogs.c index 0e38e5cb7..09e62e070 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -668,8 +668,9 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETEVENTMASK, 0, (LPARAM)(ENM_LINK)); // link click char pAboutRes[4096]; + StringCchCopyA(pAboutResource, COUNTOF(pAboutResource), ""); GetLngStringA(IDS_MUI_ABOUT_RTF_0, pAboutRes, COUNTOF(pAboutRes)); - StringCchCopyA(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes); GetLngStringA(IDS_MUI_ABOUT_DEV, pAboutRes, COUNTOF(pAboutRes)); StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes); GetLngStringA(IDS_MUI_ABOUT_RTF_1, pAboutRes, COUNTOF(pAboutRes)); @@ -710,7 +711,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam if (hVersionFont) { DeleteObject(hVersionFont); } break; - + case WM_SIZE: case WM_DPICHANGED: { UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); @@ -1121,12 +1122,10 @@ static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM case WM_SIZE: { - int dx; - int dy; - HDWP hdwp; - + int dx, dy; ResizeDlg_Size(hwnd,lParam,&dx,&dy); + HDWP hdwp; hdwp = BeginDeferWindowPos(6); hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE); hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); @@ -1138,12 +1137,12 @@ static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVSCW_AUTOSIZE_USEHEADER); } - return true; + return !0; case WM_GETMINMAXINFO: ResizeDlg_GetMinMaxInfo(hwnd,lParam); - return true; + return !0; case WM_NOTIFY: @@ -1321,12 +1320,10 @@ static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case WM_SIZE: { - int dx; - int dy; - HDWP hdwp; - + int dx, dy; ResizeDlg_Size(hwnd,lParam,&dx,&dy); + HDWP hdwp; hdwp = BeginDeferWindowPos(6); hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE); hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); @@ -3965,7 +3962,7 @@ typedef const RESIZEDLG* LPCRESIZEDLG; void ResizeDlg_InitEx(HWND hwnd, int cxFrame, int cyFrame, int nIdGrip, int iDirection) { - RESIZEDLG* pm = (RESIZEDLG*)AllocMem(sizeof(RESIZEDLG), HEAP_ZERO_MEMORY); + RESIZEDLG* const pm = (RESIZEDLG*)AllocMem(sizeof(RESIZEDLG), HEAP_ZERO_MEMORY); pm->direction = iDirection; RECT rc; @@ -3976,12 +3973,12 @@ void ResizeDlg_InitEx(HWND hwnd, int cxFrame, int cyFrame, int nIdGrip, int iDir AdjustWindowRectEx(&rc, GetWindowLong(hwnd, GWL_STYLE) | WS_THICKFRAME, FALSE, 0); pm->mmiPtMinX = rc.right - rc.left; pm->mmiPtMinY = rc.bottom - rc.top; + // only one direction switch (iDirection) { case ResizeDlgDirection_OnlyX: pm->mmiPtMaxY = pm->mmiPtMinY; break; - case ResizeDlgDirection_OnlyY: pm->mmiPtMaxX = pm->mmiPtMinX; break; @@ -3997,30 +3994,31 @@ void ResizeDlg_InitEx(HWND hwnd, int cxFrame, int cyFrame, int nIdGrip, int iDir SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | WS_THICKFRAME); SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - WCHAR wch[64]; + WCHAR wch[MAX_PATH]; GetMenuString(GetSystemMenu(GetParent(hwnd), FALSE), SC_SIZE, wch, COUNTOF(wch), MF_BYCOMMAND); InsertMenu(GetSystemMenu(hwnd, FALSE), SC_CLOSE, MF_BYCOMMAND | MF_STRING | MF_ENABLED, SC_SIZE, wch); InsertMenu(GetSystemMenu(hwnd, FALSE), SC_CLOSE, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); - HWND hwndCtl = GetDlgItem(hwnd, nIdGrip); + HWND const hwndCtl = GetDlgItem(hwnd, nIdGrip); SetWindowLongPtr(hwndCtl, GWL_STYLE, GetWindowLongPtr(hwndCtl, GWL_STYLE) | SBS_SIZEGRIP | WS_CLIPSIBLINGS); - /// TODO: per-window DPI + const int cGrip = Scintilla_GetSystemMetricsEx(hwnd, SM_CXHTHUMB); SetWindowPos(hwndCtl, NULL, pm->cxClient - cGrip, pm->cyClient - cGrip, cGrip, cGrip, SWP_NOZORDER); } -void ResizeDlg_Destroy(HWND hwnd, int* cxFrame, int* cyFrame) { - PRESIZEDLG pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY); + +void ResizeDlg_Destroy(HWND hwnd, int* cxFrame, int* cyFrame) +{ + PRESIZEDLG const pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY); RECT rc; GetWindowRect(hwnd, &rc); if (cxFrame) { - *cxFrame = rc.right - rc.left; + *cxFrame = (rc.right - rc.left); } if (cyFrame) { - *cyFrame = rc.bottom - rc.top; + *cyFrame = (rc.bottom - rc.top); } - RemoveProp(hwnd, RESIZEDLG_PROP_KEY); FreeMem(pm); } @@ -4040,7 +4038,8 @@ void ResizeDlg_Size(HWND hwnd, LPARAM lParam, int* cx, int* cy) pm->cyClient = cyClient; } -void ResizeDlg_GetMinMaxInfo(HWND hwnd, LPARAM lParam) { +void ResizeDlg_GetMinMaxInfo(HWND hwnd, LPARAM lParam) +{ LPCRESIZEDLG pm = (LPCRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY); LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; @@ -4071,7 +4070,6 @@ int ResizeDlg_GetAttr(HWND hwnd, int index) { const LPCRESIZEDLG pm = (LPCRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY); return pm->attrs[index]; } - return 0; } @@ -4083,7 +4081,7 @@ static inline int GetDlgCtlHeight(HWND hwndDlg, int nCtlId) { } void ResizeDlgCtl(HWND hwndDlg, int nCtlId, int dx, int dy) { - HWND hwndCtl = GetDlgItem(hwndDlg, nCtlId); + HWND const hwndCtl = GetDlgItem(hwndDlg, nCtlId); RECT rc; GetWindowRect(hwndCtl, &rc); MapWindowPoints(NULL, hwndDlg, (LPPOINT)& rc, 2); @@ -4093,7 +4091,7 @@ void ResizeDlgCtl(HWND hwndDlg, int nCtlId, int dx, int dy) { HDWP DeferCtlPos(HDWP hdwp, HWND hwndDlg, int nCtlId, int dx, int dy, UINT uFlags) { - HWND hwndCtl = GetDlgItem(hwndDlg, nCtlId); + HWND const hwndCtl = GetDlgItem(hwndDlg, nCtlId); RECT rc; GetWindowRect(hwndCtl, &rc); MapWindowPoints(NULL, hwndDlg, (LPPOINT)& rc, 2); @@ -4524,19 +4522,18 @@ if (!bSucceed) { // void UpdateWindowLayoutForDPI(HWND hWnd, int x_96dpi, int y_96dpi, int w_96dpi, int h_96dpi) { -#if TRUE +#if FALSE // only update yet SetWindowPos(hWnd, hWnd, x_96dpi, y_96dpi, w_96dpi, h_96dpi, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOREPOSITION); #else - //@@@ TODO: ??? UNUSED(x_96dpi); UNUSED(y_96dpi); UNUSED(w_96dpi); UNUSED(h_96dpi); - DPI_T const wndDPI = GetCurrentDPI(hWnd); + DPI_T const wndDPI = Scintilla_GetCurrentDPI(hWnd); RECT rc; GetWindowRect(hWnd, &rc); @@ -4549,7 +4546,8 @@ void UpdateWindowLayoutForDPI(HWND hWnd, int x_96dpi, int y_96dpi, int w_96dpi, int dpiScaledHeight = MulDiv(height, wndDPI.y, USER_DEFAULT_SCREEN_DPI); SetWindowPos(hWnd, NULL, dpiScaledX, dpiScaledY, dpiScaledWidth, dpiScaledHeight, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOREPOSITION); + SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOREPOSITION | SWP_FRAMECHANGED); + InvalidateRect(hWnd, NULL, TRUE); #endif diff --git a/src/Edit.h b/src/Edit.h index 457baed80..e6f5af1e7 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -91,8 +91,8 @@ void EditEnsureConsistentLineEndings(HWND hwnd); void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt); HWND EditFindReplaceDlg(HWND hwnd,LPCEDITFINDREPLACE lpefr,bool); -bool EditFindNext(HWND hwnd,LPCEDITFINDREPLACE lpefr,bool,bool); -bool EditFindPrev(HWND hwnd,LPCEDITFINDREPLACE lpefr,bool,bool); +bool EditFindNext(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bool bFocusWnd); +bool EditFindPrev(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bool bFocusWnd); bool EditReplace(HWND hwnd,LPCEDITFINDREPLACE lpefr); int EditReplaceAllInRange(HWND hwnd,LPCEDITFINDREPLACE lpefr,DocPos iStartPos,DocPos iEndPos,DocPos* enlargement); bool EditReplaceAll(HWND hwnd,LPCEDITFINDREPLACE lpefr,bool); diff --git a/src/Notepad3.c b/src/Notepad3.c index b4b7b224c..85c4af8cf 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -4942,11 +4942,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } SciCall_GetSelText(szSelection); - SetFindReplaceData(); // s_FindReplaceData - SetFindPatternMB(szSelection); MRU_Add(Globals.pMRUfind, GetFindPattern(), 0, -1, -1, NULL); + SetFindReplaceData(); // s_FindReplaceData + StringCchCopyA(s_FindReplaceData.szFind, COUNTOF(s_FindReplaceData.szFind), szSelection); s_FindReplaceData.fuFlags &= (~(SCFIND_REGEXP | SCFIND_POSIX)); s_FindReplaceData.bTransformBS = false; diff --git a/src/Styles.c b/src/Styles.c index 0d06e2325..c0d488851 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -603,7 +603,6 @@ bool Style_ImportFromFile(const WCHAR* szFile) s_cxStyleSelectDlg = clampi(IniSectionGetInt(IniSecStyles, L"SelectDlgSizeX", STYLESELECTDLG_X), 0, 8192); s_cyStyleSelectDlg = clampi(IniSectionGetInt(IniSecStyles, L"SelectDlgSizeY", STYLESELECTDLG_Y), 0, 8192); - // Lexer for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) { @@ -3891,11 +3890,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case WM_ACTIVATE: DialogEnableControl(hwnd, IDC_PREVIEW, ((pCurrentLexer == s_pLexCurrent) || (pCurrentLexer == GetCurrentStdLexer()))); - return true; - - case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - return true; + return !0; case WM_DESTROY: { @@ -3929,19 +3924,12 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam } return false; + case WM_SIZE: + case WM_DPICHANGED: + UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); + return !0; - case WM_SYSCOMMAND: - if (wParam == IDS_MUI_SAVEPOS) { - PostWMCommand(hwnd, IDACC_SAVEPOS); - return true; - } - else if (wParam == IDS_MUI_RESETPOS) { - PostWMCommand(hwnd, IDACC_RESETPOS); - return true; - } - else - return false; - +#if 0 case WM_SIZE: { int dx; @@ -3970,12 +3958,25 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam hdwp = DeferCtlPos(hdwp, hwnd, IDC_STYLEEDIT_HELP, dx, dy, SWP_NOSIZE); EndDeferWindowPos(hdwp); } - return TRUE; - + return !0; +#endif case WM_GETMINMAXINFO: ResizeDlg_GetMinMaxInfo(hwnd, lParam); - return TRUE; + return !0; + + + case WM_SYSCOMMAND: + if (wParam == IDS_MUI_SAVEPOS) { + PostWMCommand(hwnd, IDACC_SAVEPOS); + return !0; + } + else if (wParam == IDS_MUI_RESETPOS) { + PostWMCommand(hwnd, IDACC_RESETPOS); + return !0; + } + else + return 0; case WM_NOTIFY: @@ -4466,11 +4467,8 @@ static int _s_idefaultLexer = -1; INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { - static int cxClient; static int cyClient; - static int mmiPtMaxY; - static int mmiPtMinX; static HWND hwndLV; static int iInternalDefault; @@ -4481,53 +4479,25 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR { SET_NP3_DLG_ICON_SMALL(hwnd); - LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - - RECT rc; - GetClientRect(hwnd,&rc); - cxClient = rc.right - rc.left; - cyClient = rc.bottom - rc.top; - - AdjustWindowRectEx(&rc,GetWindowLong(hwnd,GWL_STYLE)|WS_THICKFRAME,false,0); - mmiPtMinX = rc.right-rc.left; - mmiPtMaxY = rc.bottom-rc.top; - - if (s_cxStyleSelectDlg < (rc.right-rc.left)) - s_cxStyleSelectDlg = rc.right-rc.left; - if (s_cyStyleSelectDlg < (rc.bottom-rc.top)) - s_cyStyleSelectDlg = rc.bottom-rc.top; - SetWindowPos(hwnd,NULL,rc.left,rc.top,s_cxStyleSelectDlg,s_cyStyleSelectDlg,SWP_NOZORDER); - - SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME); - SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); - - WCHAR tch[MAX_PATH] = { L'\0' }; - GetMenuString(GetSystemMenu(GetParent(hwnd),false),SC_SIZE,tch,COUNTOF(tch),MF_BYCOMMAND); - InsertMenu(GetSystemMenu(hwnd,false),SC_CLOSE,MF_BYCOMMAND|MF_STRING|MF_ENABLED,SC_SIZE,tch); - InsertMenu(GetSystemMenu(hwnd,false),SC_CLOSE,MF_BYCOMMAND|MF_SEPARATOR,0,NULL); - - SetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP),GWL_STYLE, - GetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS); - - int cGrip = Scintilla_GetSystemMetricsEx(hwnd, SM_CXHTHUMB); - SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP),NULL,cxClient-cGrip, - cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER); + ResizeDlg_Init(hwnd, s_cxStyleSelectDlg, s_cyStyleSelectDlg, IDC_RESIZEGRIP); hwndLV = GetDlgItem(hwnd,IDC_STYLELIST); SHFILEINFO shfi; ZeroMemory(&shfi, sizeof(SHFILEINFO)); + ListView_SetImageList(hwndLV, (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY, - &shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES), + &shfi,sizeof(SHFILEINFO), SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES), LVSIL_SMALL); ListView_SetImageList(hwndLV, (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY, - &shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES), + &shfi,sizeof(SHFILEINFO), SHGFI_LARGEICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES), LVSIL_NORMAL); //SetExplorerTheme(hwndLV); + LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); ListView_InsertColumn(hwndLV,0,&lvc); @@ -4563,71 +4533,41 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); + { + UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); + } return !0; case WM_DESTROY: { - RECT rc; - GetWindowRect(hwnd,&rc); - s_cxStyleSelectDlg = rc.right-rc.left; - s_cyStyleSelectDlg = rc.bottom-rc.top; + ResizeDlg_Destroy(hwnd, &s_cxStyleSelectDlg, &s_cyStyleSelectDlg); } return 0; case WM_SIZE: { - RECT rc; + ResizeDlg_Size(hwnd, lParam, &cxClient, &cyClient); - int dxClient = LOWORD(lParam) - cxClient; - int dyClient = HIWORD(lParam) - cyClient; - cxClient = LOWORD(lParam); - cyClient = HIWORD(lParam); - - GetWindowRect(GetDlgItem(hwnd,IDC_RESIZEGRIP),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDC_RESIZEGRIP),NULL,true); - - GetWindowRect(GetDlgItem(hwnd,IDOK),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDOK),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDOK),NULL,true); - - GetWindowRect(GetDlgItem(hwnd,IDCANCEL),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDCANCEL),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDCANCEL),NULL,true); - - GetWindowRect(GetDlgItem(hwnd,IDC_STYLELIST),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDC_STYLELIST),NULL,0,0,rc.right-rc.left+dxClient,rc.bottom-rc.top+dyClient,SWP_NOZORDER|SWP_NOMOVE); - ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_STYLELIST),0,LVSCW_AUTOSIZE_USEHEADER); - InvalidateRect(GetDlgItem(hwnd,IDC_STYLELIST),NULL,true); - - GetWindowRect(GetDlgItem(hwnd,IDC_AUTOSELECT),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDC_AUTOSELECT),NULL,rc.left,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDC_AUTOSELECT),NULL,true); - - GetWindowRect(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),NULL,rc.left,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),NULL,true); - } - return true; + HDWP hdwp; + hdwp = BeginDeferWindowPos(6); + hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP, cxClient, cyClient, SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp, hwnd, IDOK, cxClient, cyClient, SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp, hwnd, IDCANCEL, cxClient, cyClient, SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp, hwnd, IDC_STYLELIST, 0, cyClient, SWP_NOMOVE); + hdwp = DeferCtlPos(hdwp, hwnd, IDC_DEFAULTSCHEME, 0, cyClient, SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp, hwnd, IDC_AUTOSELECT, 0, cyClient, SWP_NOSIZE); + EndDeferWindowPos(hdwp); + + ListView_SetColumnWidth(GetDlgItem(hwnd, IDC_STYLELIST), 0, LVSCW_AUTOSIZE_USEHEADER); + } + return !0; case WM_GETMINMAXINFO: - { - LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; - lpmmi->ptMinTrackSize.x = mmiPtMinX; - lpmmi->ptMinTrackSize.y = mmiPtMaxY; - //lpmmi->ptMaxTrackSize.y = mmiPtMaxY; - } - return true; + ResizeDlg_GetMinMaxInfo(hwnd, lParam); + return !0; case WM_NOTIFY: @@ -4652,7 +4592,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR } } } - return true; + return !0; case WM_COMMAND: @@ -4688,9 +4628,9 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR } // switch() } // WM_COMMAND - return true; + return !0; } - return false; + return 0; }