diff --git a/src/Dialogs.c b/src/Dialogs.c
index 470673deb..c801a8eae 100644
--- a/src/Dialogs.c
+++ b/src/Dialogs.c
@@ -77,77 +77,77 @@ static HHOOK s_hCBThook = NULL;
static LRESULT CALLBACK SetPosRelatedToParent_Hook(INT nCode, WPARAM wParam, LPARAM lParam)
{
- // notification that a window is about to be activated
- if (nCode == HCBT_CREATEWND) {
- HWND const hThisWnd = (HWND)wParam;
- if (hThisWnd) {
+ // notification that a window is about to be activated
+ if (nCode == HCBT_CREATEWND) {
+ HWND const hThisWnd = (HWND)wParam;
+ if (hThisWnd) {
- SetDialogIconNP3(hThisWnd);
- InitWindowCommon(hThisWnd, true);
+ SetDialogIconNP3(hThisWnd);
+ InitWindowCommon(hThisWnd, true);
- // get window handles
- LPCREATESTRUCT const pCreateStruct = ((LPCBT_CREATEWND)lParam)->lpcs;
- HWND const hParentWnd = pCreateStruct->hwndParent ? pCreateStruct->hwndParent : GetParentOrDesktop(hThisWnd);
+ // get window handles
+ LPCREATESTRUCT const pCreateStruct = ((LPCBT_CREATEWND)lParam)->lpcs;
+ HWND const hParentWnd = pCreateStruct->hwndParent ? pCreateStruct->hwndParent : GetParentOrDesktop(hThisWnd);
- if (hParentWnd) {
+ if (hParentWnd) {
- // set new coordinates
- RECT rcDlg = { 0, 0, 0, 0 };
- rcDlg.left = pCreateStruct->x;
- rcDlg.top = pCreateStruct->y;
- rcDlg.right = pCreateStruct->x + pCreateStruct->cx;
- rcDlg.bottom = pCreateStruct->y + pCreateStruct->cy;
+ // set new coordinates
+ RECT rcDlg = { 0, 0, 0, 0 };
+ rcDlg.left = pCreateStruct->x;
+ rcDlg.top = pCreateStruct->y;
+ rcDlg.right = pCreateStruct->x + pCreateStruct->cx;
+ rcDlg.bottom = pCreateStruct->y + pCreateStruct->cy;
- RECT rcParent = { 0 };
- GetWindowRectEx(hParentWnd, &rcParent);
+ RECT rcParent = { 0 };
+ GetWindowRectEx(hParentWnd, &rcParent);
- POINT const ptTopLeft = GetCenterOfDlgInParent(&rcDlg, &rcParent);
+ POINT const ptTopLeft = GetCenterOfDlgInParent(&rcDlg, &rcParent);
- pCreateStruct->x = ptTopLeft.x;
- pCreateStruct->y = ptTopLeft.y;
- }
+ pCreateStruct->x = ptTopLeft.x;
+ pCreateStruct->y = ptTopLeft.y;
+ }
- // we are done
- if (s_hCBThook) {
- UnhookWindowsHookEx(s_hCBThook);
- s_hCBThook = NULL;
- }
- } else if (s_hCBThook) {
- // continue with any possible chained hooks
- return CallNextHookEx(s_hCBThook, nCode, wParam, lParam);
- }
- }
- return (LRESULT)0;
+ // we are done
+ if (s_hCBThook) {
+ UnhookWindowsHookEx(s_hCBThook);
+ s_hCBThook = NULL;
+ }
+ } else if (s_hCBThook) {
+ // continue with any possible chained hooks
+ return CallNextHookEx(s_hCBThook, nCode, wParam, lParam);
+ }
+ }
+ return (LRESULT)0;
}
// -----------------------------------------------------------------------------
int MessageBoxLng(UINT uType, UINT uidMsg, ...)
{
- WCHAR szFormat[HUGE_BUFFER] = { L'\0' };
- if (!GetLngString(uidMsg, szFormat, COUNTOF(szFormat))) {
- return -1;
- }
+ WCHAR szFormat[HUGE_BUFFER] = { L'\0' };
+ if (!GetLngString(uidMsg, szFormat, COUNTOF(szFormat))) {
+ return -1;
+ }
- WCHAR szText[HUGE_BUFFER] = { L'\0' };
- const PUINT_PTR argp = (PUINT_PTR)&uidMsg + 1;
- if (argp && *argp) {
- StringCchVPrintfW(szText, COUNTOF(szText), szFormat, (LPVOID)argp);
- } else {
- StringCchCopy(szText, COUNTOF(szText), szFormat);
- }
+ WCHAR szText[HUGE_BUFFER] = { L'\0' };
+ const PUINT_PTR argp = (PUINT_PTR)&uidMsg + 1;
+ if (argp && *argp) {
+ StringCchVPrintfW(szText, COUNTOF(szText), szFormat, (LPVOID)argp);
+ } else {
+ StringCchCopy(szText, COUNTOF(szText), szFormat);
+ }
- uType |= MB_SETFOREGROUND; //~ MB_TOPMOST
- if (Settings.DialogsLayoutRTL) {
- uType |= MB_RTLREADING;
- }
+ uType |= MB_SETFOREGROUND; //~ MB_TOPMOST
+ if (Settings.DialogsLayoutRTL) {
+ uType |= MB_RTLREADING;
+ }
- // center message box to focus or main
- HWND const focus = GetFocus();
- HWND const hwnd = focus ? focus : Globals.hwndMain;
- s_hCBThook = SetWindowsHookEx(WH_CBT, &SetPosRelatedToParent_Hook, 0, GetCurrentThreadId());
+ // center message box to focus or main
+ HWND const focus = GetFocus();
+ HWND const hwnd = focus ? focus : Globals.hwndMain;
+ s_hCBThook = SetWindowsHookEx(WH_CBT, &SetPosRelatedToParent_Hook, 0, GetCurrentThreadId());
- return MessageBoxEx(hwnd, szText, _W(SAPPNAME), uType, GetLangIdByLocaleName(Globals.CurrentLngLocaleName));
+ return MessageBoxEx(hwnd, szText, _W(SAPPNAME), uType, GetLangIdByLocaleName(Globals.CurrentLngLocaleName));
}
@@ -157,44 +157,44 @@ int MessageBoxLng(UINT uType, UINT uidMsg, ...)
//
DWORD MsgBoxLastError(LPCWSTR lpszMessage, DWORD dwErrID)
{
- // Retrieve the system error message for the last-error code
- if (!dwErrID) {
- dwErrID = GetLastError();
- }
+ // Retrieve the system error message for the last-error code
+ if (!dwErrID) {
+ dwErrID = GetLastError();
+ }
- LPVOID lpMsgBuf = NULL;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- dwErrID,
- GetLangIdByLocaleName(Globals.CurrentLngLocaleName),
- (LPWSTR)&lpMsgBuf,
- 0, NULL);
+ LPVOID lpMsgBuf = NULL;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwErrID,
+ GetLangIdByLocaleName(Globals.CurrentLngLocaleName),
+ (LPWSTR)&lpMsgBuf,
+ 0, NULL);
- if (lpMsgBuf) {
- // Display the error message and exit the process
- size_t const len = StringCchLen((LPCWSTR)lpMsgBuf, 0) + StringCchLen(lpszMessage, 0) + 160;
- LPWSTR lpDisplayBuf = (LPWSTR)AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY);
+ if (lpMsgBuf) {
+ // Display the error message and exit the process
+ size_t const len = StringCchLen((LPCWSTR)lpMsgBuf, 0) + StringCchLen(lpszMessage, 0) + 160;
+ LPWSTR lpDisplayBuf = (LPWSTR)AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY);
- if (lpDisplayBuf) {
- WCHAR msgFormat[128] = { L'\0' };
- GetLngString(IDS_MUI_ERR_DLG_FORMAT, msgFormat, COUNTOF(msgFormat));
- StringCchPrintf(lpDisplayBuf, len, msgFormat, lpszMessage, (LPCWSTR)lpMsgBuf, dwErrID);
- // center message box to main
- HWND const focus = GetFocus();
- HWND const hwnd = focus ? focus : Globals.hwndMain;
- s_hCBThook = SetWindowsHookEx(WH_CBT, &SetPosRelatedToParent_Hook, 0, GetCurrentThreadId());
+ if (lpDisplayBuf) {
+ WCHAR msgFormat[128] = { L'\0' };
+ GetLngString(IDS_MUI_ERR_DLG_FORMAT, msgFormat, COUNTOF(msgFormat));
+ StringCchPrintf(lpDisplayBuf, len, msgFormat, lpszMessage, (LPCWSTR)lpMsgBuf, dwErrID);
+ // center message box to main
+ HWND const focus = GetFocus();
+ HWND const hwnd = focus ? focus : Globals.hwndMain;
+ s_hCBThook = SetWindowsHookEx(WH_CBT, &SetPosRelatedToParent_Hook, 0, GetCurrentThreadId());
- UINT uType = MB_ICONERROR | MB_TOPMOST | (Settings.DialogsLayoutRTL ? MB_RTLREADING : 0);
- MessageBoxEx(hwnd, lpDisplayBuf, _W(SAPPNAME) L" - ERROR", uType, GetLangIdByLocaleName(Globals.CurrentLngLocaleName));
+ UINT uType = MB_ICONERROR | MB_TOPMOST | (Settings.DialogsLayoutRTL ? MB_RTLREADING : 0);
+ MessageBoxEx(hwnd, lpDisplayBuf, _W(SAPPNAME) L" - ERROR", uType, GetLangIdByLocaleName(Globals.CurrentLngLocaleName));
- FreeMem(lpDisplayBuf);
- }
- LocalFree(lpMsgBuf); // LocalAlloc()
- }
- return dwErrID;
+ FreeMem(lpDisplayBuf);
+ }
+ LocalFree(lpMsgBuf); // LocalAlloc()
+ }
+ return dwErrID;
}
//=============================================================================
@@ -204,169 +204,169 @@ DWORD MsgBoxLastError(LPCWSTR lpszMessage, DWORD dwErrID)
//
typedef struct _infbox {
- UINT uType;
- LPWSTR lpstrMessage;
- LPWSTR lpstrSetting;
- bool bDisableCheckBox;
+ UINT uType;
+ LPWSTR lpstrMessage;
+ LPWSTR lpstrSetting;
+ bool bDisableCheckBox;
} INFOBOXLNG, *LPINFOBOXLNG;
static INT_PTR CALLBACK _InfoBoxLngDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- static HBITMAP hIconBmp = NULL;
- static HICON hBoxIcon = NULL;
- static UINT dpi = USER_DEFAULT_SCREEN_DPI;
+ static HBITMAP hIconBmp = NULL;
+ static HICON hBoxIcon = NULL;
+ static UINT dpi = USER_DEFAULT_SCREEN_DPI;
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- LPINFOBOXLNG const lpMsgBox = (LPINFOBOXLNG)lParam;
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ LPINFOBOXLNG const lpMsgBox = (LPINFOBOXLNG)lParam;
- SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ SetDialogIconNP3(hwnd);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- for (int btn = IDOK; btn <= IDCONTINUE; ++btn) {
- HWND const hBtn = GetDlgItem(hwnd, btn);
- if (hBtn) {
- SetExplorerTheme(hBtn);
- }
- }
- SetWindowTheme(GetDlgItem(hwnd, IDC_INFOBOXCHECK), L"", L"");
- }
+ if (UseDarkMode()) {
+ for (int btn = IDOK; btn <= IDCONTINUE; ++btn) {
+ HWND const hBtn = GetDlgItem(hwnd, btn);
+ if (hBtn) {
+ SetExplorerTheme(hBtn);
+ }
+ }
+ SetWindowTheme(GetDlgItem(hwnd, IDC_INFOBOXCHECK), L"", L"");
+ }
#endif
- switch (lpMsgBox->uType & MB_ICONMASK) {
- case MB_ICONQUESTION:
- hBoxIcon = Globals.hIconMsgQuest;
- break;
- case MB_ICONWARNING: // = MB_ICONEXCLAMATION
- hBoxIcon = Globals.hIconMsgWarn;
- break;
- case MB_ICONERROR: // = MB_ICONSTOP, MB_ICONHAND
- hBoxIcon = Globals.hIconMsgError;
- break;
- case MB_ICONSHIELD:
- hBoxIcon = Globals.hIconMsgShield;
- break;
- case MB_USERICON:
- hBoxIcon = Globals.hIconMsgUser;
- break;
- case MB_ICONINFORMATION: // = MB_ICONASTERISK
- default:
- hBoxIcon = Globals.hIconMsgInfo;
- break;
- }
+ switch (lpMsgBox->uType & MB_ICONMASK) {
+ case MB_ICONQUESTION:
+ hBoxIcon = Globals.hIconMsgQuest;
+ break;
+ case MB_ICONWARNING: // = MB_ICONEXCLAMATION
+ hBoxIcon = Globals.hIconMsgWarn;
+ break;
+ case MB_ICONERROR: // = MB_ICONSTOP, MB_ICONHAND
+ hBoxIcon = Globals.hIconMsgError;
+ break;
+ case MB_ICONSHIELD:
+ hBoxIcon = Globals.hIconMsgShield;
+ break;
+ case MB_USERICON:
+ hBoxIcon = Globals.hIconMsgUser;
+ break;
+ case MB_ICONINFORMATION: // = MB_ICONASTERISK
+ default:
+ hBoxIcon = Globals.hIconMsgInfo;
+ break;
+ }
- dpi = Scintilla_GetWindowDPI(hwnd);
- int const scxb = Scintilla_GetSystemMetricsForDpi(SM_CXICON, dpi);
- int const scyb = Scintilla_GetSystemMetricsForDpi(SM_CYICON, dpi);
+ dpi = Scintilla_GetWindowDPI(hwnd);
+ int const scxb = Scintilla_GetSystemMetricsForDpi(SM_CXICON, dpi);
+ int const scyb = Scintilla_GetSystemMetricsForDpi(SM_CYICON, dpi);
- hIconBmp = ResampleIconToBitmap(hwnd, hIconBmp, hBoxIcon, scxb, scyb);
- if (hIconBmp) {
- SetBitmapControl(hwnd, IDC_INFOBOXICON, hIconBmp);
- }
+ hIconBmp = ResampleIconToBitmap(hwnd, hIconBmp, hBoxIcon, scxb, scyb);
+ if (hIconBmp) {
+ SetBitmapControl(hwnd, IDC_INFOBOXICON, hIconBmp);
+ }
- SetDlgItemText(hwnd, IDC_INFOBOXTEXT, lpMsgBox->lpstrMessage);
+ SetDlgItemText(hwnd, IDC_INFOBOXTEXT, lpMsgBox->lpstrMessage);
- if (lpMsgBox->bDisableCheckBox) {
- DialogEnableControl(hwnd, IDC_INFOBOXCHECK, false);
- DialogHideControl(hwnd, IDC_INFOBOXCHECK, true);
- }
+ if (lpMsgBox->bDisableCheckBox) {
+ DialogEnableControl(hwnd, IDC_INFOBOXCHECK, false);
+ DialogHideControl(hwnd, IDC_INFOBOXCHECK, true);
+ }
- FreeMem(lpMsgBox->lpstrMessage);
+ FreeMem(lpMsgBox->lpstrMessage);
- CenterDlgInParent(hwnd, NULL);
- AttentionBeep(lpMsgBox->uType);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ AttentionBeep(lpMsgBox->uType);
+ }
+ return TRUE;
- case WM_DPICHANGED: {
- dpi = LOWORD(wParam);
- int const scxb = Scintilla_GetSystemMetricsForDpi(SM_CXICON, dpi);
- int const scyb = Scintilla_GetSystemMetricsForDpi(SM_CYICON, dpi);
- hIconBmp = ResampleIconToBitmap(hwnd, hIconBmp, hBoxIcon, scxb, scyb);
- if (hIconBmp) {
- SetBitmapControl(hwnd, IDC_INFOBOXICON, hIconBmp);
- }
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- }
- return TRUE;
+ case WM_DPICHANGED: {
+ dpi = LOWORD(wParam);
+ int const scxb = Scintilla_GetSystemMetricsForDpi(SM_CXICON, dpi);
+ int const scyb = Scintilla_GetSystemMetricsForDpi(SM_CYICON, dpi);
+ hIconBmp = ResampleIconToBitmap(hwnd, hIconBmp, hBoxIcon, scxb, scyb);
+ if (hIconBmp) {
+ SetBitmapControl(hwnd, IDC_INFOBOXICON, hIconBmp);
+ }
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ }
+ return TRUE;
- case WM_DESTROY:
- if (hIconBmp) {
- DeleteObject(hIconBmp);
- }
- return TRUE;
+ case WM_DESTROY:
+ if (hIconBmp) {
+ DeleteObject(hIconBmp);
+ }
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- for (int btn = IDOK; btn <= IDCONTINUE; ++btn) {
- HWND const hBtn = GetDlgItem(hwnd, btn);
- if (hBtn) {
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ for (int btn = IDOK; btn <= IDCONTINUE; ++btn) {
+ HWND const hBtn = GetDlgItem(hwnd, btn);
+ if (hBtn) {
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND: {
- LPINFOBOXLNG const lpMsgBox = (LPINFOBOXLNG)GetWindowLongPtr(hwnd, DWLP_USER);
- switch (LOWORD(wParam)) {
- case IDOK:
- case IDYES:
- case IDRETRY:
- case IDIGNORE:
- case IDTRYAGAIN:
- case IDCONTINUE:
- if (IsButtonChecked(hwnd, IDC_INFOBOXCHECK) && StrIsNotEmpty(lpMsgBox->lpstrSetting) && Globals.bCanSaveIniFile) {
- IniFileSetInt(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpMsgBox->lpstrSetting, LOWORD(wParam));
- }
- case IDNO:
- case IDABORT:
- case IDCLOSE:
- case IDCANCEL:
- EndDialog(hwnd, LOWORD(wParam));
- break;
+ case WM_COMMAND: {
+ LPINFOBOXLNG const lpMsgBox = (LPINFOBOXLNG)GetWindowLongPtr(hwnd, DWLP_USER);
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ case IDYES:
+ case IDRETRY:
+ case IDIGNORE:
+ case IDTRYAGAIN:
+ case IDCONTINUE:
+ if (IsButtonChecked(hwnd, IDC_INFOBOXCHECK) && StrIsNotEmpty(lpMsgBox->lpstrSetting) && Globals.bCanSaveIniFile) {
+ IniFileSetInt(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpMsgBox->lpstrSetting, LOWORD(wParam));
+ }
+ case IDNO:
+ case IDABORT:
+ case IDCLOSE:
+ case IDCANCEL:
+ EndDialog(hwnd, LOWORD(wParam));
+ break;
- case IDC_INFOBOXCHECK:
- DialogEnableControl(hwnd, IDNO, !IsButtonChecked(hwnd, IDC_INFOBOXCHECK));
- DialogEnableControl(hwnd, IDABORT, !IsButtonChecked(hwnd, IDC_INFOBOXCHECK));
- DialogEnableControl(hwnd, IDCLOSE, !IsButtonChecked(hwnd, IDC_INFOBOXCHECK));
- DialogEnableControl(hwnd, IDCANCEL, !IsButtonChecked(hwnd, IDC_INFOBOXCHECK));
- break;
+ case IDC_INFOBOXCHECK:
+ DialogEnableControl(hwnd, IDNO, !IsButtonChecked(hwnd, IDC_INFOBOXCHECK));
+ DialogEnableControl(hwnd, IDABORT, !IsButtonChecked(hwnd, IDC_INFOBOXCHECK));
+ DialogEnableControl(hwnd, IDCLOSE, !IsButtonChecked(hwnd, IDC_INFOBOXCHECK));
+ DialogEnableControl(hwnd, IDCANCEL, !IsButtonChecked(hwnd, IDC_INFOBOXCHECK));
+ break;
- default:
- break;
- }
- }
- return TRUE;
- }
- return FALSE;
+ default:
+ break;
+ }
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -378,125 +378,125 @@ CASE_WM_CTLCOLOR_SET:
LONG InfoBoxLng(UINT uType, LPCWSTR lpstrSetting, UINT uidMsg, ...)
{
- int const iMode = StrIsEmpty(lpstrSetting) ? 0 : IniFileGetInt(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpstrSetting, 0);
+ int const iMode = StrIsEmpty(lpstrSetting) ? 0 : IniFileGetInt(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpstrSetting, 0);
- if (Settings.DialogsLayoutRTL) {
- uType |= MB_RTLREADING;
- }
+ if (Settings.DialogsLayoutRTL) {
+ uType |= MB_RTLREADING;
+ }
- switch (iMode) {
- case IDOK:
- case IDYES:
- case IDCONTINUE:
- return MAKELONG(iMode, iMode);
+ switch (iMode) {
+ case IDOK:
+ case IDYES:
+ case IDCONTINUE:
+ return MAKELONG(iMode, iMode);
- case 0:
- // no entry found
- case -1:
- // disable "Don't display again" check-box
- break;
+ case 0:
+ // no entry found
+ case -1:
+ // disable "Don't display again" check-box
+ break;
- default:
- if (Globals.bCanSaveIniFile) {
- IniFileDelete(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpstrSetting, false);
- }
- break;
- }
+ default:
+ if (Globals.bCanSaveIniFile) {
+ IniFileDelete(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpstrSetting, false);
+ }
+ break;
+ }
- WCHAR wchMessage[LARGE_BUFFER];
- if (!GetLngString(uidMsg, wchMessage, COUNTOF(wchMessage))) {
- return MAKELONG(0, iMode);
- }
+ WCHAR wchMessage[LARGE_BUFFER];
+ if (!GetLngString(uidMsg, wchMessage, COUNTOF(wchMessage))) {
+ return MAKELONG(0, iMode);
+ }
- INFOBOXLNG msgBox = { 0 };
- msgBox.uType = uType;
- msgBox.lpstrMessage = AllocMem((COUNTOF(wchMessage)+1) * sizeof(WCHAR), HEAP_ZERO_MEMORY);
+ INFOBOXLNG msgBox = { 0 };
+ msgBox.uType = uType;
+ msgBox.lpstrMessage = AllocMem((COUNTOF(wchMessage)+1) * sizeof(WCHAR), HEAP_ZERO_MEMORY);
- const PUINT_PTR argp = (PUINT_PTR)& uidMsg + 1;
- if (argp && *argp) {
- StringCchVPrintfW(msgBox.lpstrMessage, COUNTOF(wchMessage), wchMessage, (LPVOID)argp);
- } else {
- StringCchCopy(msgBox.lpstrMessage, COUNTOF(wchMessage), wchMessage);
- }
+ const PUINT_PTR argp = (PUINT_PTR)& uidMsg + 1;
+ if (argp && *argp) {
+ StringCchVPrintfW(msgBox.lpstrMessage, COUNTOF(wchMessage), wchMessage, (LPVOID)argp);
+ } else {
+ StringCchCopy(msgBox.lpstrMessage, COUNTOF(wchMessage), wchMessage);
+ }
- bool bLastError = false;
- switch (uidMsg) {
- case IDS_MUI_ERR_LOADFILE:
- case IDS_MUI_ERR_SAVEFILE:
- case IDS_MUI_CREATEINI_FAIL:
- case IDS_MUI_WRITEINI_FAIL:
- case IDS_MUI_EXPORT_FAIL:
- case IDS_MUI_ERR_ELEVATED_RIGHTS:
- case IDS_MUI_FILELOCK_ERROR:
- bLastError = true;
- break;
- default:
- //bLastError = false;
- break;
- }
+ bool bLastError = false;
+ switch (uidMsg) {
+ case IDS_MUI_ERR_LOADFILE:
+ case IDS_MUI_ERR_SAVEFILE:
+ case IDS_MUI_CREATEINI_FAIL:
+ case IDS_MUI_WRITEINI_FAIL:
+ case IDS_MUI_EXPORT_FAIL:
+ case IDS_MUI_ERR_ELEVATED_RIGHTS:
+ case IDS_MUI_FILELOCK_ERROR:
+ bLastError = true;
+ break;
+ default:
+ //bLastError = false;
+ break;
+ }
- if (bLastError) {
- LPVOID lpMsgBuf = NULL;
- if (Globals.dwLastError != ERROR_SUCCESS) {
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- Globals.dwLastError,
- GetLangIdByLocaleName(Globals.CurrentLngLocaleName),
- (LPWSTR)&lpMsgBuf, 0,
- NULL);
+ if (bLastError) {
+ LPVOID lpMsgBuf = NULL;
+ if (Globals.dwLastError != ERROR_SUCCESS) {
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ Globals.dwLastError,
+ GetLangIdByLocaleName(Globals.CurrentLngLocaleName),
+ (LPWSTR)&lpMsgBuf, 0,
+ NULL);
- Globals.dwLastError = ERROR_SUCCESS; // reset;
- }
+ Globals.dwLastError = ERROR_SUCCESS; // reset;
+ }
- if (lpMsgBuf) {
- StringCchCat(msgBox.lpstrMessage, COUNTOF(wchMessage), L"\n\n");
- StringCchCat(msgBox.lpstrMessage, COUNTOF(wchMessage), lpMsgBuf);
- LocalFree(lpMsgBuf);
- }
+ if (lpMsgBuf) {
+ StringCchCat(msgBox.lpstrMessage, COUNTOF(wchMessage), L"\n\n");
+ StringCchCat(msgBox.lpstrMessage, COUNTOF(wchMessage), lpMsgBuf);
+ LocalFree(lpMsgBuf);
+ }
- WCHAR wcht = *CharPrev(msgBox.lpstrMessage, StrEnd(msgBox.lpstrMessage, COUNTOF(wchMessage)));
- if (IsCharAlphaNumeric(wcht) || wcht == '"' || wcht == '\'') {
- StringCchCat(msgBox.lpstrMessage, COUNTOF(wchMessage), L".");
- }
- }
+ WCHAR wcht = *CharPrev(msgBox.lpstrMessage, StrEnd(msgBox.lpstrMessage, COUNTOF(wchMessage)));
+ if (IsCharAlphaNumeric(wcht) || wcht == '"' || wcht == '\'') {
+ StringCchCat(msgBox.lpstrMessage, COUNTOF(wchMessage), L".");
+ }
+ }
- msgBox.lpstrSetting = (LPWSTR)lpstrSetting;
- msgBox.bDisableCheckBox = (!Globals.bCanSaveIniFile || StrIsEmpty(lpstrSetting) || (iMode < 0)) ? true : false;
+ msgBox.lpstrSetting = (LPWSTR)lpstrSetting;
+ msgBox.bDisableCheckBox = (!Globals.bCanSaveIniFile || StrIsEmpty(lpstrSetting) || (iMode < 0)) ? true : false;
- int idDlg;
- switch (uType & MB_TYPEMASK) {
+ int idDlg;
+ switch (uType & MB_TYPEMASK) {
- case MB_YESNO: // contains two push buttons : Yes and No.
- idDlg = IDD_MUI_INFOBOX2;
- break;
+ case MB_YESNO: // contains two push buttons : Yes and No.
+ idDlg = IDD_MUI_INFOBOX2;
+ break;
- case MB_OKCANCEL: // contains two push buttons : OK and Cancel.
- idDlg = IDD_MUI_INFOBOX3;
- break;
+ case MB_OKCANCEL: // contains two push buttons : OK and Cancel.
+ idDlg = IDD_MUI_INFOBOX3;
+ break;
- case MB_YESNOCANCEL: // contains three push buttons : Yes, No, and Cancel.
- idDlg = IDD_MUI_INFOBOX4;
- break;
+ case MB_YESNOCANCEL: // contains three push buttons : Yes, No, and Cancel.
+ idDlg = IDD_MUI_INFOBOX4;
+ break;
- case MB_RETRYCANCEL: // contains two push buttons : Retry and Cancel.
- idDlg = IDD_MUI_INFOBOX5;
- break;
+ case MB_RETRYCANCEL: // contains two push buttons : Retry and Cancel.
+ idDlg = IDD_MUI_INFOBOX5;
+ break;
- case MB_ABORTRETRYIGNORE: // three push buttons : Abort, Retry, and Ignore.
- case MB_CANCELTRYCONTINUE: // three push buttons : Cancel, Try Again, Continue.Use this message box type instead of MB_ABORTRETRYIGNORE.
+ case MB_ABORTRETRYIGNORE: // three push buttons : Abort, Retry, and Ignore.
+ case MB_CANCELTRYCONTINUE: // three push buttons : Cancel, Try Again, Continue.Use this message box type instead of MB_ABORTRETRYIGNORE.
- case MB_OK: // one push button : OK. This is the default.
- default:
- idDlg = IDD_MUI_INFOBOX;
- break;
- }
+ case MB_OK: // one push button : OK. This is the default.
+ default:
+ idDlg = IDD_MUI_INFOBOX;
+ break;
+ }
- HWND focus = GetFocus();
- HWND hwnd = focus ? focus : Globals.hwndMain;
+ HWND focus = GetFocus();
+ HWND hwnd = focus ? focus : Globals.hwndMain;
- INT_PTR const answer = ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(idDlg), hwnd, _InfoBoxLngDlgProc, (LPARAM)&msgBox);
- return MAKELONG(answer, iMode);
+ INT_PTR const answer = ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(idDlg), hwnd, _InfoBoxLngDlgProc, (LPARAM)&msgBox);
+ return MAKELONG(answer, iMode);
}
/*
@@ -550,142 +550,142 @@ LONG InfoBoxLng(UINT uType, LPCWSTR lpstrSetting, UINT uidMsg, ...)
// best to work with a 3rd party shell. If we still can't find anything, we
// return a rect in the lower right hand corner of the screen
static bool GetTrayWndRect(LPRECT lpTrayRect) {
- APPBARDATA appBarData;
- // First, we'll use a quick hack method. We know that the taskbar is a window
- // of class Shell_TrayWnd, and the status tray is a child of this of class
- // TrayNotifyWnd. This provides us a window rect to minimize to. Note, however,
- // that this is not guaranteed to work on future versions of the shell. If we
- // use this method, make sure we have a backup!
- HWND hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), NULL);
- if (hShellTrayWnd) {
- HWND hTrayNotifyWnd = FindWindowEx(hShellTrayWnd, NULL, TEXT("TrayNotifyWnd"), NULL);
- if (hTrayNotifyWnd) {
- GetWindowRect(hTrayNotifyWnd, lpTrayRect);
- return true;
- }
- }
+ APPBARDATA appBarData;
+ // First, we'll use a quick hack method. We know that the taskbar is a window
+ // of class Shell_TrayWnd, and the status tray is a child of this of class
+ // TrayNotifyWnd. This provides us a window rect to minimize to. Note, however,
+ // that this is not guaranteed to work on future versions of the shell. If we
+ // use this method, make sure we have a backup!
+ HWND hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), NULL);
+ if (hShellTrayWnd) {
+ HWND hTrayNotifyWnd = FindWindowEx(hShellTrayWnd, NULL, TEXT("TrayNotifyWnd"), NULL);
+ if (hTrayNotifyWnd) {
+ GetWindowRect(hTrayNotifyWnd, lpTrayRect);
+ return true;
+ }
+ }
- // OK, we failed to get the rect from the quick hack. Either explorer isn't
- // running or it's a new version of the shell with the window class names
- // changed (how dare Microsoft change these undocumented class names!) So, we
- // try to find out what side of the screen the taskbar is connected to. We
- // know that the system tray is either on the right or the bottom of the
- // taskbar, so we can make a good guess at where to minimize to
- /*APPBARDATA appBarData;*/
- appBarData.cbSize = sizeof(appBarData);
- if (SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData)) {
- // We know the edge the taskbar is connected to, so guess the rect of the
- // system tray. Use various fudge factor to make it look good
- switch (appBarData.uEdge) {
- case ABE_LEFT:
- case ABE_RIGHT:
- // We want to minimize to the bottom of the taskbar
- lpTrayRect->top = appBarData.rc.bottom - 100;
- lpTrayRect->bottom = appBarData.rc.bottom - 16;
- lpTrayRect->left = appBarData.rc.left;
- lpTrayRect->right = appBarData.rc.right;
- break;
+ // OK, we failed to get the rect from the quick hack. Either explorer isn't
+ // running or it's a new version of the shell with the window class names
+ // changed (how dare Microsoft change these undocumented class names!) So, we
+ // try to find out what side of the screen the taskbar is connected to. We
+ // know that the system tray is either on the right or the bottom of the
+ // taskbar, so we can make a good guess at where to minimize to
+ /*APPBARDATA appBarData;*/
+ appBarData.cbSize = sizeof(appBarData);
+ if (SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData)) {
+ // We know the edge the taskbar is connected to, so guess the rect of the
+ // system tray. Use various fudge factor to make it look good
+ switch (appBarData.uEdge) {
+ case ABE_LEFT:
+ case ABE_RIGHT:
+ // We want to minimize to the bottom of the taskbar
+ lpTrayRect->top = appBarData.rc.bottom - 100;
+ lpTrayRect->bottom = appBarData.rc.bottom - 16;
+ lpTrayRect->left = appBarData.rc.left;
+ lpTrayRect->right = appBarData.rc.right;
+ break;
- case ABE_TOP:
- case ABE_BOTTOM:
- // We want to minimize to the right of the taskbar
- lpTrayRect->top = appBarData.rc.top;
- lpTrayRect->bottom = appBarData.rc.bottom;
- lpTrayRect->left = appBarData.rc.right - 100;
- lpTrayRect->right = appBarData.rc.right - 16;
- break;
- }
+ case ABE_TOP:
+ case ABE_BOTTOM:
+ // We want to minimize to the right of the taskbar
+ lpTrayRect->top = appBarData.rc.top;
+ lpTrayRect->bottom = appBarData.rc.bottom;
+ lpTrayRect->left = appBarData.rc.right - 100;
+ lpTrayRect->right = appBarData.rc.right - 16;
+ break;
+ }
- return true;
- }
+ return true;
+ }
- // Blimey, we really aren't in luck. It's possible that a third party shell
- // is running instead of explorer. This shell might provide support for the
- // system tray, by providing a Shell_TrayWnd window (which receives the
- // messages for the icons) So, look for a Shell_TrayWnd window and work out
- // the rect from that. Remember that explorer's taskbar is the Shell_TrayWnd,
- // and stretches either the width or the height of the screen. We can't rely
- // on the 3rd party shell's Shell_TrayWnd doing the same, in fact, we can't
- // rely on it being any size. The best we can do is just blindly use the
- // window rect, perhaps limiting the width and height to, say 150 square.
- // Note that if the 3rd party shell supports the same configuraion as
- // explorer (the icons hosted in NotifyTrayWnd, which is a child window of
- // Shell_TrayWnd), we would already have caught it above
- hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), NULL);
- if (hShellTrayWnd) {
- GetWindowRect(hShellTrayWnd, lpTrayRect);
- if (lpTrayRect->right - lpTrayRect->left > DEFAULT_RECT_WIDTH) {
- lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH;
- }
- if (lpTrayRect->bottom - lpTrayRect->top > DEFAULT_RECT_HEIGHT) {
- lpTrayRect->top = lpTrayRect->bottom - DEFAULT_RECT_HEIGHT;
- }
- return true;
- }
+ // Blimey, we really aren't in luck. It's possible that a third party shell
+ // is running instead of explorer. This shell might provide support for the
+ // system tray, by providing a Shell_TrayWnd window (which receives the
+ // messages for the icons) So, look for a Shell_TrayWnd window and work out
+ // the rect from that. Remember that explorer's taskbar is the Shell_TrayWnd,
+ // and stretches either the width or the height of the screen. We can't rely
+ // on the 3rd party shell's Shell_TrayWnd doing the same, in fact, we can't
+ // rely on it being any size. The best we can do is just blindly use the
+ // window rect, perhaps limiting the width and height to, say 150 square.
+ // Note that if the 3rd party shell supports the same configuraion as
+ // explorer (the icons hosted in NotifyTrayWnd, which is a child window of
+ // Shell_TrayWnd), we would already have caught it above
+ hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), NULL);
+ if (hShellTrayWnd) {
+ GetWindowRect(hShellTrayWnd, lpTrayRect);
+ if (lpTrayRect->right - lpTrayRect->left > DEFAULT_RECT_WIDTH) {
+ lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH;
+ }
+ if (lpTrayRect->bottom - lpTrayRect->top > DEFAULT_RECT_HEIGHT) {
+ lpTrayRect->top = lpTrayRect->bottom - DEFAULT_RECT_HEIGHT;
+ }
+ return true;
+ }
- // OK. Haven't found a thing. Provide a default rect based on the current work area
- SystemParametersInfo(SPI_GETWORKAREA, 0, lpTrayRect, 0);
- lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH;
- lpTrayRect->top = lpTrayRect->bottom - DEFAULT_RECT_HEIGHT;
- return false;
+ // OK. Haven't found a thing. Provide a default rect based on the current work area
+ SystemParametersInfo(SPI_GETWORKAREA, 0, lpTrayRect, 0);
+ lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH;
+ lpTrayRect->top = lpTrayRect->bottom - DEFAULT_RECT_HEIGHT;
+ return false;
}
// Check to see if the animation has been disabled
/*static */ bool GetDoAnimateMinimize(VOID) {
- ANIMATIONINFO ai;
+ ANIMATIONINFO ai;
- ai.cbSize = sizeof(ai);
- SystemParametersInfo(SPI_GETANIMATION, sizeof(ai), &ai, 0);
+ ai.cbSize = sizeof(ai);
+ SystemParametersInfo(SPI_GETANIMATION, sizeof(ai), &ai, 0);
- return ai.iMinAnimate ? true : false;
+ return ai.iMinAnimate ? true : false;
}
void MinimizeWndToTray(HWND hWnd) {
- if (GetDoAnimateMinimize()) {
+ if (GetDoAnimateMinimize()) {
- // Get the rect of the window. It is safe to use the rect of the whole
- // window - DrawAnimatedRects will only draw the caption
- RECT rcFrom;
- GetWindowRect(hWnd, &rcFrom);
- RECT rcTo;
- GetTrayWndRect(&rcTo);
+ // Get the rect of the window. It is safe to use the rect of the whole
+ // window - DrawAnimatedRects will only draw the caption
+ RECT rcFrom;
+ GetWindowRect(hWnd, &rcFrom);
+ RECT rcTo;
+ GetTrayWndRect(&rcTo);
- // Get the system to draw our animation for us
- DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo);
- }
+ // Get the system to draw our animation for us
+ DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo);
+ }
- // Add the tray icon. If we add it before the call to DrawAnimatedRects,
- // the taskbar gets erased, but doesn't get redrawn until DAR finishes.
- // This looks untidy, so call the functions in this order
+ // Add the tray icon. If we add it before the call to DrawAnimatedRects,
+ // the taskbar gets erased, but doesn't get redrawn until DAR finishes.
+ // This looks untidy, so call the functions in this order
- // Hide the window
- ShowWindow(hWnd, SW_HIDE);
- Globals.bMinimizedToTray = true;
+ // Hide the window
+ ShowWindow(hWnd, SW_HIDE);
+ Globals.bMinimizedToTray = true;
}
void RestoreWndFromTray(HWND hWnd) {
- if (GetDoAnimateMinimize()) {
+ if (GetDoAnimateMinimize()) {
- // Get the rect of the tray and the window. Note that the window rect
- // is still valid even though the window is hidden
- RECT rcFrom;
- GetTrayWndRect(&rcFrom);
- RECT rcTo;
- GetWindowRect(hWnd, &rcTo);
+ // Get the rect of the tray and the window. Note that the window rect
+ // is still valid even though the window is hidden
+ RECT rcFrom;
+ GetTrayWndRect(&rcFrom);
+ RECT rcTo;
+ GetWindowRect(hWnd, &rcTo);
- // Get the system to draw our animation for us
- DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo);
- }
+ // Get the system to draw our animation for us
+ DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo);
+ }
- // Show the window, and make sure we're the foreground window
- ShowWindow(hWnd, SW_SHOW);
- SetActiveWindow(hWnd);
- SetForegroundWindow(hWnd);
- Globals.bMinimizedToTray = false;
+ // Show the window, and make sure we're the foreground window
+ ShowWindow(hWnd, SW_SHOW);
+ SetActiveWindow(hWnd);
+ SetForegroundWindow(hWnd);
+ Globals.bMinimizedToTray = false;
- // Remove the tray icon. As described above, remove the icon after the
- // call to DrawAnimatedRects, or the taskbar will not refresh itself
- // properly until DAR finished
+ // Remove the tray icon. As described above, remove the icon after the
+ // call to DrawAnimatedRects, or the taskbar will not refresh itself
+ // properly until DAR finished
}
@@ -696,107 +696,107 @@ void RestoreWndFromTray(HWND hWnd) {
#if 0
void DisplayCmdLineHelp(HWND hwnd)
{
- WCHAR szText[2048] = { L'\0' };
- GetLngString(IDS_MUI_CMDLINEHELP,szText,COUNTOF(szText));
+ WCHAR szText[2048] = { L'\0' };
+ GetLngString(IDS_MUI_CMDLINEHELP,szText,COUNTOF(szText));
- MSGBOXPARAMS mbp = { 0 };
- mbp.cbSize = sizeof(MSGBOXPARAMS);
- mbp.hwndOwner = hwnd;
- mbp.hInstance = Globals.hInstance;
- mbp.lpszText = szText;
- mbp.lpszCaption = _W(SAPPNAME);
- mbp.dwStyle = MB_OK | MB_USERICON | MB_SETFOREGROUND;
- mbp.lpszIcon = MAKEINTRESOURCE(IDR_MAINWND);
- mbp.dwContextHelpId = 0;
- mbp.lpfnMsgBoxCallback = NULL;
- mbp.dwLanguageId = GetLangIdByLocaleName(Globals.CurrentLngLocaleName);
+ MSGBOXPARAMS mbp = { 0 };
+ mbp.cbSize = sizeof(MSGBOXPARAMS);
+ mbp.hwndOwner = hwnd;
+ mbp.hInstance = Globals.hInstance;
+ mbp.lpszText = szText;
+ mbp.lpszCaption = _W(SAPPNAME);
+ mbp.dwStyle = MB_OK | MB_USERICON | MB_SETFOREGROUND;
+ mbp.lpszIcon = MAKEINTRESOURCE(IDR_MAINWND);
+ mbp.dwContextHelpId = 0;
+ mbp.lpfnMsgBoxCallback = NULL;
+ mbp.dwLanguageId = GetLangIdByLocaleName(Globals.CurrentLngLocaleName);
- hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId());
+ hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId());
- MessageBoxIndirect(&mbp);
- //MsgBoxLng(MBINFO, IDS_MUI_CMDLINEHELP);
+ MessageBoxIndirect(&mbp);
+ //MsgBoxLng(MBINFO, IDS_MUI_CMDLINEHELP);
}
#else
static INT_PTR CALLBACK CmdLineHelpProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- UNREFERENCED_PARAMETER(lParam);
+ UNREFERENCED_PARAMETER(lParam);
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ SetDialogIconNP3(hwnd);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ }
#endif
- WCHAR szText[4096] = { L'\0' };
- GetLngString(IDS_MUI_CMDLINEHELP, szText, COUNTOF(szText));
- SetDlgItemText(hwnd, IDC_CMDLINEHELP, szText);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ WCHAR szText[4096] = { L'\0' };
+ GetLngString(IDS_MUI_CMDLINEHELP, szText, COUNTOF(szText));
+ SetDlgItemText(hwnd, IDC_CMDLINEHELP, szText);
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- for (int btn = IDOK; btn <= IDCONTINUE; ++btn) {
- HWND const hBtn = GetDlgItem(hwnd, btn);
- if (hBtn) {
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ for (int btn = IDOK; btn <= IDCONTINUE; ++btn) {
+ HWND const hBtn = GetDlgItem(hwnd, btn);
+ if (hBtn) {
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK:
- case IDCANCEL:
- case IDYES:
- case IDNO:
- EndDialog(hwnd, LOWORD(wParam));
- break;
- }
- return TRUE;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ case IDCANCEL:
+ case IDYES:
+ case IDNO:
+ EndDialog(hwnd, LOWORD(wParam));
+ break;
+ }
+ return TRUE;
- default:
- break;
- }
- return FALSE;
+ default:
+ break;
+ }
+ return FALSE;
}
INT_PTR DisplayCmdLineHelp(HWND hwnd)
{
- return ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CMDLINEHELP), hwnd, CmdLineHelpProc, (LPARAM)L"");
+ return ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CMDLINEHELP), hwnd, CmdLineHelpProc, (LPARAM)L"");
}
#endif
@@ -807,19 +807,19 @@ INT_PTR DisplayCmdLineHelp(HWND hwnd)
//
int CALLBACK BFFCallBack(HWND hwnd, UINT umsg, LPARAM lParam, LPARAM lpData)
{
- UNREFERENCED_PARAMETER(lParam);
- switch (umsg) {
- case BFFM_INITIALIZED:
- SetDialogIconNP3(hwnd);
- //~InitWindowCommon(hwnd, true);
- SendMessage(hwnd, BFFM_SETSELECTION, true, lpData);
- break;
- case BFFM_VALIDATEFAILED:
- break;
- default:
- break;
- }
- return 0;
+ UNREFERENCED_PARAMETER(lParam);
+ switch (umsg) {
+ case BFFM_INITIALIZED:
+ SetDialogIconNP3(hwnd);
+ //~InitWindowCommon(hwnd, true);
+ SendMessage(hwnd, BFFM_SETSELECTION, true, lpData);
+ break;
+ case BFFM_VALIDATEFAILED:
+ break;
+ default:
+ break;
+ }
+ return 0;
}
@@ -829,33 +829,33 @@ int CALLBACK BFFCallBack(HWND hwnd, UINT umsg, LPARAM lParam, LPARAM lpData)
//
bool GetDirectory(HWND hwndParent, int uiTitle, LPWSTR pszFolder, LPCWSTR pszBase, bool bNewDialogStyle)
{
- WCHAR szTitle[MIDSZ_BUFFER] = { L'\0' };
- GetLngString(uiTitle, szTitle, COUNTOF(szTitle));
+ WCHAR szTitle[MIDSZ_BUFFER] = { L'\0' };
+ GetLngString(uiTitle, szTitle, COUNTOF(szTitle));
- WCHAR szBase[MAX_PATH] = { L'\0' };
- if (!pszBase || !*pszBase) {
- GetCurrentDirectory(MAX_PATH, szBase);
- } else {
- StringCchCopyN(szBase, COUNTOF(szBase), pszBase, MAX_PATH);
- }
+ WCHAR szBase[MAX_PATH] = { L'\0' };
+ if (!pszBase || !*pszBase) {
+ GetCurrentDirectory(MAX_PATH, szBase);
+ } else {
+ StringCchCopyN(szBase, COUNTOF(szBase), pszBase, MAX_PATH);
+ }
- BROWSEINFO bi = { 0 };
- bi.hwndOwner = hwndParent;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = pszFolder;
- bi.lpszTitle = szTitle;
- bi.ulFlags = BIF_RETURNONLYFSDIRS | (bNewDialogStyle ? (BIF_NEWDIALOGSTYLE | BIF_USENEWUI) : 0);
- bi.lpfn = &BFFCallBack;
- bi.lParam = (LPARAM)szBase;
- bi.iImage = 0;
+ BROWSEINFO bi = { 0 };
+ bi.hwndOwner = hwndParent;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = pszFolder;
+ bi.lpszTitle = szTitle;
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | (bNewDialogStyle ? (BIF_NEWDIALOGSTYLE | BIF_USENEWUI) : 0);
+ bi.lpfn = &BFFCallBack;
+ bi.lParam = (LPARAM)szBase;
+ bi.iImage = 0;
- LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
- if (pidl) {
- SHGetPathFromIDList(pidl,pszFolder);
- CoTaskMemFree(pidl);
- return TRUE;
- }
- return FALSE;
+ LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
+ if (pidl) {
+ SHGetPathFromIDList(pidl,pszFolder);
+ CoTaskMemFree(pidl);
+ return TRUE;
+ }
+ return FALSE;
}
@@ -869,31 +869,31 @@ static DWORD _LoadStringEx(UINT nResId, LPCTSTR pszRsType, LPSTR strOut)
LPTSTR pszResId = MAKEINTRESOURCE(nResId);
if (Globals.hInstance == NULL)
- return FALSEL;
+ return FALSEL;
HRSRC hRsrc = FindResource(Globals.hInstance, pszResId, pszRsType);
if (hRsrc == NULL) {
- return FALSEL;
+ return FALSEL;
}
HGLOBAL hGlobal = LoadResource(Globals.hInstance, hRsrc);
if (hGlobal == NULL) {
- return FALSEL;
+ return FALSEL;
}
const BYTE* pData = (const BYTE*)LockResource(hGlobal);
if (pData == NULL) {
- FreeResource(hGlobal);
- return FALSEL;
+ FreeResource(hGlobal);
+ return FALSEL;
}
DWORD dwSize = SizeofResource(Globals.hInstance, hRsrc);
if (strOut) {
- memcpy(strOut, (LPCSTR)pData, dwSize);
+ memcpy(strOut, (LPCSTR)pData, dwSize);
}
UnlockResource(hGlobal);
@@ -911,26 +911,26 @@ static DWORD _LoadStringEx(UINT nResId, LPCTSTR pszRsType, LPSTR strOut)
// _LoadRtfCallback() RTF edit control StreamIn's callback function
//
static DWORD CALLBACK _LoadRtfCallback(
- DWORD_PTR dwCookie, // (in) pointer to the string
- LPBYTE pbBuff, // (in) pointer to the destination buffer
- LONG cb, // (in) size in bytes of the destination buffer
- LONG FAR* pcb // (out) number of bytes transfered
+ DWORD_PTR dwCookie, // (in) pointer to the string
+ LPBYTE pbBuff, // (in) pointer to the destination buffer
+ LONG cb, // (in) size in bytes of the destination buffer
+ LONG FAR* pcb // (out) number of bytes transfered
)
{
- LPSTR* pstr = (LPSTR*)dwCookie;
- LONG const len = (LONG)StringCchLenA(*pstr,0);
+ LPSTR* pstr = (LPSTR*)dwCookie;
+ LONG const len = (LONG)StringCchLenA(*pstr,0);
- if (len < cb) {
- *pcb = len;
- memcpy_s(pbBuff, cb, (LPCSTR)*pstr, *pcb);
- *pstr += len;
- //*pstr = '\0';
- } else {
- *pcb = cb;
- memcpy_s(pbBuff, cb, (LPCSTR)*pstr, *pcb);
- *pstr += cb;
- }
- return FALSE;
+ if (len < cb) {
+ *pcb = len;
+ memcpy_s(pbBuff, cb, (LPCSTR)*pstr, *pcb);
+ *pstr += len;
+ //*pstr = '\0';
+ } else {
+ *pcb = cb;
+ memcpy_s(pbBuff, cb, (LPCSTR)*pstr, *pcb);
+ *pstr += cb;
+ }
+ return FALSE;
}
// ----------------------------------------------------------------------------
@@ -941,379 +941,379 @@ static DWORD CALLBACK _LoadRtfCallback(
//
INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- static HFONT hVersionFont = NULL;
- static char pAboutResource[8192] = { '\0' };
- static char* pAboutInfo = NULL;
- static UINT dpi = USER_DEFAULT_SCREEN_DPI;
- static HBRUSH hbrBkgnd = NULL;
+ static HFONT hVersionFont = NULL;
+ static char pAboutResource[8192] = { '\0' };
+ static char* pAboutInfo = NULL;
+ static UINT dpi = USER_DEFAULT_SCREEN_DPI;
+ static HBRUSH hbrBkgnd = NULL;
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- //~InitWindowCommon(hwnd, true);
- //~SetWindowLayoutRTL(hwnd, Settings.DialogsLayoutRTL);
- SetExplorerTheme(hwnd);
+ //~InitWindowCommon(hwnd, true);
+ //~SetWindowLayoutRTL(hwnd, Settings.DialogsLayoutRTL);
+ SetExplorerTheme(hwnd);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDC_COPYVERSTRG));
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDC_COPYVERSTRG));
+ }
#endif
- dpi = Scintilla_GetWindowDPI(hwnd);
+ dpi = Scintilla_GetWindowDPI(hwnd);
- SetDlgItemText(hwnd, IDC_VERSION, _W(_STRG(VERSION_FILEVERSION_LONG)));
- SetDlgItemText(hwnd, IDC_SCI_VERSION, VERSION_SCIVERSION L", " VERSION_LXIVERSION L", ID='" _W(_STRG(VERSION_COMMIT_ID)) L"'");
- SetDlgItemText(hwnd, IDC_COPYRIGHT, _W(VERSION_LEGALCOPYRIGHT));
- SetDlgItemText(hwnd, IDC_AUTHORNAME, _W(VERSION_AUTHORNAME));
- SetDlgItemText(hwnd, IDC_COMPILER, VERSION_COMPILER);
+ SetDlgItemText(hwnd, IDC_VERSION, _W(_STRG(VERSION_FILEVERSION_LONG)));
+ SetDlgItemText(hwnd, IDC_SCI_VERSION, VERSION_SCIVERSION L", " VERSION_LXIVERSION L", ID='" _W(_STRG(VERSION_COMMIT_ID)) L"'");
+ SetDlgItemText(hwnd, IDC_COPYRIGHT, _W(VERSION_LEGALCOPYRIGHT));
+ SetDlgItemText(hwnd, IDC_AUTHORNAME, _W(VERSION_AUTHORNAME));
+ SetDlgItemText(hwnd, IDC_COMPILER, VERSION_COMPILER);
- WCHAR wch[256] = { L'\0' };
- if (GetDlgItem(hwnd, IDC_WEBPAGE) == NULL) {
- SetDlgItemText(hwnd, IDC_WEBPAGE2, _W(VERSION_WEBPAGEDISPLAY));
- ShowWindow(GetDlgItem(hwnd, IDC_WEBPAGE2), SW_SHOWNORMAL);
- } else {
- StringCchPrintf(wch, COUNTOF(wch), L"%s", _W(VERSION_WEBPAGEDISPLAY));
- SetDlgItemText(hwnd, IDC_WEBPAGE, wch);
- }
- GetLngString(IDS_MUI_TRANSL_AUTHOR, wch, COUNTOF(wch));
- SetDlgItemText(hwnd, IDC_TRANSL_AUTH, wch);
+ WCHAR wch[256] = { L'\0' };
+ if (GetDlgItem(hwnd, IDC_WEBPAGE) == NULL) {
+ SetDlgItemText(hwnd, IDC_WEBPAGE2, _W(VERSION_WEBPAGEDISPLAY));
+ ShowWindow(GetDlgItem(hwnd, IDC_WEBPAGE2), SW_SHOWNORMAL);
+ } else {
+ StringCchPrintf(wch, COUNTOF(wch), L"%s", _W(VERSION_WEBPAGEDISPLAY));
+ SetDlgItemText(hwnd, IDC_WEBPAGE, wch);
+ }
+ GetLngString(IDS_MUI_TRANSL_AUTHOR, wch, COUNTOF(wch));
+ SetDlgItemText(hwnd, IDC_TRANSL_AUTH, wch);
- // --- Rich Edit Control ---
- //SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETBKGNDCOLOR, 0, (LPARAM)GetBackgroundColor(hwnd));
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETBKGNDCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE));
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SHOWSCROLLBAR, SB_VERT, TRUE);
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, 1, 1); //, 0, 0); // OFF
+ // --- Rich Edit Control ---
+ //SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETBKGNDCOLOR, 0, (LPARAM)GetBackgroundColor(hwnd));
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETBKGNDCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE));
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SHOWSCROLLBAR, SB_VERT, TRUE);
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, 1, 1); //, 0, 0); // OFF
- DWORD styleFlags = SES_EXTENDBACKCOLOR; // | SES_HYPERLINKTOOLTIPS;
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETEDITSTYLE, (WPARAM)styleFlags, (LPARAM)styleFlags);
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_AUTOURLDETECT, (WPARAM)1, (LPARAM)0);
+ DWORD styleFlags = SES_EXTENDBACKCOLOR; // | SES_HYPERLINKTOOLTIPS;
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETEDITSTYLE, (WPARAM)styleFlags, (LPARAM)styleFlags);
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_AUTOURLDETECT, (WPARAM)1, (LPARAM)0);
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETEVENTMASK, 0, (LPARAM)(ENM_LINK)); // link click
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETEVENTMASK, 0, (LPARAM)(ENM_LINK)); // link click
- //~if (StrIsEmptyA(pAboutResource)) { ~ maybe language resource changed, so reload
- char pAboutRes[4096];
- StringCchCopyA(pAboutResource, COUNTOF(pAboutResource), "");
- GetLngStringA(IDS_MUI_ABOUT_RTF_0, pAboutRes, COUNTOF(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));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_CONTRIBS, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_RTF_2, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_LIBS, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_RTF_3, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_ACKNOWLEDGES, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_RTF_4, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_MORE, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_RTF_5, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_LICENSES, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- GetLngStringA(IDS_MUI_ABOUT_RTF_6, pAboutRes, COUNTOF(pAboutRes));
- StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
- //~}
+ //~if (StrIsEmptyA(pAboutResource)) { ~ maybe language resource changed, so reload
+ char pAboutRes[4096];
+ StringCchCopyA(pAboutResource, COUNTOF(pAboutResource), "");
+ GetLngStringA(IDS_MUI_ABOUT_RTF_0, pAboutRes, COUNTOF(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));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_CONTRIBS, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_RTF_2, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_LIBS, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_RTF_3, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_ACKNOWLEDGES, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_RTF_4, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_MORE, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_RTF_5, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_LICENSES, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ GetLngStringA(IDS_MUI_ABOUT_RTF_6, pAboutRes, COUNTOF(pAboutRes));
+ StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes);
+ //~}
- CenterDlgInParent(hwnd, NULL);
+ CenterDlgInParent(hwnd, NULL);
- HFONT const hFont = (HFONT)SendDlgItemMessage(hwnd, IDC_SCI_VERSION, WM_GETFONT, 0, 0);
- if (hFont) {
- LOGFONT lf = { 0 };
- GetObject(hFont, sizeof(LOGFONT), &lf);
- lf.lfHeight = MulDiv(lf.lfHeight, 3, 2);
- lf.lfWeight = FW_BOLD;
- //lf.lfUnderline = true;
- if (hVersionFont) {
- DeleteObject(hVersionFont);
- }
- hVersionFont = CreateFontIndirectW(&lf);
- SendDlgItemMessageW(hwnd, IDC_VERSION, WM_SETFONT, (WPARAM)hVersionFont, true);
- }
+ HFONT const hFont = (HFONT)SendDlgItemMessage(hwnd, IDC_SCI_VERSION, WM_GETFONT, 0, 0);
+ if (hFont) {
+ LOGFONT lf = { 0 };
+ GetObject(hFont, sizeof(LOGFONT), &lf);
+ lf.lfHeight = MulDiv(lf.lfHeight, 3, 2);
+ lf.lfWeight = FW_BOLD;
+ //lf.lfUnderline = true;
+ if (hVersionFont) {
+ DeleteObject(hVersionFont);
+ }
+ hVersionFont = CreateFontIndirectW(&lf);
+ SendDlgItemMessageW(hwnd, IDC_VERSION, WM_SETFONT, (WPARAM)hVersionFont, true);
+ }
- // render rich-edit control text again
- if (!StrIsEmptyA(pAboutResource)) {
- pAboutInfo = pAboutResource;
- EDITSTREAM editStreamIn = {(DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallback};
- if (UseDarkMode()) {
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETBKGNDCOLOR, 0, (LPARAM)RGB(0x80, 0x80, 0x80));
- }
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn);
- }
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SHOWSCROLLBAR, SB_HORZ, (LPARAM)(dpi > USER_DEFAULT_SCREEN_DPI));
+ // render rich-edit control text again
+ if (!StrIsEmptyA(pAboutResource)) {
+ pAboutInfo = pAboutResource;
+ EDITSTREAM editStreamIn = {(DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallback};
+ if (UseDarkMode()) {
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETBKGNDCOLOR, 0, (LPARAM)RGB(0x80, 0x80, 0x80));
+ }
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn);
+ }
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SHOWSCROLLBAR, SB_HORZ, (LPARAM)(dpi > USER_DEFAULT_SCREEN_DPI));
- // RichEdit-Ctrl DPI-BUG: it initially uses the DPI setting of
- // the main(1) screen instead it's current parent window screen DPI
- UINT const dpiPrime = Scintilla_GetWindowDPI(NULL);
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, (WPARAM)dpi, (LPARAM)dpiPrime);
+ // RichEdit-Ctrl DPI-BUG: it initially uses the DPI setting of
+ // the main(1) screen instead it's current parent window screen DPI
+ UINT const dpiPrime = Scintilla_GetWindowDPI(NULL);
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, (WPARAM)dpi, (LPARAM)dpiPrime);
- int const width = ScaleIntByDPI(136, dpi);
- int const height = ScaleIntByDPI(41, dpi);
- HBITMAP hBmp = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDR_RIZBITMAP), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
- SetBitmapControlResample(hwnd, IDC_RIZONEBMP, hBmp, width, height);
- DeleteObject(hBmp);
- }
- break;
+ int const width = ScaleIntByDPI(136, dpi);
+ int const height = ScaleIntByDPI(41, dpi);
+ HBITMAP hBmp = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDR_RIZBITMAP), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ SetBitmapControlResample(hwnd, IDC_RIZONEBMP, hBmp, width, height);
+ DeleteObject(hBmp);
+ }
+ break;
- case WM_DESTROY:
- if (hVersionFont) {
- DeleteObject(hVersionFont);
- hVersionFont = NULL;
- }
- break;
+ case WM_DESTROY:
+ if (hVersionFont) {
+ DeleteObject(hVersionFont);
+ hVersionFont = NULL;
+ }
+ break;
- case WM_DPICHANGED: {
- dpi = LOWORD(wParam);
- //dpi.y = HIWORD(wParam);
+ case WM_DPICHANGED: {
+ dpi = LOWORD(wParam);
+ //dpi.y = HIWORD(wParam);
- // render rich-edit control text again
- if (!StrIsEmptyA(pAboutResource)) {
- pAboutInfo = pAboutResource;
- EDITSTREAM editStreamIn = {(DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallback};
- if (UseDarkMode()) {
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETBKGNDCOLOR, 0, (LPARAM)RGB(0xA0,0xA0,0xA0));
- }
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn);
- }
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SHOWSCROLLBAR, SB_HORZ, (LPARAM)(dpi > USER_DEFAULT_SCREEN_DPI));
- //~SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, (WPARAM)dpi.y, (LPARAM)USER_DEFAULT_SCREEN_DPI);
+ // render rich-edit control text again
+ if (!StrIsEmptyA(pAboutResource)) {
+ pAboutInfo = pAboutResource;
+ EDITSTREAM editStreamIn = {(DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallback};
+ if (UseDarkMode()) {
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETBKGNDCOLOR, 0, (LPARAM)RGB(0xA0,0xA0,0xA0));
+ }
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn);
+ }
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SHOWSCROLLBAR, SB_HORZ, (LPARAM)(dpi > USER_DEFAULT_SCREEN_DPI));
+ //~SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, (WPARAM)dpi.y, (LPARAM)USER_DEFAULT_SCREEN_DPI);
- int const width = ScaleIntByDPI(136, dpi);
- int const height = ScaleIntByDPI(41, dpi);
- HBITMAP hBmp = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDR_RIZBITMAP), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
- SetBitmapControlResample(hwnd, IDC_RIZONEBMP, hBmp, width, height);
- DeleteObject(hBmp);
+ int const width = ScaleIntByDPI(136, dpi);
+ int const height = ScaleIntByDPI(41, dpi);
+ HBITMAP hBmp = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDR_RIZBITMAP), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ SetBitmapControlResample(hwnd, IDC_RIZONEBMP, hBmp, width, height);
+ DeleteObject(hBmp);
- HFONT const hFont = (HFONT)SendDlgItemMessage(hwnd, IDC_SCI_VERSION, WM_GETFONT, 0, 0);
- if (hFont) {
- LOGFONT lf = { 0 };
- GetObject(hFont, sizeof(LOGFONT), &lf);
- lf.lfHeight = MulDiv(lf.lfHeight, 3, 2);
- lf.lfWeight = FW_BOLD;
- //lf.lfUnderline = true;
- if (hVersionFont) {
- DeleteObject(hVersionFont);
- }
- hVersionFont = CreateFontIndirectW(&lf);
- SendDlgItemMessageW(hwnd, IDC_VERSION, WM_SETFONT, (WPARAM)hVersionFont, true);
- }
+ HFONT const hFont = (HFONT)SendDlgItemMessage(hwnd, IDC_SCI_VERSION, WM_GETFONT, 0, 0);
+ if (hFont) {
+ LOGFONT lf = { 0 };
+ GetObject(hFont, sizeof(LOGFONT), &lf);
+ lf.lfHeight = MulDiv(lf.lfHeight, 3, 2);
+ lf.lfWeight = FW_BOLD;
+ //lf.lfUnderline = true;
+ if (hVersionFont) {
+ DeleteObject(hVersionFont);
+ }
+ hVersionFont = CreateFontIndirectW(&lf);
+ SendDlgItemMessageW(hwnd, IDC_VERSION, WM_SETFONT, (WPARAM)hVersionFont, true);
+ }
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- }
- break;
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ }
+ break;
#ifdef D_NP3_WIN10_DARK_MODE
- //case WM_ERASEBKGND:
- // if (UseDarkMode()) {
- // HDC const hdc = (HDC)wParam;
- // SelectObject((HDC)wParam, Globals.hbrDarkModeBkgBrush);
- // RECT rc;
- // GetClientRect(hwnd, &rc);
- // SetMapMode(hdc, MM_ANISOTROPIC);
- // SetWindowExtEx(hdc, 100, 100, NULL);
- // SetViewportExtEx(hdc, rc.right, rc.bottom, NULL);
- // FillRect(hdc, &rc, Globals.hbrDarkModeBkgBrush);
- // }
- // return TRUE;
+ //case WM_ERASEBKGND:
+ // if (UseDarkMode()) {
+ // HDC const hdc = (HDC)wParam;
+ // SelectObject((HDC)wParam, Globals.hbrDarkModeBkgBrush);
+ // RECT rc;
+ // GetClientRect(hwnd, &rc);
+ // SetMapMode(hdc, MM_ANISOTROPIC);
+ // SetWindowExtEx(hdc, 100, 100, NULL);
+ // SetViewportExtEx(hdc, rc.right, rc.bottom, NULL);
+ // FillRect(hdc, &rc, Globals.hbrDarkModeBkgBrush);
+ // }
+ // return TRUE;
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDC_COPYVERSTRG };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDC_COPYVERSTRG };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_PAINT: {
- PAINTSTRUCT ps;
- HDC const hdc = GetDC(hwnd); // ClientArea
- if (hdc) {
- BeginPaint(hwnd, &ps);
- SetMapMode(hdc, MM_TEXT);
+ case WM_PAINT: {
+ PAINTSTRUCT ps;
+ HDC const hdc = GetDC(hwnd); // ClientArea
+ if (hdc) {
+ BeginPaint(hwnd, &ps);
+ SetMapMode(hdc, MM_TEXT);
- int const iconSize = 128;
- int const dpiWidth = ScaleIntByDPI(iconSize, dpi);
- int const dpiHeight = ScaleIntByDPI(iconSize, dpi);
- HICON const hicon = (dpiHeight > 128) ? Globals.hDlgIcon256 : Globals.hDlgIcon128;
- if (hicon) {
- //RECT rc = {0};
- //MapWindowPoints(GetDlgItem(hwnd, IDC_INFO_GROUPBOX), hwnd, (LPPOINT)&rc, 2);
- DrawIconEx(hdc, ScaleIntByDPI(10, dpi), ScaleIntByDPI(10, dpi), hicon, dpiWidth, dpiHeight, 0, NULL, DI_NORMAL);
- }
+ int const iconSize = 128;
+ int const dpiWidth = ScaleIntByDPI(iconSize, dpi);
+ int const dpiHeight = ScaleIntByDPI(iconSize, dpi);
+ HICON const hicon = (dpiHeight > 128) ? Globals.hDlgIcon256 : Globals.hDlgIcon128;
+ if (hicon) {
+ //RECT rc = {0};
+ //MapWindowPoints(GetDlgItem(hwnd, IDC_INFO_GROUPBOX), hwnd, (LPPOINT)&rc, 2);
+ DrawIconEx(hdc, ScaleIntByDPI(10, dpi), ScaleIntByDPI(10, dpi), hicon, dpiWidth, dpiHeight, 0, NULL, DI_NORMAL);
+ }
- ReleaseDC(hwnd, hdc);
- EndPaint(hwnd, &ps);
- }
- }
- return FALSE;
+ ReleaseDC(hwnd, hdc);
+ EndPaint(hwnd, &ps);
+ }
+ }
+ return FALSE;
- case WM_NOTIFY: {
- LPNMHDR pnmhdr = (LPNMHDR)lParam;
- switch (pnmhdr->code) {
- case NM_CLICK:
- case NM_RETURN: {
- switch (pnmhdr->idFrom) {
- case IDC_WEBPAGE:
- ShellExecute(hwnd, L"open", L"https://www.rizonesoft.com", NULL, NULL, SW_SHOWNORMAL);
- break;
+ case WM_NOTIFY: {
+ LPNMHDR pnmhdr = (LPNMHDR)lParam;
+ switch (pnmhdr->code) {
+ case NM_CLICK:
+ case NM_RETURN: {
+ switch (pnmhdr->idFrom) {
+ case IDC_WEBPAGE:
+ ShellExecute(hwnd, L"open", L"https://www.rizonesoft.com", NULL, NULL, SW_SHOWNORMAL);
+ break;
- default:
- break;
- }
- }
- break;
+ default:
+ break;
+ }
+ }
+ break;
- case EN_LINK: { // hyperlink from RichEdit Ctrl
- ENLINK* penLink = (ENLINK *)lParam;
- if (penLink->msg == WM_LBUTTONDOWN) {
- WCHAR hLink[256] = { L'\0' };
- TEXTRANGE txtRng = { 0 };
- txtRng.chrg = penLink->chrg;
- txtRng.lpstrText = hLink;
- SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_GETTEXTRANGE, 0, (LPARAM)&txtRng);
- ShellExecute(hwnd, L"open", hLink, NULL, NULL, SW_SHOWNORMAL);
- }
- }
- break;
- }
- }
- break;
+ case EN_LINK: { // hyperlink from RichEdit Ctrl
+ ENLINK* penLink = (ENLINK *)lParam;
+ if (penLink->msg == WM_LBUTTONDOWN) {
+ WCHAR hLink[256] = { L'\0' };
+ TEXTRANGE txtRng = { 0 };
+ txtRng.chrg = penLink->chrg;
+ txtRng.lpstrText = hLink;
+ SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_GETTEXTRANGE, 0, (LPARAM)&txtRng);
+ ShellExecute(hwnd, L"open", hLink, NULL, NULL, SW_SHOWNORMAL);
+ }
+ }
+ break;
+ }
+ }
+ break;
- case WM_SETCURSOR: {
- if ((LOWORD(lParam) == HTCLIENT) &&
- (GetDlgCtrlID((HWND)wParam) == IDC_RIZONEBMP)) {
- SetCursor(LoadCursor(NULL, IDC_HAND));
- SetWindowLongPtr(hwnd, DWLP_MSGRESULT, (LONG_PTR)true);
- return TRUE;
- }
- }
- break;
+ case WM_SETCURSOR: {
+ if ((LOWORD(lParam) == HTCLIENT) &&
+ (GetDlgCtrlID((HWND)wParam) == IDC_RIZONEBMP)) {
+ SetCursor(LoadCursor(NULL, IDC_HAND));
+ SetWindowLongPtr(hwnd, DWLP_MSGRESULT, (LONG_PTR)true);
+ return TRUE;
+ }
+ }
+ break;
- case WM_COMMAND:
+ case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_RIZONEBMP:
- ShellExecute(hwnd, L"open", _W(VERSION_WEBPAGEDISPLAY), NULL, NULL, SW_SHOWNORMAL);
- break;
+ switch (LOWORD(wParam)) {
+ case IDC_RIZONEBMP:
+ ShellExecute(hwnd, L"open", _W(VERSION_WEBPAGEDISPLAY), NULL, NULL, SW_SHOWNORMAL);
+ break;
- case IDC_COPYVERSTRG: {
- WCHAR wchBuf[128] = { L'\0' };
- WCHAR wchBuf2[128] = { L'\0' };
- WCHAR wchVerInfo[2048] = { L'\0' };
+ case IDC_COPYVERSTRG: {
+ WCHAR wchBuf[128] = { L'\0' };
+ WCHAR wchBuf2[128] = { L'\0' };
+ WCHAR wchVerInfo[2048] = { L'\0' };
- int ResX, ResY;
- GetCurrentMonitorResolution(Globals.hwndMain, &ResX, &ResY);
+ int ResX, ResY;
+ GetCurrentMonitorResolution(Globals.hwndMain, &ResX, &ResY);
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
- StringCchCopy(wchVerInfo, COUNTOF(wchVerInfo), _W(_STRG(VERSION_FILEVERSION_LONG)) L" (" _W(_STRG(VERSION_COMMIT_ID)) L")");
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_COMPILER);
+ StringCchCopy(wchVerInfo, COUNTOF(wchVerInfo), _W(_STRG(VERSION_FILEVERSION_LONG)) L" (" _W(_STRG(VERSION_COMMIT_ID)) L")");
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_COMPILER);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n");
- GetWinVersionString(wchBuf, COUNTOF(wchBuf));
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n");
+ GetWinVersionString(wchBuf, COUNTOF(wchBuf));
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
- bool const bDarkModeSupported = IsDarkModeSupported();
- bool const bIsThemeEnabled = ShouldAppsUseDarkModeEx();
- StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\nWindows Colors 'Dark-Mode' Theme is %s.",
- bDarkModeSupported ? (bIsThemeEnabled ? L"SUPPORTED and SELECTED" : L"SUPPORTED but NOT SELECTED") : L"NO SUPPORTED");
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
+ bool const bDarkModeSupported = IsDarkModeSupported();
+ bool const bIsThemeEnabled = ShouldAppsUseDarkModeEx();
+ StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\nWindows Colors 'Dark-Mode' Theme is %s.",
+ bDarkModeSupported ? (bIsThemeEnabled ? L"SUPPORTED and SELECTED" : L"SUPPORTED but NOT SELECTED") : L"NO SUPPORTED");
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_SCIVERSION);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_LXIVERSION);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_ONIGURUMA);
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_SCIVERSION);
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_LXIVERSION);
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_ONIGURUMA);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), (IsProcessElevated() ? L"\n- Process is elevated." : L"\n- Process is not elevated"));
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), (IsUserInAdminGroup() ? L"\n- User is in Admin-Group." : L"\n- User is not in Admin-Group"));
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), (IsProcessElevated() ? L"\n- Process is elevated." : L"\n- Process is not elevated"));
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), (IsUserInAdminGroup() ? L"\n- User is in Admin-Group." : L"\n- User is not in Admin-Group"));
- StringCchCopy(wchBuf, COUNTOF(wchBuf), MUI_BASE_LNG_ID);
- #if defined(HAVE_DYN_LOAD_LIBS_MUI_LNGS)
- for (unsigned lng = 0; lng < MuiLanguages_CountOf(); ++lng) {
- if (IsMUILanguageActive(lng)) {
- StringCchCopy(wchBuf, COUNTOF(wchBuf), GetMUILocaleNameByIndex(lng));
- break;
- }
- }
- #endif
+ StringCchCopy(wchBuf, COUNTOF(wchBuf), MUI_BASE_LNG_ID);
+ #if defined(HAVE_DYN_LOAD_LIBS_MUI_LNGS)
+ for (unsigned lng = 0; lng < MuiLanguages_CountOf(); ++lng) {
+ if (IsMUILanguageActive(lng)) {
+ StringCchCopy(wchBuf, COUNTOF(wchBuf), GetMUILocaleNameByIndex(lng));
+ break;
+ }
+ }
+ #endif
- StringCchPrintf(wchBuf2, ARRAYSIZE(wchBuf2), L"\n- Locale -> %s (CP:'%s')",
- wchBuf, g_Encodings[CPI_ANSI_DEFAULT].wchLabel);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf2);
+ StringCchPrintf(wchBuf2, ARRAYSIZE(wchBuf2), L"\n- Locale -> %s (CP:'%s')",
+ wchBuf, g_Encodings[CPI_ANSI_DEFAULT].wchLabel);
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf2);
- StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Current Encoding -> '%s'", Encoding_GetLabel(Encoding_GetCurrent()));
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
+ StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Current Encoding -> '%s'", Encoding_GetLabel(Encoding_GetCurrent()));
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
- if (bDarkModeSupported && bIsThemeEnabled) {
- StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Dark-Mode enabled -> %s", CheckDarkModeEnabled() ? L"YES" : L"NO");
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
- }
+ if (bDarkModeSupported && bIsThemeEnabled) {
+ StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Dark-Mode enabled -> %s", CheckDarkModeEnabled() ? L"YES" : L"NO");
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
+ }
- StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Screen-Resolution -> %i x %i [pix]", ResX, ResY);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
+ StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Screen-Resolution -> %i x %i [pix]", ResX, ResY);
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
- StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Display-DPI -> %i x %i (Scale: %i%%).", dpi, dpi, ScaleIntToDPI(hwnd, 100));
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
+ StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Display-DPI -> %i x %i (Scale: %i%%).", dpi, dpi, ScaleIntToDPI(hwnd, 100));
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
- StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Rendering-Technology -> '%s'", Settings.RenderingTechnology ? L"DIRECT-WRITE" : L"GDI");
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
+ StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Rendering-Technology -> '%s'", Settings.RenderingTechnology ? L"DIRECT-WRITE" : L"GDI");
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
- StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Zoom -> %i%%.", SciCall_GetZoom());
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
+ StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Zoom -> %i%%.", SciCall_GetZoom());
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
- Style_GetLexerDisplayName(Style_GetCurrentLexerPtr(), wchBuf, COUNTOF(wchBuf));
- StringCchPrintf(wchBuf2, ARRAYSIZE(wchBuf2), L"\n- Current Lexer -> '%s'", wchBuf);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf2);
+ Style_GetLexerDisplayName(Style_GetCurrentLexerPtr(), wchBuf, COUNTOF(wchBuf));
+ StringCchPrintf(wchBuf2, ARRAYSIZE(wchBuf2), L"\n- Current Lexer -> '%s'", wchBuf);
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf2);
- StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n");
+ StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n");
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
- SetClipboardText(Globals.hwndMain, wchVerInfo, StringCchLen(wchVerInfo,0));
- }
- break;
+ SetClipboardText(Globals.hwndMain, wchVerInfo, StringCchLen(wchVerInfo,0));
+ }
+ break;
- case IDOK:
- case IDCANCEL:
- EndDialog(hwnd, IDOK);
- break;
- }
- return TRUE;
- }
- return FALSE;
+ case IDOK:
+ case IDCANCEL:
+ EndDialog(hwnd, IDOK);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -1324,191 +1324,191 @@ CASE_WM_CTLCOLOR_SET:
//
static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- SetExplorerTheme(GetDlgItem(hwnd, IDC_SEARCHEXE));
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ SetExplorerTheme(GetDlgItem(hwnd, IDC_SEARCHEXE));
+ }
#endif
- // MakeBitmapButton(hwnd,IDC_SEARCHEXE,IDB_OPEN, -1, -1);
- SendDlgItemMessage(hwnd, IDC_COMMANDLINE, EM_LIMITTEXT, MAX_PATH - 1, 0);
- SetDlgItemText(hwnd, IDC_COMMANDLINE, (LPCWSTR)lParam); //TODO: §§§ MAX_PATH limit §§§ @@@!
- SHAutoComplete(GetDlgItem(hwnd, IDC_COMMANDLINE), SHACF_FILESYSTEM);
+ // MakeBitmapButton(hwnd,IDC_SEARCHEXE,IDB_OPEN, -1, -1);
+ SendDlgItemMessage(hwnd, IDC_COMMANDLINE, EM_LIMITTEXT, MAX_PATH - 1, 0);
+ SetDlgItemText(hwnd, IDC_COMMANDLINE, (LPCWSTR)lParam); //TODO: §§§ MAX_PATH limit §§§ @@@!
+ SHAutoComplete(GetDlgItem(hwnd, IDC_COMMANDLINE), SHACF_FILESYSTEM);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
- case WM_DESTROY:
- DeleteBitmapButton(hwnd, IDC_SEARCHEXE);
- return FALSE;
+ case WM_DESTROY:
+ DeleteBitmapButton(hwnd, IDC_SEARCHEXE);
+ return FALSE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL, IDC_SEARCHEXE };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL, IDC_SEARCHEXE };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
+ case WM_COMMAND:
- switch (LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
- case IDC_SEARCHEXE: {
- WCHAR szArgs[MAX_PATH] = { L'\0' };
- WCHAR szArg2[MAX_PATH] = { L'\0' };
- WCHAR szFile[MAX_PATH] = { L'\0' };
- WCHAR szFilter[MAX_PATH] = { L'\0' };
+ case IDC_SEARCHEXE: {
+ WCHAR szArgs[MAX_PATH] = { L'\0' };
+ WCHAR szArg2[MAX_PATH] = { L'\0' };
+ WCHAR szFile[MAX_PATH] = { L'\0' };
+ WCHAR szFilter[MAX_PATH] = { L'\0' };
- GetDlgItemText(hwnd, IDC_COMMANDLINE, szArgs, COUNTOF(szArgs));
- ExpandEnvironmentStringsEx(szArgs, COUNTOF(szArgs));
- ExtractFirstArgument(szArgs, szFile, szArg2, MAX_PATH);
+ GetDlgItemText(hwnd, IDC_COMMANDLINE, szArgs, COUNTOF(szArgs));
+ ExpandEnvironmentStringsEx(szArgs, COUNTOF(szArgs));
+ ExtractFirstArgument(szArgs, szFile, szArg2, MAX_PATH);
- GetLngString(IDS_MUI_FILTER_EXE, szFilter, COUNTOF(szFilter));
- PrepareFilterStr(szFilter);
+ GetLngString(IDS_MUI_FILTER_EXE, szFilter, COUNTOF(szFilter));
+ PrepareFilterStr(szFilter);
- OPENFILENAME ofn = { 0 };
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = hwnd;
- ofn.lpstrFilter = szFilter;
- ofn.lpstrFile = szFile;
- ofn.nMaxFile = COUNTOF(szFile);
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
- | OFN_PATHMUSTEXIST | OFN_SHAREAWARE | OFN_NODEREFERENCELINKS;
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwnd;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrFile = szFile;
+ ofn.nMaxFile = COUNTOF(szFile);
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
+ | OFN_PATHMUSTEXIST | OFN_SHAREAWARE | OFN_NODEREFERENCELINKS;
- if (GetOpenFileName(&ofn)) {
- PathQuoteSpaces(szFile);
- if (StrIsNotEmpty(szArg2)) {
- StringCchCat(szFile, COUNTOF(szFile), L" ");
- StringCchCat(szFile, COUNTOF(szFile), szArg2);
- }
- SetDlgItemText(hwnd, IDC_COMMANDLINE, szFile);
- }
- PostMessage(hwnd, WM_NEXTDLGCTL, 1, 0);
- }
- break;
+ if (GetOpenFileName(&ofn)) {
+ PathQuoteSpaces(szFile);
+ if (StrIsNotEmpty(szArg2)) {
+ StringCchCat(szFile, COUNTOF(szFile), L" ");
+ StringCchCat(szFile, COUNTOF(szFile), szArg2);
+ }
+ SetDlgItemText(hwnd, IDC_COMMANDLINE, szFile);
+ }
+ PostMessage(hwnd, WM_NEXTDLGCTL, 1, 0);
+ }
+ break;
- case IDC_COMMANDLINE: {
- bool bEnableOK = false;
- WCHAR args[MAX_PATH] = { L'\0' };
+ case IDC_COMMANDLINE: {
+ bool bEnableOK = false;
+ WCHAR args[MAX_PATH] = { L'\0' };
- if (GetDlgItemText(hwnd, IDC_COMMANDLINE, args, MAX_PATH)) {
- if (ExtractFirstArgument(args, args, NULL, MAX_PATH)) {
- if (StrIsNotEmpty(args)) {
- bEnableOK = true;
- }
- }
- }
- DialogEnableControl(hwnd, IDOK, bEnableOK);
- }
- break;
+ if (GetDlgItemText(hwnd, IDC_COMMANDLINE, args, MAX_PATH)) {
+ if (ExtractFirstArgument(args, args, NULL, MAX_PATH)) {
+ if (StrIsNotEmpty(args)) {
+ bEnableOK = true;
+ }
+ }
+ }
+ DialogEnableControl(hwnd, IDOK, bEnableOK);
+ }
+ break;
- case IDOK: {
- WCHAR arg1[MAX_PATH] = { L'\0' };
- WCHAR arg2[MAX_PATH] = { L'\0' };
+ case IDOK: {
+ WCHAR arg1[MAX_PATH] = { L'\0' };
+ WCHAR arg2[MAX_PATH] = { L'\0' };
- if (GetDlgItemText(hwnd, IDC_COMMANDLINE, arg1, MAX_PATH)) {
+ if (GetDlgItemText(hwnd, IDC_COMMANDLINE, arg1, MAX_PATH)) {
- bool bQuickExit = false;
+ bool bQuickExit = false;
- ExpandEnvironmentStringsEx(arg1, COUNTOF(arg1));
- ExtractFirstArgument(arg1, arg1, arg2, MAX_PATH);
+ ExpandEnvironmentStringsEx(arg1, COUNTOF(arg1));
+ ExtractFirstArgument(arg1, arg1, arg2, MAX_PATH);
- if (StringCchCompareNI(arg1, COUNTOF(arg1), _W(SAPPNAME), CONSTSTRGLEN(_W(SAPPNAME))) == 0 ||
- StringCchCompareNI(arg1, COUNTOF(arg1), _W(SAPPNAME) L".exe", CONSTSTRGLEN(_W(SAPPNAME) L".exe")) == 0) {
- GetModuleFileName(NULL, arg1, COUNTOF(arg1));
- PathCanonicalizeEx(arg1, COUNTOF(arg1));
- bQuickExit = true;
- }
+ if (StringCchCompareNI(arg1, COUNTOF(arg1), _W(SAPPNAME), CONSTSTRGLEN(_W(SAPPNAME))) == 0 ||
+ StringCchCompareNI(arg1, COUNTOF(arg1), _W(SAPPNAME) L".exe", CONSTSTRGLEN(_W(SAPPNAME) L".exe")) == 0) {
+ GetModuleFileName(NULL, arg1, COUNTOF(arg1));
+ PathCanonicalizeEx(arg1, COUNTOF(arg1));
+ bQuickExit = true;
+ }
- HPATHL pthDirectory = NULL;
- if (Path_IsNotEmpty(Paths.CurrentFile)) {
- pthDirectory = Path_Copy(Paths.CurrentFile);
- Path_RemoveFileSpec(pthDirectory);
- }
+ HPATHL pthDirectory = NULL;
+ if (Path_IsNotEmpty(Paths.CurrentFile)) {
+ pthDirectory = Path_Copy(Paths.CurrentFile);
+ Path_RemoveFileSpec(pthDirectory);
+ }
- SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
- sei.fMask = SEE_MASK_DEFAULT;
- sei.hwnd = hwnd;
- sei.lpVerb = NULL;
- sei.lpFile = arg1;
- sei.lpParameters = arg2;
- sei.lpDirectory = Path_Get(pthDirectory);
- sei.nShow = SW_SHOWNORMAL;
+ SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
+ sei.fMask = SEE_MASK_DEFAULT;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = arg1;
+ sei.lpParameters = arg2;
+ sei.lpDirectory = Path_Get(pthDirectory);
+ sei.nShow = SW_SHOWNORMAL;
- if (bQuickExit) {
- sei.fMask |= SEE_MASK_NOZONECHECKS;
- EndDialog(hwnd, IDOK);
- ShellExecuteEx(&sei);
- }
+ if (bQuickExit) {
+ sei.fMask |= SEE_MASK_NOZONECHECKS;
+ EndDialog(hwnd, IDOK);
+ ShellExecuteEx(&sei);
+ }
- else {
- if (ShellExecuteEx(&sei)) {
- EndDialog(hwnd, IDOK);
- }
+ else {
+ if (ShellExecuteEx(&sei)) {
+ EndDialog(hwnd, IDOK);
+ }
- else
- PostMessage(hwnd, WM_NEXTDLGCTL,
- (WPARAM)(GetDlgItem(hwnd, IDC_COMMANDLINE)), 1);
- }
- Path_Release(pthDirectory);
- }
- }
- break;
+ else
+ PostMessage(hwnd, WM_NEXTDLGCTL,
+ (WPARAM)(GetDlgItem(hwnd, IDC_COMMANDLINE)), 1);
+ }
+ Path_Release(pthDirectory);
+ }
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+ break;
- }
+ }
- return TRUE;
+ return TRUE;
- }
+ }
- return FALSE;
+ return FALSE;
}
@@ -1519,7 +1519,7 @@ CASE_WM_CTLCOLOR_SET:
//
INT_PTR RunDlg(HWND hwnd,LPCWSTR lpstrDefault)
{
- return ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_RUN), hwnd, RunDlgProc, (LPARAM)lpstrDefault);
+ return ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_RUN), hwnd, RunDlgProc, (LPARAM)lpstrDefault);
}
@@ -1529,185 +1529,185 @@ INT_PTR RunDlg(HWND hwnd,LPCWSTR lpstrDefault)
//
static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
- static HWND hwndLV = NULL;
+ static HWND hwndLV = NULL;
- switch(umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch(umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_GETOPENWITHDIR));
- SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_GETOPENWITHDIR));
+ SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ }
#endif
- ResizeDlg_Init(hwnd, Settings.OpenWithDlgSizeX, Settings.OpenWithDlgSizeY, IDC_RESIZEGRIP);
+ ResizeDlg_Init(hwnd, Settings.OpenWithDlgSizeX, Settings.OpenWithDlgSizeY, IDC_RESIZEGRIP);
- LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+ LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
- hwndLV = GetDlgItem(hwnd, IDC_OPENWITHDIR);
- InitWindowCommon(hwndLV, true);
- InitListView(hwndLV); // DarkMode
+ hwndLV = GetDlgItem(hwnd, IDC_OPENWITHDIR);
+ InitWindowCommon(hwndLV, true);
+ InitListView(hwndLV); // DarkMode
- ListView_SetExtendedListViewStyle(hwndLV, /*LVS_EX_FULLROWSELECT|*/ LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
- ListView_InsertColumn(hwndLV, 0, &lvc);
- DirList_Init(hwndLV, NULL);
- DirList_Fill(hwndLV, Settings.OpenWithDir, DL_ALLOBJECTS, NULL, false, Flags.NoFadeHidden, DS_NAME, false);
- DirList_StartIconThread(hwndLV);
- ListView_SetItemState(hwndLV, 0, LVIS_FOCUSED, LVIS_FOCUSED);
+ ListView_SetExtendedListViewStyle(hwndLV, /*LVS_EX_FULLROWSELECT|*/ LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
+ ListView_InsertColumn(hwndLV, 0, &lvc);
+ DirList_Init(hwndLV, NULL);
+ DirList_Fill(hwndLV, Settings.OpenWithDir, DL_ALLOBJECTS, NULL, false, Flags.NoFadeHidden, DS_NAME, false);
+ DirList_StartIconThread(hwndLV);
+ ListView_SetItemState(hwndLV, 0, LVIS_FOCUSED, LVIS_FOCUSED);
- MakeBitmapButton(hwnd,IDC_GETOPENWITHDIR,IDB_OPEN, -1, -1);
+ MakeBitmapButton(hwnd,IDC_GETOPENWITHDIR,IDB_OPEN, -1, -1);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
- case WM_DESTROY:
- DirList_Destroy(hwndLV);
- hwndLV = NULL;
- DeleteBitmapButton(hwnd,IDC_GETOPENWITHDIR);
- ResizeDlg_Destroy(hwnd,&Settings.OpenWithDlgSizeX,&Settings.OpenWithDlgSizeY);
- return FALSE;
+ case WM_DESTROY:
+ DirList_Destroy(hwndLV);
+ hwndLV = NULL;
+ DeleteBitmapButton(hwnd,IDC_GETOPENWITHDIR);
+ ResizeDlg_Destroy(hwnd,&Settings.OpenWithDlgSizeX,&Settings.OpenWithDlgSizeY);
+ return FALSE;
- case WM_SIZE: {
- int dx, dy;
- ResizeDlg_Size(hwnd,lParam,&dx,&dy);
+ case WM_SIZE: {
+ 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);
- hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDIR,dx,dy,SWP_NOMOVE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETOPENWITHDIR,0,dy,SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDESCR,0,dy,SWP_NOSIZE);
- EndDeferWindowPos(hdwp);
+ HDWP hdwp;
+ hdwp = BeginDeferWindowPos(6);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDIR,dx,dy,SWP_NOMOVE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETOPENWITHDIR,0,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDESCR,0,dy,SWP_NOSIZE);
+ EndDeferWindowPos(hdwp);
- ListView_SetColumnWidth(hwndLV, 0, LVSCW_AUTOSIZE_USEHEADER);
- }
- return TRUE;
+ ListView_SetColumnWidth(hwndLV, 0, LVSCW_AUTOSIZE_USEHEADER);
+ }
+ return TRUE;
- case WM_GETMINMAXINFO:
- ResizeDlg_GetMinMaxInfo(hwnd, lParam);
- return TRUE;
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd, lParam);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL, IDC_RESIZEGRIP };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- SendMessage(hwndLV, WM_THEMECHANGED, 0, 0);
+ int const buttons[] = { IDOK, IDCANCEL, IDC_RESIZEGRIP };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ SendMessage(hwndLV, WM_THEMECHANGED, 0, 0);
- UpdateWindowEx(hwnd);
- }
- break;
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_NOTIFY: {
- LPNMHDR pnmh = (LPNMHDR)lParam;
+ case WM_NOTIFY: {
+ LPNMHDR pnmh = (LPNMHDR)lParam;
- if (pnmh->idFrom == IDC_OPENWITHDIR) {
- switch(pnmh->code) {
- case LVN_GETDISPINFO:
- DirList_GetDispInfo(hwndLV, lParam, Flags.NoFadeHidden);
- break;
+ if (pnmh->idFrom == IDC_OPENWITHDIR) {
+ switch(pnmh->code) {
+ case LVN_GETDISPINFO:
+ DirList_GetDispInfo(hwndLV, lParam, Flags.NoFadeHidden);
+ break;
- case LVN_DELETEITEM:
- DirList_DeleteItem(hwndLV, lParam);
- break;
+ case LVN_DELETEITEM:
+ DirList_DeleteItem(hwndLV, lParam);
+ break;
- case LVN_ITEMCHANGED: {
- NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam;
- DialogEnableControl(hwnd,IDOK,(pnmlv->uNewState & LVIS_SELECTED));
- }
- break;
+ case LVN_ITEMCHANGED: {
+ NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam;
+ DialogEnableControl(hwnd,IDOK,(pnmlv->uNewState & LVIS_SELECTED));
+ }
+ break;
- case NM_DBLCLK:
- if (ListView_GetSelectedCount(hwndLV)) {
- SendWMCommand(hwnd, IDOK);
- }
- break;
- }
- }
- }
- return TRUE;
+ case NM_DBLCLK:
+ if (ListView_GetSelectedCount(hwndLV)) {
+ SendWMCommand(hwnd, IDOK);
+ }
+ break;
+ }
+ }
+ }
+ return TRUE;
- case WM_COMMAND:
+ case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch(LOWORD(wParam)) {
- case IDC_GETOPENWITHDIR: {
- if (GetDirectory(hwnd,IDS_MUI_OPENWITH,Settings.OpenWithDir,Settings.OpenWithDir,true)) {
- DirList_Fill(hwndLV, Settings.OpenWithDir, DL_ALLOBJECTS, NULL, false, Flags.NoFadeHidden, DS_NAME, false);
- DirList_StartIconThread(hwndLV);
- ListView_EnsureVisible(hwndLV, 0, false);
- ListView_SetItemState(hwndLV, 0, LVIS_FOCUSED, LVIS_FOCUSED);
- }
- PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(hwndLV), 1);
- }
- break;
+ case IDC_GETOPENWITHDIR: {
+ if (GetDirectory(hwnd,IDS_MUI_OPENWITH,Settings.OpenWithDir,Settings.OpenWithDir,true)) {
+ DirList_Fill(hwndLV, Settings.OpenWithDir, DL_ALLOBJECTS, NULL, false, Flags.NoFadeHidden, DS_NAME, false);
+ DirList_StartIconThread(hwndLV);
+ ListView_EnsureVisible(hwndLV, 0, false);
+ ListView_SetItemState(hwndLV, 0, LVIS_FOCUSED, LVIS_FOCUSED);
+ }
+ PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(hwndLV), 1);
+ }
+ break;
- case IDOK: {
- LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER);
- lpdli->mask = DLI_FILENAME | DLI_TYPE;
- lpdli->ntype = DLE_NONE;
- DirList_GetItem(hwndLV, (-1), lpdli);
+ case IDOK: {
+ LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER);
+ lpdli->mask = DLI_FILENAME | DLI_TYPE;
+ lpdli->ntype = DLE_NONE;
+ DirList_GetItem(hwndLV, (-1), lpdli);
- if (lpdli->ntype != DLE_NONE) {
- EndDialog(hwnd,IDOK);
- } else {
- SimpleBeep();
- }
- }
- break;
+ if (lpdli->ntype != DLE_NONE) {
+ EndDialog(hwnd,IDOK);
+ } else {
+ SimpleBeep();
+ }
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd,IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
- }
- return TRUE;
+ }
+ return TRUE;
- }
- return FALSE;
+ }
+ return FALSE;
}
@@ -1718,42 +1718,42 @@ CASE_WM_CTLCOLOR_SET:
//
bool OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile)
{
- bool result = false;
+ bool result = false;
- DLITEM dliOpenWith = { 0 };
- dliOpenWith.mask = DLI_FILENAME;
+ DLITEM dliOpenWith = { 0 };
+ dliOpenWith.mask = DLI_FILENAME;
- if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer,MAKEINTRESOURCE(IDD_MUI_OPENWITH),
- hwnd,OpenWithDlgProc,(LPARAM)&dliOpenWith)) {
- WCHAR szParam[MAX_PATH] = { L'\0' };
+ if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer,MAKEINTRESOURCE(IDD_MUI_OPENWITH),
+ hwnd,OpenWithDlgProc,(LPARAM)&dliOpenWith)) {
+ WCHAR szParam[MAX_PATH] = { L'\0' };
- HPATHL pthDirectory = NULL;
- if (Path_IsNotEmpty(Paths.CurrentFile)) {
- pthDirectory = Path_Copy(Paths.CurrentFile);
- Path_RemoveFileSpec(pthDirectory);
- }
+ HPATHL pthDirectory = NULL;
+ if (Path_IsNotEmpty(Paths.CurrentFile)) {
+ pthDirectory = Path_Copy(Paths.CurrentFile);
+ Path_RemoveFileSpec(pthDirectory);
+ }
- SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
- sei.fMask = SEE_MASK_DEFAULT;
- sei.hwnd = hwnd;
- sei.lpVerb = NULL;
- sei.lpFile = dliOpenWith.szFileName;
- sei.lpParameters = szParam;
- sei.lpDirectory = Path_Get(pthDirectory);
- sei.nShow = SW_SHOWNORMAL;
+ SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
+ sei.fMask = SEE_MASK_DEFAULT;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = dliOpenWith.szFileName;
+ sei.lpParameters = szParam;
+ sei.lpDirectory = Path_Get(pthDirectory);
+ sei.nShow = SW_SHOWNORMAL;
- // resolve links and get short path name
- if (!(PathIsLnkFile(lpstrFile) && PathGetLnkPath(lpstrFile, szParam, COUNTOF(szParam)))) {
- StringCchCopy(szParam, COUNTOF(szParam), lpstrFile);
- }
- //GetShortPathName(szParam,szParam,sizeof(WCHAR)*COUNTOF(szParam));
- PathQuoteSpaces(szParam);
- result = ShellExecuteEx(&sei);
+ // resolve links and get short path name
+ if (!(PathIsLnkFile(lpstrFile) && PathGetLnkPath(lpstrFile, szParam, COUNTOF(szParam)))) {
+ StringCchCopy(szParam, COUNTOF(szParam), lpstrFile);
+ }
+ //GetShortPathName(szParam,szParam,sizeof(WCHAR)*COUNTOF(szParam));
+ PathQuoteSpaces(szParam);
+ result = ShellExecuteEx(&sei);
- Path_Release(pthDirectory);
- }
+ Path_Release(pthDirectory);
+ }
- return result;
+ return result;
}
@@ -1764,187 +1764,187 @@ bool OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile)
//
static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
- static HWND hwndLV = NULL;
+ static HWND hwndLV = NULL;
- switch(umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch(umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_GETFAVORITESDIR));
- SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_GETFAVORITESDIR));
+ SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ }
#endif
- ResizeDlg_Init(hwnd, Settings.FavoritesDlgSizeX, Settings.FavoritesDlgSizeY, IDC_RESIZEGRIP);
+ ResizeDlg_Init(hwnd, Settings.FavoritesDlgSizeX, Settings.FavoritesDlgSizeY, IDC_RESIZEGRIP);
- LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+ LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
- hwndLV = GetDlgItem(hwnd, IDC_FAVORITESDIR);
- InitWindowCommon(hwndLV, true);
- InitListView(hwndLV); // DarkMode
+ hwndLV = GetDlgItem(hwnd, IDC_FAVORITESDIR);
+ InitWindowCommon(hwndLV, true);
+ InitListView(hwndLV); // DarkMode
- ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
- ListView_InsertColumn(hwndLV,0,&lvc);
- DirList_Init(hwndLV,NULL);
- DirList_Fill(hwndLV,Settings.FavoritesDir,DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false);
- DirList_StartIconThread(hwndLV);
- ListView_SetItemState(hwndLV,0,LVIS_FOCUSED,LVIS_FOCUSED);
+ ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
+ ListView_InsertColumn(hwndLV,0,&lvc);
+ DirList_Init(hwndLV,NULL);
+ DirList_Fill(hwndLV,Settings.FavoritesDir,DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false);
+ DirList_StartIconThread(hwndLV);
+ ListView_SetItemState(hwndLV,0,LVIS_FOCUSED,LVIS_FOCUSED);
- MakeBitmapButton(hwnd,IDC_GETFAVORITESDIR,IDB_OPEN, -1, -1);
+ MakeBitmapButton(hwnd,IDC_GETFAVORITESDIR,IDB_OPEN, -1, -1);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
- case WM_DESTROY:
- DirList_Destroy(hwndLV);
- hwndLV = NULL;
- DeleteBitmapButton(hwnd,IDC_GETFAVORITESDIR);
- ResizeDlg_Destroy(hwnd,&Settings.FavoritesDlgSizeX,&Settings.FavoritesDlgSizeY);
- return FALSE;
+ case WM_DESTROY:
+ DirList_Destroy(hwndLV);
+ hwndLV = NULL;
+ DeleteBitmapButton(hwnd,IDC_GETFAVORITESDIR);
+ ResizeDlg_Destroy(hwnd,&Settings.FavoritesDlgSizeX,&Settings.FavoritesDlgSizeY);
+ return FALSE;
- case WM_SIZE: {
- int dx, dy;
- ResizeDlg_Size(hwnd,lParam,&dx,&dy);
+ case WM_SIZE: {
+ 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);
- hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDIR,dx,dy,SWP_NOMOVE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETFAVORITESDIR,0,dy,SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDESCR,0,dy,SWP_NOSIZE);
- EndDeferWindowPos(hdwp);
- ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER);
- }
- return TRUE;
+ HDWP hdwp;
+ hdwp = BeginDeferWindowPos(6);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDIR,dx,dy,SWP_NOMOVE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETFAVORITESDIR,0,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDESCR,0,dy,SWP_NOSIZE);
+ EndDeferWindowPos(hdwp);
+ ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER);
+ }
+ return TRUE;
- case WM_GETMINMAXINFO:
- ResizeDlg_GetMinMaxInfo(hwnd,lParam);
- return TRUE;
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd,lParam);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL, IDC_RESIZEGRIP };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- SendMessage(hwndLV, WM_THEMECHANGED, 0, 0);
+ int const buttons[] = { IDOK, IDCANCEL, IDC_RESIZEGRIP };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ SendMessage(hwndLV, WM_THEMECHANGED, 0, 0);
- UpdateWindowEx(hwnd);
- }
- break;
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_NOTIFY: {
- LPNMHDR pnmh = (LPNMHDR)lParam;
+ case WM_NOTIFY: {
+ LPNMHDR pnmh = (LPNMHDR)lParam;
- if (pnmh->idFrom == IDC_FAVORITESDIR) {
- switch(pnmh->code) {
- case LVN_GETDISPINFO:
- DirList_GetDispInfo(hwndLV, lParam, Flags.NoFadeHidden);
- break;
+ if (pnmh->idFrom == IDC_FAVORITESDIR) {
+ switch(pnmh->code) {
+ case LVN_GETDISPINFO:
+ DirList_GetDispInfo(hwndLV, lParam, Flags.NoFadeHidden);
+ break;
- case LVN_DELETEITEM:
- DirList_DeleteItem(hwndLV, lParam);
- break;
+ case LVN_DELETEITEM:
+ DirList_DeleteItem(hwndLV, lParam);
+ break;
- case LVN_ITEMCHANGED: {
- NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam;
- DialogEnableControl(hwnd,IDOK,(pnmlv->uNewState & LVIS_SELECTED));
- }
- break;
+ case LVN_ITEMCHANGED: {
+ NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam;
+ DialogEnableControl(hwnd,IDOK,(pnmlv->uNewState & LVIS_SELECTED));
+ }
+ break;
- case NM_DBLCLK:
- if (ListView_GetSelectedCount(GetDlgItem(hwnd, IDC_FAVORITESDIR))) {
- SendWMCommand(hwnd, IDOK);
- }
- break;
- }
- }
- }
- return TRUE;
+ case NM_DBLCLK:
+ if (ListView_GetSelectedCount(GetDlgItem(hwnd, IDC_FAVORITESDIR))) {
+ SendWMCommand(hwnd, IDOK);
+ }
+ break;
+ }
+ }
+ }
+ return TRUE;
- case WM_COMMAND:
+ case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch(LOWORD(wParam)) {
- case IDC_GETFAVORITESDIR: {
- if (GetDirectory(hwnd,IDS_MUI_FAVORITES,Settings.FavoritesDir,Settings.FavoritesDir,true)) {
- DirList_Fill(hwndLV,Settings.FavoritesDir,DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false);
- DirList_StartIconThread(hwndLV);
- ListView_EnsureVisible(hwndLV,0,false);
- ListView_SetItemState(hwndLV,0,LVIS_FOCUSED,LVIS_FOCUSED);
- }
- PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(hwndLV),1);
- }
- break;
+ case IDC_GETFAVORITESDIR: {
+ if (GetDirectory(hwnd,IDS_MUI_FAVORITES,Settings.FavoritesDir,Settings.FavoritesDir,true)) {
+ DirList_Fill(hwndLV,Settings.FavoritesDir,DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false);
+ DirList_StartIconThread(hwndLV);
+ ListView_EnsureVisible(hwndLV,0,false);
+ ListView_SetItemState(hwndLV,0,LVIS_FOCUSED,LVIS_FOCUSED);
+ }
+ PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(hwndLV),1);
+ }
+ break;
- case IDOK: {
- LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER);
- lpdli->mask = DLI_FILENAME | DLI_TYPE;
- lpdli->ntype = DLE_NONE;
- DirList_GetItem(hwndLV,(-1),lpdli);
+ case IDOK: {
+ LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER);
+ lpdli->mask = DLI_FILENAME | DLI_TYPE;
+ lpdli->ntype = DLE_NONE;
+ DirList_GetItem(hwndLV,(-1),lpdli);
- if (lpdli->ntype != DLE_NONE) {
- EndDialog(hwnd,IDOK);
- } else {
- SimpleBeep();
- }
- }
- break;
+ if (lpdli->ntype != DLE_NONE) {
+ EndDialog(hwnd,IDOK);
+ } else {
+ SimpleBeep();
+ }
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd,IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
- }
+ }
- return TRUE;
+ return TRUE;
- }
+ }
- return FALSE;
+ return FALSE;
}
@@ -1956,15 +1956,15 @@ CASE_WM_CTLCOLOR_SET:
bool FavoritesDlg(HWND hwnd,LPWSTR lpstrFile)
{
- DLITEM dliFavorite = { 0 };
- dliFavorite.mask = DLI_FILENAME;
+ DLITEM dliFavorite = { 0 };
+ dliFavorite.mask = DLI_FILENAME;
- if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer,MAKEINTRESOURCE(IDD_MUI_FAVORITES),
- hwnd,FavoritesDlgProc,(LPARAM)&dliFavorite)) {
- StringCchCopyN(lpstrFile,MAX_PATH,dliFavorite.szFileName,MAX_PATH);
- return TRUE;
- }
- return FALSE;
+ if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer,MAKEINTRESOURCE(IDD_MUI_FAVORITES),
+ hwnd,FavoritesDlgProc,(LPARAM)&dliFavorite)) {
+ StringCchCopyN(lpstrFile,MAX_PATH,dliFavorite.szFileName,MAX_PATH);
+ return TRUE;
+ }
+ return FALSE;
}
@@ -1976,114 +1976,114 @@ bool FavoritesDlg(HWND hwnd,LPWSTR lpstrFile)
//
static INT_PTR CALLBACK AddToFavDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- switch (umsg) {
+ switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_ADDFAV_FILES));
- SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_ADDFAV_FILES));
+ SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ }
#endif
- ResizeDlg_InitX(hwnd, Settings.AddToFavDlgSizeX, IDC_RESIZEGRIP);
+ ResizeDlg_InitX(hwnd, Settings.AddToFavDlgSizeX, IDC_RESIZEGRIP);
- LPCWSTR const pszName = (LPCWSTR)lParam;
- SendDlgItemMessage(hwnd, IDC_ADDFAV_FILES, EM_LIMITTEXT, MAX_PATH - 1, 0);
- SetDlgItemText(hwnd, IDC_ADDFAV_FILES, pszName);
+ LPCWSTR const pszName = (LPCWSTR)lParam;
+ SendDlgItemMessage(hwnd, IDC_ADDFAV_FILES, EM_LIMITTEXT, MAX_PATH - 1, 0);
+ SetDlgItemText(hwnd, IDC_ADDFAV_FILES, pszName);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DESTROY:
- ResizeDlg_Destroy(hwnd, &Settings.AddToFavDlgSizeX, NULL);
- return FALSE;
+ case WM_DESTROY:
+ ResizeDlg_Destroy(hwnd, &Settings.AddToFavDlgSizeX, NULL);
+ return FALSE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- break;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ break;
- case WM_SIZE: {
- int dx;
- ResizeDlg_Size(hwnd, lParam, &dx, NULL);
- HDWP hdwp = BeginDeferWindowPos(5);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP, dx, 0, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDOK, dx, 0, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDCANCEL, dx, 0, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_FAVORITESDESCR, dx, 0, SWP_NOMOVE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_ADDFAV_FILES, dx, 0, SWP_NOMOVE);
- EndDeferWindowPos(hdwp);
- InvalidateRect(GetDlgItem(hwnd, IDC_FAVORITESDESCR), NULL, TRUE);
- }
- return TRUE;
+ case WM_SIZE: {
+ int dx;
+ ResizeDlg_Size(hwnd, lParam, &dx, NULL);
+ HDWP hdwp = BeginDeferWindowPos(5);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP, dx, 0, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDOK, dx, 0, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDCANCEL, dx, 0, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_FAVORITESDESCR, dx, 0, SWP_NOMOVE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_ADDFAV_FILES, dx, 0, SWP_NOMOVE);
+ EndDeferWindowPos(hdwp);
+ InvalidateRect(GetDlgItem(hwnd, IDC_FAVORITESDESCR), NULL, TRUE);
+ }
+ return TRUE;
- case WM_GETMINMAXINFO:
- ResizeDlg_GetMinMaxInfo(hwnd, lParam);
- return TRUE;
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd, lParam);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL, IDC_RESIZEGRIP };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL, IDC_RESIZEGRIP };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_ADDFAV_FILES:
- DialogEnableControl(hwnd, IDOK, GetWindowTextLength(GetDlgItem(hwnd, IDC_ADDFAV_FILES)));
- break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_ADDFAV_FILES:
+ DialogEnableControl(hwnd, IDOK, GetWindowTextLength(GetDlgItem(hwnd, IDC_ADDFAV_FILES)));
+ break;
- case IDOK: {
- LPWSTR pszName = (LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER);
- GetDlgItemText(hwnd, IDC_ADDFAV_FILES, pszName, MAX_PATH - 1);
- EndDialog(hwnd, IDOK);
- }
- break;
+ case IDOK: {
+ LPWSTR pszName = (LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER);
+ GetDlgItemText(hwnd, IDC_ADDFAV_FILES, pszName, MAX_PATH - 1);
+ EndDialog(hwnd, IDOK);
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
- break;
- }
- return TRUE;
- }
- return FALSE;
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -2094,26 +2094,26 @@ CASE_WM_CTLCOLOR_SET:
bool AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget)
{
- INT_PTR iResult;
+ INT_PTR iResult;
- WCHAR pszName[MAX_PATH] = { L'\0' };
- StringCchCopy(pszName,COUNTOF(pszName),lpszName);
+ WCHAR pszName[MAX_PATH] = { L'\0' };
+ StringCchCopy(pszName,COUNTOF(pszName),lpszName);
- iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCE(IDD_MUI_ADDTOFAV),
- hwnd,
- AddToFavDlgProc,(LPARAM)pszName);
+ iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCE(IDD_MUI_ADDTOFAV),
+ hwnd,
+ AddToFavDlgProc,(LPARAM)pszName);
- if (iResult == IDOK) {
- if (!PathCreateFavLnk(pszName,lpszTarget,Settings.FavoritesDir)) {
- InfoBoxLng(MB_ICONWARNING,NULL,IDS_MUI_FAV_FAILURE);
- return FALSE;
- }
- InfoBoxLng(MB_ICONINFORMATION, NULL, IDS_MUI_FAV_SUCCESS);
- return TRUE;
- }
- return FALSE;
+ if (iResult == IDOK) {
+ if (!PathCreateFavLnk(pszName,lpszTarget,Settings.FavoritesDir)) {
+ InfoBoxLng(MB_ICONWARNING,NULL,IDS_MUI_FAV_FAILURE);
+ return FALSE;
+ }
+ InfoBoxLng(MB_ICONINFORMATION, NULL, IDS_MUI_FAV_SUCCESS);
+ return TRUE;
+ }
+ return FALSE;
}
@@ -2123,486 +2123,486 @@ bool AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget)
//
//
typedef struct tagIconThreadInfo {
- HWND hwnd; // HWND of ListView Control
- HANDLE hThread; // Thread Handle
- HANDLE hExitThread; // Flag is set when Icon Thread should terminate
- HANDLE hTerminatedThread; // Flag is set when Icon Thread has terminated
+ HWND hwnd; // HWND of ListView Control
+ HANDLE hThread; // Thread Handle
+ HANDLE hExitThread; // Flag is set when Icon Thread should terminate
+ HANDLE hTerminatedThread; // Flag is set when Icon Thread has terminated
} ICONTHREADINFO, *LPICONTHREADINFO;
DWORD WINAPI FileMRUIconThread(LPVOID lpParam)
{
- BackgroundWorker *worker = (BackgroundWorker *)lpParam;
+ BackgroundWorker *worker = (BackgroundWorker *)lpParam;
- (void)CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY);
+ (void)CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY);
- WCHAR tch[MAX_PATH] = { L'\0' };
- DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
+ WCHAR tch[MAX_PATH] = { L'\0' };
+ DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
- HWND hwnd = worker->hwnd;
- int iMaxItem = ListView_GetItemCount(hwnd);
+ HWND hwnd = worker->hwnd;
+ int iMaxItem = ListView_GetItemCount(hwnd);
- int iItem = 0;
- while (iItem < iMaxItem && BackgroundWorker_Continue(worker)) {
+ int iItem = 0;
+ while (iItem < iMaxItem && BackgroundWorker_Continue(worker)) {
- LV_ITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT;
- lvi.pszText = tch;
- lvi.cchTextMax = COUNTOF(tch);
- lvi.iItem = iItem;
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT;
+ lvi.pszText = tch;
+ lvi.cchTextMax = COUNTOF(tch);
+ lvi.iItem = iItem;
- SHFILEINFO shfi = { 0 };
+ SHFILEINFO shfi = { 0 };
- if (ListView_GetItem(hwnd,&lvi)) {
- DWORD dwAttr = 0;
- if (PathIsUNC(tch) || !PathIsExistingFile(tch)) {
- dwFlags |= SHGFI_USEFILEATTRIBUTES;
- dwAttr = FILE_ATTRIBUTE_NORMAL;
- shfi.dwAttributes = 0;
- SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
- } else {
- shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
- SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
- }
+ if (ListView_GetItem(hwnd,&lvi)) {
+ DWORD dwAttr = 0;
+ if (PathIsUNC(tch) || !PathIsExistingFile(tch)) {
+ dwFlags |= SHGFI_USEFILEATTRIBUTES;
+ dwAttr = FILE_ATTRIBUTE_NORMAL;
+ shfi.dwAttributes = 0;
+ SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
+ } else {
+ shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
+ SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
+ }
- lvi.mask = LVIF_IMAGE;
- lvi.iImage = shfi.iIcon;
- lvi.stateMask = 0;
- lvi.state = 0;
+ lvi.mask = LVIF_IMAGE;
+ lvi.iImage = shfi.iIcon;
+ lvi.stateMask = 0;
+ lvi.state = 0;
- if (shfi.dwAttributes & SFGAO_LINK) {
- lvi.mask |= LVIF_STATE;
- lvi.stateMask |= LVIS_OVERLAYMASK;
- lvi.state |= INDEXTOOVERLAYMASK(2);
- }
+ if (shfi.dwAttributes & SFGAO_LINK) {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_OVERLAYMASK;
+ lvi.state |= INDEXTOOVERLAYMASK(2);
+ }
- if (shfi.dwAttributes & SFGAO_SHARE) {
- lvi.mask |= LVIF_STATE;
- lvi.stateMask |= LVIS_OVERLAYMASK;
- lvi.state |= INDEXTOOVERLAYMASK(1);
- }
+ if (shfi.dwAttributes & SFGAO_SHARE) {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_OVERLAYMASK;
+ lvi.state |= INDEXTOOVERLAYMASK(1);
+ }
- if (PathIsUNC(tch)) {
- dwAttr = FILE_ATTRIBUTE_NORMAL;
- } else {
- dwAttr = GetFileAttributes(tch);
- }
+ if (PathIsUNC(tch)) {
+ dwAttr = FILE_ATTRIBUTE_NORMAL;
+ } else {
+ dwAttr = GetFileAttributes(tch);
+ }
- if (!Flags.NoFadeHidden &&
- dwAttr != INVALID_FILE_ATTRIBUTES &&
- dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
- lvi.mask |= LVIF_STATE;
- lvi.stateMask |= LVIS_CUT;
- lvi.state |= LVIS_CUT;
- }
+ if (!Flags.NoFadeHidden &&
+ dwAttr != INVALID_FILE_ATTRIBUTES &&
+ dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
+ lvi.mask |= LVIF_STATE;
+ lvi.stateMask |= LVIS_CUT;
+ lvi.state |= LVIS_CUT;
+ }
- lvi.iSubItem = 0;
- ListView_SetItem(hwnd,&lvi);
- }
- iItem++;
- }
+ lvi.iSubItem = 0;
+ ListView_SetItem(hwnd,&lvi);
+ }
+ iItem++;
+ }
- CoUninitialize();
- return 0;
+ CoUninitialize();
+ return 0;
}
#define IDC_FILEMRU_UPDATE_VIEW (WM_USER+1)
static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- static HWND hwndLV = NULL;
+ static HWND hwndLV = NULL;
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- SetExplorerTheme(GetDlgItem(hwnd, IDC_REMOVE));
- SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { IDC_SAVEMRU, IDC_PRESERVECARET, IDC_REMEMBERSEARCHPATTERN, IDC_STATIC };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ SetExplorerTheme(GetDlgItem(hwnd, IDC_REMOVE));
+ SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { IDC_SAVEMRU, IDC_PRESERVECARET, IDC_REMEMBERSEARCHPATTERN, IDC_STATIC };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
+ }
#endif
- // sync with other instances
- if (Settings.SaveRecentFiles && Globals.bCanSaveIniFile) {
- if (MRU_MergeSave(Globals.pFileMRU, true, Flags.RelativeFileMRU, Flags.PortableMyDocs)) {
- MRU_Load(Globals.pFileMRU, true);
- }
- }
+ // sync with other instances
+ if (Settings.SaveRecentFiles && Globals.bCanSaveIniFile) {
+ if (MRU_MergeSave(Globals.pFileMRU, true, Flags.RelativeFileMRU, Flags.PortableMyDocs)) {
+ MRU_Load(Globals.pFileMRU, true);
+ }
+ }
- hwndLV = GetDlgItem(hwnd, IDC_FILEMRU);
- InitWindowCommon(hwndLV, true);
- InitListView(hwndLV); // DarkMode
+ hwndLV = GetDlgItem(hwnd, IDC_FILEMRU);
+ InitWindowCommon(hwndLV, true);
+ InitListView(hwndLV); // DarkMode
BackgroundWorker *worker = (BackgroundWorker *)GlobalAlloc(GPTR, sizeof(BackgroundWorker));
- SetProp(hwnd, L"it", (HANDLE)worker);
- BackgroundWorker_Init(worker, hwndLV);
+ SetProp(hwnd, L"it", (HANDLE)worker);
+ BackgroundWorker_Init(worker, hwndLV);
- ResizeDlg_Init(hwnd, Settings.FileMRUDlgSizeX, Settings.FileMRUDlgSizeY, IDC_RESIZEGRIP);
+ ResizeDlg_Init(hwnd, Settings.FileMRUDlgSizeX, Settings.FileMRUDlgSizeY, IDC_RESIZEGRIP);
- SHFILEINFO shfi = { 0 };
- LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+ SHFILEINFO shfi = { 0 };
+ LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
- ListView_SetImageList(hwndLV,
- (HIMAGELIST)SHGetFileInfo(L"C:\\", FILE_ATTRIBUTE_DIRECTORY,
- &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_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),
- LVSIL_NORMAL);
+ ListView_SetImageList(hwndLV,
+ (HIMAGELIST)SHGetFileInfo(L"C:\\", FILE_ATTRIBUTE_DIRECTORY,
+ &shfi, sizeof(SHFILEINFO), SHGFI_LARGEICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES),
+ LVSIL_NORMAL);
- ListView_SetExtendedListViewStyle(hwndLV, /*LVS_EX_FULLROWSELECT|*/ LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
- ListView_InsertColumn(hwndLV, 0, &lvc);
+ ListView_SetExtendedListViewStyle(hwndLV, /*LVS_EX_FULLROWSELECT|*/ LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
+ ListView_InsertColumn(hwndLV, 0, &lvc);
- // Update view
- SendWMCommand(hwnd, IDC_FILEMRU_UPDATE_VIEW);
+ // Update view
+ SendWMCommand(hwnd, IDC_FILEMRU_UPDATE_VIEW);
- CheckDlgButton(hwnd, IDC_SAVEMRU, SetBtn(Settings.SaveRecentFiles));
- CheckDlgButton(hwnd, IDC_PRESERVECARET, SetBtn(Settings.PreserveCaretPos));
- CheckDlgButton(hwnd, IDC_REMEMBERSEARCHPATTERN, SetBtn(Settings.SaveFindReplace));
+ CheckDlgButton(hwnd, IDC_SAVEMRU, SetBtn(Settings.SaveRecentFiles));
+ CheckDlgButton(hwnd, IDC_PRESERVECARET, SetBtn(Settings.PreserveCaretPos));
+ CheckDlgButton(hwnd, IDC_REMEMBERSEARCHPATTERN, SetBtn(Settings.SaveFindReplace));
- DialogEnableControl(hwnd, IDC_PRESERVECARET, Settings.SaveRecentFiles);
+ DialogEnableControl(hwnd, IDC_PRESERVECARET, Settings.SaveRecentFiles);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DESTROY: {
- BackgroundWorker *worker = (BackgroundWorker *)GetProp(hwnd, L"it");
- BackgroundWorker_Destroy(worker);
- RemoveProp(hwnd, L"it");
- GlobalFree(worker);
+ case WM_DESTROY: {
+ BackgroundWorker *worker = (BackgroundWorker *)GetProp(hwnd, L"it");
+ BackgroundWorker_Destroy(worker);
+ RemoveProp(hwnd, L"it");
+ GlobalFree(worker);
- if (Settings.SaveRecentFiles) {
- MRU_Save(Globals.pFileMRU); // last instance on save wins
- }
+ if (Settings.SaveRecentFiles) {
+ MRU_Save(Globals.pFileMRU); // last instance on save wins
+ }
- Settings.SaveRecentFiles = IsButtonChecked(hwnd, IDC_SAVEMRU);
- Settings.SaveFindReplace = IsButtonChecked(hwnd, IDC_REMEMBERSEARCHPATTERN);
- Settings.PreserveCaretPos = IsButtonChecked(hwnd, IDC_PRESERVECARET);
+ Settings.SaveRecentFiles = IsButtonChecked(hwnd, IDC_SAVEMRU);
+ Settings.SaveFindReplace = IsButtonChecked(hwnd, IDC_REMEMBERSEARCHPATTERN);
+ Settings.PreserveCaretPos = IsButtonChecked(hwnd, IDC_PRESERVECARET);
- ResizeDlg_Destroy(hwnd, &Settings.FileMRUDlgSizeX, &Settings.FileMRUDlgSizeY);
- }
- return FALSE;
+ ResizeDlg_Destroy(hwnd, &Settings.FileMRUDlgSizeX, &Settings.FileMRUDlgSizeY);
+ }
+ return FALSE;
- case WM_SIZE: {
- int dx, dy;
- ResizeDlg_Size(hwnd, lParam, &dx, &dy);
- HDWP hdwp = BeginDeferWindowPos(8);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP, dx, dy, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDOK, dx, dy, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDCANCEL, dx, dy, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_REMOVE, dx, dy, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_FILEMRU, dx, dy, SWP_NOMOVE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_SAVEMRU, 0, dy, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_PRESERVECARET, 0, dy, SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp, hwnd, IDC_REMEMBERSEARCHPATTERN, 0, dy, SWP_NOSIZE);
- EndDeferWindowPos(hdwp);
- ListView_SetColumnWidth(hwndLV, 0, LVSCW_AUTOSIZE_USEHEADER);
- }
- return TRUE;
+ case WM_SIZE: {
+ int dx, dy;
+ ResizeDlg_Size(hwnd, lParam, &dx, &dy);
+ HDWP hdwp = BeginDeferWindowPos(8);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP, dx, dy, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDOK, dx, dy, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDCANCEL, dx, dy, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_REMOVE, dx, dy, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_FILEMRU, dx, dy, SWP_NOMOVE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_SAVEMRU, 0, dy, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_PRESERVECARET, 0, dy, SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp, hwnd, IDC_REMEMBERSEARCHPATTERN, 0, dy, SWP_NOSIZE);
+ EndDeferWindowPos(hdwp);
+ ListView_SetColumnWidth(hwndLV, 0, LVSCW_AUTOSIZE_USEHEADER);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT *)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT *)lParam, 0);
+ return TRUE;
- case WM_GETMINMAXINFO:
- ResizeDlg_GetMinMaxInfo(hwnd, lParam);
- return TRUE;
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd, lParam);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL, IDC_REMOVE, IDC_RESIZEGRIP };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- SendMessage(hwndLV, WM_THEMECHANGED, 0, 0);
+ int const buttons[] = { IDOK, IDCANCEL, IDC_REMOVE, IDC_RESIZEGRIP };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ SendMessage(hwndLV, WM_THEMECHANGED, 0, 0);
- UpdateWindowEx(hwnd);
- }
- break;
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_NOTIFY: {
- switch (wParam) {
- case IDC_REMOVE:
- switch (((LPNMHDR)lParam)->code) {
- case BCN_DROPDOWN: {
- const NMBCDROPDOWN* pDropDown = (NMBCDROPDOWN*)lParam;
- // Get screen coordinates of the button.
- POINT pt = { 0, 0 };
- pt.x = pDropDown->rcButton.left;
- pt.y = pDropDown->rcButton.bottom;
- ClientToScreen(pDropDown->hdr.hwndFrom, &pt);
- // Create a menu and add items.
- HMENU hSplitMenu = CreatePopupMenu();
- if (!hSplitMenu) {
- break;
- }
- if (pDropDown->hdr.hwndFrom == GetDlgItem(hwnd, IDC_REMOVE)) {
- WCHAR szMenu[80] = {L'\0'};
- GetLngString(IDS_CLEAR_ALL, szMenu, COUNTOF(szMenu));
- AppendMenu(hSplitMenu, MF_STRING, IDC_CLEAR_LIST, szMenu);
- }
+ case WM_NOTIFY: {
+ switch (wParam) {
+ case IDC_REMOVE:
+ switch (((LPNMHDR)lParam)->code) {
+ case BCN_DROPDOWN: {
+ const NMBCDROPDOWN* pDropDown = (NMBCDROPDOWN*)lParam;
+ // Get screen coordinates of the button.
+ POINT pt = { 0, 0 };
+ pt.x = pDropDown->rcButton.left;
+ pt.y = pDropDown->rcButton.bottom;
+ ClientToScreen(pDropDown->hdr.hwndFrom, &pt);
+ // Create a menu and add items.
+ HMENU hSplitMenu = CreatePopupMenu();
+ if (!hSplitMenu) {
+ break;
+ }
+ if (pDropDown->hdr.hwndFrom == GetDlgItem(hwnd, IDC_REMOVE)) {
+ WCHAR szMenu[80] = {L'\0'};
+ GetLngString(IDS_CLEAR_ALL, szMenu, COUNTOF(szMenu));
+ AppendMenu(hSplitMenu, MF_STRING, IDC_CLEAR_LIST, szMenu);
+ }
- // Display the menu.
- TrackPopupMenu(hSplitMenu, TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, 0, hwnd, NULL);
- DestroyMenu(hSplitMenu);
- return TRUE;
- }
- break;
+ // Display the menu.
+ TrackPopupMenu(hSplitMenu, TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, 0, hwnd, NULL);
+ DestroyMenu(hSplitMenu);
+ return TRUE;
+ }
+ break;
- default:
- break;
- }
- break;
+ default:
+ break;
+ }
+ break;
- case IDC_FILEMRU:
- if (((LPNMHDR)(lParam))->idFrom == IDC_FILEMRU) {
- switch (((LPNMHDR)(lParam))->code) {
- case NM_DBLCLK:
- SendWMCommand(hwnd, IDOK);
- break;
+ case IDC_FILEMRU:
+ if (((LPNMHDR)(lParam))->idFrom == IDC_FILEMRU) {
+ switch (((LPNMHDR)(lParam))->code) {
+ case NM_DBLCLK:
+ SendWMCommand(hwnd, IDOK);
+ break;
- case LVN_GETDISPINFO: {
- /*
- LV_DISPINFO *lpdi = (LPVOID)lParam;
+ case LVN_GETDISPINFO: {
+ /*
+ LV_DISPINFO *lpdi = (LPVOID)lParam;
- if (lpdi->item.mask & LVIF_IMAGE) {
+ if (lpdi->item.mask & LVIF_IMAGE) {
- WCHAR tch[MAX_PATH] = { L'\0' };
- LV_ITEM lvi = { 0 };
- SHFILEINFO shfi = { 0 };
- DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
- DWORD dwAttr = 0;
+ WCHAR tch[MAX_PATH] = { L'\0' };
+ LV_ITEM lvi = { 0 };
+ SHFILEINFO shfi = { 0 };
+ DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED;
+ DWORD dwAttr = 0;
- lvi.mask = LVIF_TEXT;
- lvi.pszText = tch;
- lvi.cchTextMax = COUNTOF(tch);
- lvi.iItem = lpdi->item.iItem;
+ lvi.mask = LVIF_TEXT;
+ lvi.pszText = tch;
+ lvi.cchTextMax = COUNTOF(tch);
+ lvi.iItem = lpdi->item.iItem;
- ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi);
+ ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi);
- if (!PathIsExistingFile(tch)) {
- dwFlags |= SHGFI_USEFILEATTRIBUTES;
- dwAttr = FILE_ATTRIBUTE_NORMAL;
- shfi.dwAttributes = 0;
- SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
- }
+ if (!PathIsExistingFile(tch)) {
+ dwFlags |= SHGFI_USEFILEATTRIBUTES;
+ dwAttr = FILE_ATTRIBUTE_NORMAL;
+ shfi.dwAttributes = 0;
+ SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
+ }
- else {
- shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
- SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
- }
+ else {
+ shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE;
+ SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags);
+ }
- lpdi->item.iImage = shfi.iIcon;
- lpdi->item.mask |= LVIF_DI_SETITEM;
+ lpdi->item.iImage = shfi.iIcon;
+ lpdi->item.mask |= LVIF_DI_SETITEM;
- lpdi->item.stateMask = 0;
- lpdi->item.state = 0;
+ lpdi->item.stateMask = 0;
+ lpdi->item.state = 0;
- if (shfi.dwAttributes & SFGAO_LINK) {
- lpdi->item.mask |= LVIF_STATE;
- lpdi->item.stateMask |= LVIS_OVERLAYMASK;
- lpdi->item.state |= INDEXTOOVERLAYMASK(2);
- }
+ if (shfi.dwAttributes & SFGAO_LINK) {
+ lpdi->item.mask |= LVIF_STATE;
+ lpdi->item.stateMask |= LVIS_OVERLAYMASK;
+ lpdi->item.state |= INDEXTOOVERLAYMASK(2);
+ }
- if (shfi.dwAttributes & SFGAO_SHARE) {
- lpdi->item.mask |= LVIF_STATE;
- lpdi->item.stateMask |= LVIS_OVERLAYMASK;
- lpdi->item.state |= INDEXTOOVERLAYMASK(1);
- }
+ if (shfi.dwAttributes & SFGAO_SHARE) {
+ lpdi->item.mask |= LVIF_STATE;
+ lpdi->item.stateMask |= LVIS_OVERLAYMASK;
+ lpdi->item.state |= INDEXTOOVERLAYMASK(1);
+ }
- dwAttr = GetFileAttributes(tch);
+ dwAttr = GetFileAttributes(tch);
- if (!Flags.NoFadeHidden &&
- dwAttr != INVALID_FILE_ATTRIBUTES &&
- dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
- lpdi->item.mask |= LVIF_STATE;
- lpdi->item.stateMask |= LVIS_CUT;
- lpdi->item.state |= LVIS_CUT;
- }
- }
- */
- }
- break;
+ if (!Flags.NoFadeHidden &&
+ dwAttr != INVALID_FILE_ATTRIBUTES &&
+ dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
+ lpdi->item.mask |= LVIF_STATE;
+ lpdi->item.stateMask |= LVIS_CUT;
+ lpdi->item.state |= LVIS_CUT;
+ }
+ }
+ */
+ }
+ break;
- case LVN_ITEMCHANGED:
- case LVN_DELETEITEM: {
- UINT const cnt = ListView_GetSelectedCount(hwndLV);
- DialogEnableControl(hwnd, IDOK, (cnt > 0));
- // can't discard current file (its myself)
- int cur = 0;
- if (!MRU_FindPath(Globals.pFileMRU, Paths.CurrentFile, &cur)) {
- cur = -1;
- }
- int const item = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
- DialogEnableControl(hwnd, IDC_REMOVE, (cnt > 0) && (cur != item));
- }
- break;
- }
- }
- break;
+ case LVN_ITEMCHANGED:
+ case LVN_DELETEITEM: {
+ UINT const cnt = ListView_GetSelectedCount(hwndLV);
+ DialogEnableControl(hwnd, IDOK, (cnt > 0));
+ // can't discard current file (its myself)
+ int cur = 0;
+ if (!MRU_FindPath(Globals.pFileMRU, Paths.CurrentFile, &cur)) {
+ cur = -1;
+ }
+ int const item = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
+ DialogEnableControl(hwnd, IDC_REMOVE, (cnt > 0) && (cur != item));
+ }
+ break;
+ }
+ }
+ break;
- default:
- break;
- }
- }
- return TRUE;
+ default:
+ break;
+ }
+ }
+ return TRUE;
- case WM_COMMAND:
+ case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_FILEMRU_UPDATE_VIEW: {
+ switch (LOWORD(wParam)) {
+ case IDC_FILEMRU_UPDATE_VIEW: {
BackgroundWorker *worker = (BackgroundWorker *)GetProp(hwnd, L"it");
- BackgroundWorker_Cancel(worker);
+ BackgroundWorker_Cancel(worker);
- ListView_DeleteAllItems(hwndLV);
+ ListView_DeleteAllItems(hwndLV);
- LV_ITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT | LVIF_IMAGE;
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE;
- SHFILEINFO shfi = { 0 };
- SHGetFileInfo(L"Icon", FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO),
- SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES);
- lvi.iImage = shfi.iIcon;
+ SHFILEINFO shfi = { 0 };
+ SHGetFileInfo(L"Icon", FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO),
+ SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES);
+ lvi.iImage = shfi.iIcon;
- WCHAR tch[MAX_PATH] = { L'\0' };
- for (int i = 0; i < MRU_Count(Globals.pFileMRU); i++) {
- MRU_Enum(Globals.pFileMRU, i, tch, COUNTOF(tch));
- // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_ADDSTRING,0,(LPARAM)tch); }
- // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_SETCARETINDEX,0,false);
- lvi.iItem = i;
- lvi.pszText = tch;
- ListView_InsertItem(hwndLV, &lvi);
- }
+ WCHAR tch[MAX_PATH] = { L'\0' };
+ for (int i = 0; i < MRU_Count(Globals.pFileMRU); i++) {
+ MRU_Enum(Globals.pFileMRU, i, tch, COUNTOF(tch));
+ // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_ADDSTRING,0,(LPARAM)tch); }
+ // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_SETCARETINDEX,0,false);
+ lvi.iItem = i;
+ lvi.pszText = tch;
+ ListView_InsertItem(hwndLV, &lvi);
+ }
- UINT const cnt = ListView_GetItemCount(hwndLV);
- if (cnt > 0) {
- UINT idx = ListView_GetTopIndex(hwndLV);
- ListView_SetColumnWidth(hwndLV, idx, LVSCW_AUTOSIZE_USEHEADER);
- ListView_SetItemState(hwndLV, ((cnt > 1) ? idx + 1 : idx), LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
- //int cur = 0;
- //if (!MRU_FindPath(Globals.pFileMRU, Paths.CurrentFile, &cur)) { cur = -1; }
- //int const item = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
- //if ((cur == item) && (cnt > 1)) {
- // ListView_SetItemState(hwndLV, idx + 1, LVIS_SELECTED, LVIS_SELECTED);
- //}
- }
- DialogEnableControl(hwnd, IDOK, (cnt > 0));
- DialogEnableControl(hwnd, IDC_REMOVE, (cnt > 0));
+ UINT const cnt = ListView_GetItemCount(hwndLV);
+ if (cnt > 0) {
+ UINT idx = ListView_GetTopIndex(hwndLV);
+ ListView_SetColumnWidth(hwndLV, idx, LVSCW_AUTOSIZE_USEHEADER);
+ ListView_SetItemState(hwndLV, ((cnt > 1) ? idx + 1 : idx), LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
+ //int cur = 0;
+ //if (!MRU_FindPath(Globals.pFileMRU, Paths.CurrentFile, &cur)) { cur = -1; }
+ //int const item = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
+ //if ((cur == item) && (cnt > 1)) {
+ // ListView_SetItemState(hwndLV, idx + 1, LVIS_SELECTED, LVIS_SELECTED);
+ //}
+ }
+ DialogEnableControl(hwnd, IDOK, (cnt > 0));
+ DialogEnableControl(hwnd, IDC_REMOVE, (cnt > 0));
- worker->workerThread = CreateThread(NULL, 0, FileMRUIconThread, (LPVOID)worker, 0, NULL);
- }
- break;
+ worker->workerThread = CreateThread(NULL, 0, FileMRUIconThread, (LPVOID)worker, 0, NULL);
+ }
+ break;
- case IDC_FILEMRU:
- break;
+ case IDC_FILEMRU:
+ break;
- case IDC_SAVEMRU: {
- bool const bSaveMRU = IsButtonChecked(hwnd, IDC_SAVEMRU);
- DialogEnableControl(hwnd, IDC_PRESERVECARET, bSaveMRU);
- }
- break;
+ case IDC_SAVEMRU: {
+ bool const bSaveMRU = IsButtonChecked(hwnd, IDC_SAVEMRU);
+ DialogEnableControl(hwnd, IDC_PRESERVECARET, bSaveMRU);
+ }
+ break;
- case IDOK:
- case IDC_REMOVE: {
- WCHAR tchFileName[MAX_PATH] = {L'\0'};
+ case IDOK:
+ case IDC_REMOVE: {
+ WCHAR tchFileName[MAX_PATH] = {L'\0'};
- if (ListView_GetSelectedCount(hwndLV)) {
+ if (ListView_GetSelectedCount(hwndLV)) {
- LV_ITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT;
- lvi.pszText = tchFileName;
- lvi.cchTextMax = COUNTOF(tchFileName);
- lvi.iItem = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT;
+ lvi.pszText = tchFileName;
+ lvi.cchTextMax = COUNTOF(tchFileName);
+ lvi.iItem = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
- ListView_GetItem(hwndLV, &lvi);
+ ListView_GetItem(hwndLV, &lvi);
- PathUnquoteSpaces(tchFileName);
- PathAbsoluteFromApp(tchFileName, COUNTOF(tchFileName), true);
+ PathUnquoteSpaces(tchFileName);
+ PathAbsoluteFromApp(tchFileName, COUNTOF(tchFileName), true);
- if (!PathIsExistingFile(tchFileName) || (LOWORD(wParam) == IDC_REMOVE)) {
- // don't remove myself
- int iCur = 0;
- if (!MRU_FindPath(Globals.pFileMRU, Paths.CurrentFile, &iCur)) {
- iCur = -1;
- }
+ if (!PathIsExistingFile(tchFileName) || (LOWORD(wParam) == IDC_REMOVE)) {
+ // don't remove myself
+ int iCur = 0;
+ if (!MRU_FindPath(Globals.pFileMRU, Paths.CurrentFile, &iCur)) {
+ iCur = -1;
+ }
- // Ask...
- WORD const answer = (LOWORD(wParam) == IDOK) ? INFOBOX_ANSW(InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_ERR_MRUDLG))
- : ((iCur == lvi.iItem) ? IDNO : IDYES);
+ // Ask...
+ WORD const answer = (LOWORD(wParam) == IDOK) ? INFOBOX_ANSW(InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_ERR_MRUDLG))
+ : ((iCur == lvi.iItem) ? IDNO : IDYES);
- if ((IDOK == answer) || (IDYES == answer)) {
- MRU_Delete(Globals.pFileMRU, lvi.iItem);
- //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_DELETESTRING,(WPARAM)iItem,0);
- //ListView_DeleteItem(GetDlgItem(hwnd,IDC_FILEMRU),lvi.iItem);
- //DialogEnableWindow(hwnd,IDOK,
- // (LB_ERR != SendDlgItemMessage(hwnd,IDC_GOTO,LB_GETCURSEL,0,0)));
- }
- } else { // file to load
- StringCchCopy((LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER), MAX_PATH, tchFileName);
- EndDialog(hwnd, IDOK);
- }
+ if ((IDOK == answer) || (IDYES == answer)) {
+ MRU_Delete(Globals.pFileMRU, lvi.iItem);
+ //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_DELETESTRING,(WPARAM)iItem,0);
+ //ListView_DeleteItem(GetDlgItem(hwnd,IDC_FILEMRU),lvi.iItem);
+ //DialogEnableWindow(hwnd,IDOK,
+ // (LB_ERR != SendDlgItemMessage(hwnd,IDC_GOTO,LB_GETCURSEL,0,0)));
+ }
+ } else { // file to load
+ StringCchCopy((LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER), MAX_PATH, tchFileName);
+ EndDialog(hwnd, IDOK);
+ }
- // must use IDM_VIEW_REFRESH, index might change...
- SendWMCommand(hwnd, IDC_FILEMRU_UPDATE_VIEW);
- }
+ // must use IDM_VIEW_REFRESH, index might change...
+ SendWMCommand(hwnd, IDC_FILEMRU_UPDATE_VIEW);
+ }
- if (Settings.SaveRecentFiles && Globals.bCanSaveIniFile) {
- MRU_MergeSave(Globals.pFileMRU, true, Flags.RelativeFileMRU, Flags.PortableMyDocs);
- }
+ if (Settings.SaveRecentFiles && Globals.bCanSaveIniFile) {
+ MRU_MergeSave(Globals.pFileMRU, true, Flags.RelativeFileMRU, Flags.PortableMyDocs);
+ }
- }
- break;
+ }
+ break;
- case IDC_CLEAR_LIST:
- ListView_DeleteAllItems(hwndLV);
- MRU_Empty(Globals.pFileMRU, Path_IsNotEmpty(Paths.CurrentFile));
- if (Globals.bCanSaveIniFile) {
- MRU_Save(Globals.pFileMRU);
- }
- SendWMCommand(hwnd, IDC_FILEMRU_UPDATE_VIEW);
- break;
+ case IDC_CLEAR_LIST:
+ ListView_DeleteAllItems(hwndLV);
+ MRU_Empty(Globals.pFileMRU, Path_IsNotEmpty(Paths.CurrentFile));
+ if (Globals.bCanSaveIniFile) {
+ MRU_Save(Globals.pFileMRU);
+ }
+ SendWMCommand(hwnd, IDC_FILEMRU_UPDATE_VIEW);
+ break;
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
- break;
- }
- return TRUE;
- }
- return FALSE;
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -2613,11 +2613,11 @@ CASE_WM_CTLCOLOR_SET:
//
bool FileMRUDlg(HWND hwnd,LPWSTR lpstrFile)
{
- if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_FILEMRU),
- hwnd, FileMRUDlgProc, (LPARAM)lpstrFile)) {
- return TRUE;
- }
- return FALSE;
+ if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_FILEMRU),
+ hwnd, FileMRUDlgProc, (LPARAM)lpstrFile)) {
+ return TRUE;
+ }
+ return FALSE;
}
@@ -2636,155 +2636,155 @@ bool FileMRUDlg(HWND hwnd,LPWSTR lpstrFile)
static INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- static FILE_WATCHING_MODE s_FWM = FWM_NO_INIT;
+ static FILE_WATCHING_MODE s_FWM = FWM_NO_INIT;
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { IDC_RADIO_BTN_A, IDC_RADIO_BTN_B, IDC_RADIO_BTN_C, IDC_RADIO_BTN_D, IDC_RADIO_BTN_E, IDC_CHECK_BOX_A, IDC_CHECK_BOX_B, -1 };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { IDC_RADIO_BTN_A, IDC_RADIO_BTN_B, IDC_RADIO_BTN_C, IDC_RADIO_BTN_D, IDC_RADIO_BTN_E, IDC_CHECK_BOX_A, IDC_CHECK_BOX_B, -1 };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
+ }
#endif
- if (s_FWM == FWM_NO_INIT) {
- s_FWM = Settings.FileWatchingMode;
- }
- CheckDlgButton(hwnd, IDC_CHECK_BOX_A, SetBtn(Settings.ResetFileWatching));
- CheckDlgButton(hwnd, IDC_CHECK_BOX_B, SetBtn(FileWatching.MonitoringLog));
+ if (s_FWM == FWM_NO_INIT) {
+ s_FWM = Settings.FileWatchingMode;
+ }
+ CheckDlgButton(hwnd, IDC_CHECK_BOX_A, SetBtn(Settings.ResetFileWatching));
+ CheckDlgButton(hwnd, IDC_CHECK_BOX_B, SetBtn(FileWatching.MonitoringLog));
- if (FileWatching.MonitoringLog) {
- CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_C);
- EnableItem(hwnd, IDC_RADIO_BTN_A, FALSE);
- EnableItem(hwnd, IDC_RADIO_BTN_B, FALSE);
- EnableItem(hwnd, IDC_RADIO_BTN_C, FALSE);
- EnableItem(hwnd, IDC_RADIO_BTN_D, FALSE);
- EnableItem(hwnd, IDC_RADIO_BTN_E, FALSE);
- EnableItem(hwnd, IDC_CHECK_BOX_A, FALSE);
- } else {
- s_FWM = FileWatching.FileWatchingMode;
- CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_A + s_FWM);
- }
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ if (FileWatching.MonitoringLog) {
+ CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_C);
+ EnableItem(hwnd, IDC_RADIO_BTN_A, FALSE);
+ EnableItem(hwnd, IDC_RADIO_BTN_B, FALSE);
+ EnableItem(hwnd, IDC_RADIO_BTN_C, FALSE);
+ EnableItem(hwnd, IDC_RADIO_BTN_D, FALSE);
+ EnableItem(hwnd, IDC_RADIO_BTN_E, FALSE);
+ EnableItem(hwnd, IDC_CHECK_BOX_A, FALSE);
+ } else {
+ s_FWM = FileWatching.FileWatchingMode;
+ CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_A + s_FWM);
+ }
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL, IDC_RADIO_BTN_A, IDC_RADIO_BTN_B, IDC_RADIO_BTN_C, IDC_RADIO_BTN_D, IDC_RADIO_BTN_E, IDC_CHECK_BOX_A, IDC_CHECK_BOX_B };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL, IDC_RADIO_BTN_A, IDC_RADIO_BTN_B, IDC_RADIO_BTN_C, IDC_RADIO_BTN_D, IDC_RADIO_BTN_E, IDC_CHECK_BOX_A, IDC_CHECK_BOX_B };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
- case IDC_CHECK_BOX_A:
- if (!IsButtonChecked(hwnd, IDC_CHECK_BOX_A)) {
- CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_A + s_FWM);
- }
- break;
+ case IDC_CHECK_BOX_A:
+ if (!IsButtonChecked(hwnd, IDC_CHECK_BOX_A)) {
+ CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_A + s_FWM);
+ }
+ break;
- case IDC_CHECK_BOX_B:
- FileWatching.MonitoringLog = IsButtonChecked(hwnd, IDC_CHECK_BOX_B);
- if (FileWatching.MonitoringLog) {
- CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_C);
- EnableItem(hwnd, IDC_RADIO_BTN_A, FALSE);
- EnableItem(hwnd, IDC_RADIO_BTN_B, FALSE);
- EnableItem(hwnd, IDC_RADIO_BTN_C, FALSE);
- EnableItem(hwnd, IDC_RADIO_BTN_D, FALSE);
- EnableItem(hwnd, IDC_RADIO_BTN_E, FALSE);
- EnableItem(hwnd, IDC_CHECK_BOX_A, FALSE);
- } else {
- CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_A + s_FWM);
- EnableItem(hwnd, IDC_RADIO_BTN_A, TRUE);
- EnableItem(hwnd, IDC_RADIO_BTN_B, TRUE);
- EnableItem(hwnd, IDC_RADIO_BTN_C, TRUE);
- EnableItem(hwnd, IDC_RADIO_BTN_D, TRUE);
- EnableItem(hwnd, IDC_RADIO_BTN_E, TRUE);
- EnableItem(hwnd, IDC_CHECK_BOX_A, TRUE);
- }
- break;
+ case IDC_CHECK_BOX_B:
+ FileWatching.MonitoringLog = IsButtonChecked(hwnd, IDC_CHECK_BOX_B);
+ if (FileWatching.MonitoringLog) {
+ CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_C);
+ EnableItem(hwnd, IDC_RADIO_BTN_A, FALSE);
+ EnableItem(hwnd, IDC_RADIO_BTN_B, FALSE);
+ EnableItem(hwnd, IDC_RADIO_BTN_C, FALSE);
+ EnableItem(hwnd, IDC_RADIO_BTN_D, FALSE);
+ EnableItem(hwnd, IDC_RADIO_BTN_E, FALSE);
+ EnableItem(hwnd, IDC_CHECK_BOX_A, FALSE);
+ } else {
+ CheckRadioButton(hwnd, IDC_RADIO_BTN_A, IDC_RADIO_BTN_E, IDC_RADIO_BTN_A + s_FWM);
+ EnableItem(hwnd, IDC_RADIO_BTN_A, TRUE);
+ EnableItem(hwnd, IDC_RADIO_BTN_B, TRUE);
+ EnableItem(hwnd, IDC_RADIO_BTN_C, TRUE);
+ EnableItem(hwnd, IDC_RADIO_BTN_D, TRUE);
+ EnableItem(hwnd, IDC_RADIO_BTN_E, TRUE);
+ EnableItem(hwnd, IDC_CHECK_BOX_A, TRUE);
+ }
+ break;
- case IDOK:
- if (FileWatching.MonitoringLog) {
- FileWatching.MonitoringLog = false; // will be toggled in IDM_VIEW_CHASING_DOCTAIL
- PostWMCommand(Globals.hwndMain, IDM_VIEW_CHASING_DOCTAIL);
- EndDialog(hwnd, IDOK);
- break;
- }
+ case IDOK:
+ if (FileWatching.MonitoringLog) {
+ FileWatching.MonitoringLog = false; // will be toggled in IDM_VIEW_CHASING_DOCTAIL
+ PostWMCommand(Globals.hwndMain, IDM_VIEW_CHASING_DOCTAIL);
+ EndDialog(hwnd, IDOK);
+ break;
+ }
- if (IsButtonChecked(hwnd, IDC_RADIO_BTN_A)) {
- s_FWM = FWM_DONT_CARE;
- } else if (IsButtonChecked(hwnd, IDC_RADIO_BTN_B)) {
- s_FWM = FWM_INDICATORSILENT;
- } else if (IsButtonChecked(hwnd, IDC_RADIO_BTN_C)) {
- s_FWM = FWM_MSGBOX;
- } else if (IsButtonChecked(hwnd, IDC_RADIO_BTN_D)) {
- s_FWM = FWM_AUTORELOAD;
- } else if (IsButtonChecked(hwnd, IDC_RADIO_BTN_E)) {
- s_FWM = FWM_EXCLUSIVELOCK;
- }
+ if (IsButtonChecked(hwnd, IDC_RADIO_BTN_A)) {
+ s_FWM = FWM_DONT_CARE;
+ } else if (IsButtonChecked(hwnd, IDC_RADIO_BTN_B)) {
+ s_FWM = FWM_INDICATORSILENT;
+ } else if (IsButtonChecked(hwnd, IDC_RADIO_BTN_C)) {
+ s_FWM = FWM_MSGBOX;
+ } else if (IsButtonChecked(hwnd, IDC_RADIO_BTN_D)) {
+ s_FWM = FWM_AUTORELOAD;
+ } else if (IsButtonChecked(hwnd, IDC_RADIO_BTN_E)) {
+ s_FWM = FWM_EXCLUSIVELOCK;
+ }
- Settings.ResetFileWatching = IsButtonChecked(hwnd, IDC_CHECK_BOX_A);
+ Settings.ResetFileWatching = IsButtonChecked(hwnd, IDC_CHECK_BOX_A);
- if (!FileWatching.MonitoringLog) {
- FileWatching.FileWatchingMode = s_FWM;
- }
- if (!Settings.ResetFileWatching) {
- Settings.FileWatchingMode = s_FWM;
- }
+ if (!FileWatching.MonitoringLog) {
+ FileWatching.FileWatchingMode = s_FWM;
+ }
+ if (!Settings.ResetFileWatching) {
+ Settings.FileWatchingMode = s_FWM;
+ }
- EndDialog(hwnd, IDOK);
- break;
+ EndDialog(hwnd, IDOK);
+ break;
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+ break;
- }
- return TRUE;
- }
- return FALSE;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -2795,16 +2795,16 @@ CASE_WM_CTLCOLOR_SET:
bool ChangeNotifyDlg(HWND hwnd)
{
- INT_PTR iResult;
+ INT_PTR iResult;
- iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCEW(IDD_MUI_CHANGENOTIFY),
- hwnd,
- ChangeNotifyDlgProc,
- 0);
+ iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCEW(IDD_MUI_CHANGENOTIFY),
+ hwnd,
+ ChangeNotifyDlgProc,
+ 0);
- return (iResult == IDOK) ? true : false;
+ return (iResult == IDOK) ? true : false;
}
@@ -2817,92 +2817,92 @@ bool ChangeNotifyDlg(HWND hwnd)
//
static INT_PTR CALLBACK ColumnWrapDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ }
#endif
- UINT const uiNumber = *((UINT*)lParam);
- SetDlgItemInt(hwnd, IDC_COLUMNWRAP, uiNumber, false);
- SendDlgItemMessage(hwnd, IDC_COLUMNWRAP, EM_LIMITTEXT, 15, 0);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ UINT const uiNumber = *((UINT*)lParam);
+ SetDlgItemInt(hwnd, IDC_COLUMNWRAP, uiNumber, false);
+ SendDlgItemMessage(hwnd, IDC_COLUMNWRAP, EM_LIMITTEXT, 15, 0);
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
+ case WM_COMMAND:
- switch (LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
- case IDOK: {
- BOOL fTranslated;
- UINT const iNewNumber = GetDlgItemInt(hwnd, IDC_COLUMNWRAP, &fTranslated, FALSE);
- if (fTranslated) {
- UINT* piNumber = (UINT*)GetWindowLongPtr(hwnd, DWLP_USER);
- *piNumber = iNewNumber;
+ case IDOK: {
+ BOOL fTranslated;
+ UINT const iNewNumber = GetDlgItemInt(hwnd, IDC_COLUMNWRAP, &fTranslated, FALSE);
+ if (fTranslated) {
+ UINT* piNumber = (UINT*)GetWindowLongPtr(hwnd, DWLP_USER);
+ *piNumber = iNewNumber;
- EndDialog(hwnd, IDOK);
- } else {
- PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_COLUMNWRAP)), 1);
- }
- }
- break;
+ EndDialog(hwnd, IDOK);
+ } else {
+ PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_COLUMNWRAP)), 1);
+ }
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+ break;
- }
- return TRUE;
- }
- return FALSE;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -2913,15 +2913,15 @@ CASE_WM_CTLCOLOR_SET:
bool ColumnWrapDlg(HWND hwnd,UINT uidDlg, UINT *iNumber)
{
- INT_PTR iResult;
+ INT_PTR iResult;
- iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCE(uidDlg),
- hwnd,
- ColumnWrapDlgProc,(LPARAM)iNumber);
+ iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCE(uidDlg),
+ hwnd,
+ ColumnWrapDlgProc,(LPARAM)iNumber);
- return (iResult == IDOK) ? true : false;
+ return (iResult == IDOK) ? true : false;
}
@@ -2941,121 +2941,121 @@ bool ColumnWrapDlg(HWND hwnd,UINT uidDlg, UINT *iNumber)
//
static INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- switch (umsg) {
+ switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { 100, 101, 102, 103, -1 };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { 100, 101, 102, 103, -1 };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
+ }
#endif
- WCHAR tch[512];
- for (int i = 0; i < 4; i++) {
- GetDlgItemText(hwnd, 200 + i, tch, COUNTOF(tch));
- StringCchCat(tch, COUNTOF(tch), L"|");
- WCHAR* p1 = tch;
- WCHAR* p2 = StrChr(p1, L'|');
- while (p2) {
- *p2++ = L'\0';
- if (*p1) {
- SendDlgItemMessage(hwnd, 100 + i, CB_ADDSTRING, 0, (LPARAM)p1);
- }
- p1 = p2;
- p2 = StrChr(p1, L'|');
- }
- SendDlgItemMessage(hwnd, 100 + i, CB_SETEXTENDEDUI, true, 0);
- }
- SendDlgItemMessage(hwnd, 100, CB_SETCURSEL, (WPARAM)Settings.WordWrapIndent, 0);
- SendDlgItemMessage(hwnd, 101, CB_SETCURSEL, (WPARAM)(Settings.ShowWordWrapSymbols ? Settings.WordWrapSymbols % 10 : 0), 0);
- SendDlgItemMessage(hwnd, 102, CB_SETCURSEL, (WPARAM)(Settings.ShowWordWrapSymbols ? ((Settings.WordWrapSymbols % 100) - (Settings.WordWrapSymbols % 10)) / 10 : 0), 0);
- SendDlgItemMessage(hwnd, 103, CB_SETCURSEL, (WPARAM)Settings.WordWrapMode, 0);
+ WCHAR tch[512];
+ for (int i = 0; i < 4; i++) {
+ GetDlgItemText(hwnd, 200 + i, tch, COUNTOF(tch));
+ StringCchCat(tch, COUNTOF(tch), L"|");
+ WCHAR* p1 = tch;
+ WCHAR* p2 = StrChr(p1, L'|');
+ while (p2) {
+ *p2++ = L'\0';
+ if (*p1) {
+ SendDlgItemMessage(hwnd, 100 + i, CB_ADDSTRING, 0, (LPARAM)p1);
+ }
+ p1 = p2;
+ p2 = StrChr(p1, L'|');
+ }
+ SendDlgItemMessage(hwnd, 100 + i, CB_SETEXTENDEDUI, true, 0);
+ }
+ SendDlgItemMessage(hwnd, 100, CB_SETCURSEL, (WPARAM)Settings.WordWrapIndent, 0);
+ SendDlgItemMessage(hwnd, 101, CB_SETCURSEL, (WPARAM)(Settings.ShowWordWrapSymbols ? Settings.WordWrapSymbols % 10 : 0), 0);
+ SendDlgItemMessage(hwnd, 102, CB_SETCURSEL, (WPARAM)(Settings.ShowWordWrapSymbols ? ((Settings.WordWrapSymbols % 100) - (Settings.WordWrapSymbols % 10)) / 10 : 0), 0);
+ SendDlgItemMessage(hwnd, 103, CB_SETCURSEL, (WPARAM)Settings.WordWrapMode, 0);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
+ case WM_COMMAND:
- switch (LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
- case IDOK: {
- int iSel = (int)SendDlgItemMessage(hwnd, 100, CB_GETCURSEL, 0, 0);
- Settings.WordWrapIndent = iSel;
+ case IDOK: {
+ int iSel = (int)SendDlgItemMessage(hwnd, 100, CB_GETCURSEL, 0, 0);
+ Settings.WordWrapIndent = iSel;
- Settings.ShowWordWrapSymbols = false;
- iSel = (int)SendDlgItemMessage(hwnd, 101, CB_GETCURSEL, 0, 0);
- int iSel2 = (int)SendDlgItemMessage(hwnd, 102, CB_GETCURSEL, 0, 0);
- if (iSel > 0 || iSel2 > 0) {
- Settings.ShowWordWrapSymbols = true;
- Settings.WordWrapSymbols = iSel + iSel2 * 10;
- }
+ Settings.ShowWordWrapSymbols = false;
+ iSel = (int)SendDlgItemMessage(hwnd, 101, CB_GETCURSEL, 0, 0);
+ int iSel2 = (int)SendDlgItemMessage(hwnd, 102, CB_GETCURSEL, 0, 0);
+ if (iSel > 0 || iSel2 > 0) {
+ Settings.ShowWordWrapSymbols = true;
+ Settings.WordWrapSymbols = iSel + iSel2 * 10;
+ }
- iSel = (int)SendDlgItemMessage(hwnd, 103, CB_GETCURSEL, 0, 0);
- Settings.WordWrapMode = iSel;
+ iSel = (int)SendDlgItemMessage(hwnd, 103, CB_GETCURSEL, 0, 0);
+ Settings.WordWrapMode = iSel;
- EndDialog(hwnd, IDOK);
- }
- break;
+ EndDialog(hwnd, IDOK);
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+ break;
- }
- return TRUE;
+ }
+ return TRUE;
- }
- return FALSE;
+ }
+ return FALSE;
}
@@ -3066,15 +3066,15 @@ CASE_WM_CTLCOLOR_SET:
bool WordWrapSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber)
{
- INT_PTR iResult;
+ INT_PTR iResult;
- iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCE(uidDlg),
- hwnd,
- WordWrapSettingsDlgProc,(LPARAM)iNumber);
+ iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCE(uidDlg),
+ hwnd,
+ WordWrapSettingsDlgProc,(LPARAM)iNumber);
- return (iResult == IDOK) ? true : false;
+ return (iResult == IDOK) ? true : false;
}
@@ -3086,139 +3086,139 @@ bool WordWrapSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber)
//
static INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- switch (umsg) {
+ switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_STATIC };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_STATIC };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
+ }
#endif
- LPWSTR pszColumnList = (LPWSTR)lParam;
- SetDlgItemText(hwnd, IDC_MULTIEDGELINE, pszColumnList);
- SendDlgItemMessage(hwnd, IDC_MULTIEDGELINE, EM_LIMITTEXT, MIDSZ_BUFFER, 0);
+ LPWSTR pszColumnList = (LPWSTR)lParam;
+ SetDlgItemText(hwnd, IDC_MULTIEDGELINE, pszColumnList);
+ SendDlgItemMessage(hwnd, IDC_MULTIEDGELINE, EM_LIMITTEXT, MIDSZ_BUFFER, 0);
- BOOL fTranslated;
- /*UINT const iCol = */ GetDlgItemInt(hwnd, IDC_MULTIEDGELINE, &fTranslated, FALSE);
- if (fTranslated) {
- switch (Settings.LongLineMode) {
- case EDGE_BACKGROUND:
- CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_BACKGRDCOLOR);
- break;
- default:
- CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_SHOWEDGELINE);
- break;
- }
- } else {
- CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_SHOWEDGELINE);
- DialogEnableControl(hwnd, IDC_SHOWEDGELINE, false);
- DialogEnableControl(hwnd, IDC_BACKGRDCOLOR, false);
- }
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ BOOL fTranslated;
+ /*UINT const iCol = */ GetDlgItemInt(hwnd, IDC_MULTIEDGELINE, &fTranslated, FALSE);
+ if (fTranslated) {
+ switch (Settings.LongLineMode) {
+ case EDGE_BACKGROUND:
+ CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_BACKGRDCOLOR);
+ break;
+ default:
+ CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_SHOWEDGELINE);
+ break;
+ }
+ } else {
+ CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_SHOWEDGELINE);
+ DialogEnableControl(hwnd, IDC_SHOWEDGELINE, false);
+ DialogEnableControl(hwnd, IDC_BACKGRDCOLOR, false);
+ }
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
+ case WM_COMMAND:
- switch (LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
- case IDC_MULTIEDGELINE: {
- BOOL fTranslated;
- /*UINT const iCol = */ GetDlgItemInt(hwnd, IDC_MULTIEDGELINE, &fTranslated, FALSE);
- if (fTranslated) {
- DialogEnableControl(hwnd, IDC_SHOWEDGELINE, true);
- DialogEnableControl(hwnd, IDC_BACKGRDCOLOR, true);
- CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR,
- (Settings.LongLineMode == EDGE_LINE) ? IDC_SHOWEDGELINE : IDC_BACKGRDCOLOR);
- } else {
- DialogEnableControl(hwnd, IDC_SHOWEDGELINE, false);
- DialogEnableControl(hwnd, IDC_BACKGRDCOLOR, false);
- CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_SHOWEDGELINE);
- }
- }
- break;
+ case IDC_MULTIEDGELINE: {
+ BOOL fTranslated;
+ /*UINT const iCol = */ GetDlgItemInt(hwnd, IDC_MULTIEDGELINE, &fTranslated, FALSE);
+ if (fTranslated) {
+ DialogEnableControl(hwnd, IDC_SHOWEDGELINE, true);
+ DialogEnableControl(hwnd, IDC_BACKGRDCOLOR, true);
+ CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR,
+ (Settings.LongLineMode == EDGE_LINE) ? IDC_SHOWEDGELINE : IDC_BACKGRDCOLOR);
+ } else {
+ DialogEnableControl(hwnd, IDC_SHOWEDGELINE, false);
+ DialogEnableControl(hwnd, IDC_BACKGRDCOLOR, false);
+ CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_SHOWEDGELINE);
+ }
+ }
+ break;
- case IDC_SHOWEDGELINE:
- case IDC_BACKGRDCOLOR:
- if (IsDialogControlEnabled(hwnd, IDC_SHOWEDGELINE)) {
- Settings.LongLineMode = IsButtonChecked(hwnd, IDC_SHOWEDGELINE) ? EDGE_LINE : EDGE_BACKGROUND;
- }
- break;
+ case IDC_SHOWEDGELINE:
+ case IDC_BACKGRDCOLOR:
+ if (IsDialogControlEnabled(hwnd, IDC_SHOWEDGELINE)) {
+ Settings.LongLineMode = IsButtonChecked(hwnd, IDC_SHOWEDGELINE) ? EDGE_LINE : EDGE_BACKGROUND;
+ }
+ break;
- case IDOK: {
- WCHAR wchColumnList[MIDSZ_BUFFER];
- GetDlgItemText(hwnd, IDC_MULTIEDGELINE, wchColumnList, MIDSZ_BUFFER);
+ case IDOK: {
+ WCHAR wchColumnList[MIDSZ_BUFFER];
+ GetDlgItemText(hwnd, IDC_MULTIEDGELINE, wchColumnList, MIDSZ_BUFFER);
- bool const bOkay = true; // TODO: parse list OK
- if (bOkay) {
- LPWSTR pszColumnList = (LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER);
- StringCchCopy(pszColumnList, MIDSZ_BUFFER, wchColumnList);
- Settings.LongLineMode = IsButtonChecked(hwnd, IDC_SHOWEDGELINE) ? EDGE_LINE : EDGE_BACKGROUND;
- EndDialog(hwnd, IDOK);
- } else {
- PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_MULTIEDGELINE)), 1);
- }
- }
- break;
+ bool const bOkay = true; // TODO: parse list OK
+ if (bOkay) {
+ LPWSTR pszColumnList = (LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER);
+ StringCchCopy(pszColumnList, MIDSZ_BUFFER, wchColumnList);
+ Settings.LongLineMode = IsButtonChecked(hwnd, IDC_SHOWEDGELINE) ? EDGE_LINE : EDGE_BACKGROUND;
+ EndDialog(hwnd, IDOK);
+ } else {
+ PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_MULTIEDGELINE)), 1);
+ }
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+ break;
- }
- return TRUE;
- }
- return FALSE;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -3228,13 +3228,13 @@ CASE_WM_CTLCOLOR_SET:
//
bool LongLineSettingsDlg(HWND hwnd,UINT uidDlg, LPWSTR pColList)
{
- INT_PTR const iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCE(uidDlg),
- hwnd,
- LongLineSettingsDlgProc, (LPARAM)pColList);
+ INT_PTR const iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCE(uidDlg),
+ hwnd,
+ LongLineSettingsDlgProc, (LPARAM)pColList);
- return (iResult == IDOK) ? true : false;
+ return (iResult == IDOK) ? true : false;
}
@@ -3251,123 +3251,123 @@ bool LongLineSettingsDlg(HWND hwnd,UINT uidDlg, LPWSTR pColList)
static INT_PTR CALLBACK TabSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
- switch(umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch(umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { IDC_TAB_AS_SPC, IDC_TAB_INDENTS, IDC_BACKTAB_INDENTS,
- IDC_WARN_INCONSISTENT_INDENTS, IDC_AUTO_DETECT_INDENTS, IDC_STATIC, IDC_STATIC2, IDC_STATIC3
- };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { IDC_TAB_AS_SPC, IDC_TAB_INDENTS, IDC_BACKTAB_INDENTS,
+ IDC_WARN_INCONSISTENT_INDENTS, IDC_AUTO_DETECT_INDENTS, IDC_STATIC, IDC_STATIC2, IDC_STATIC3
+ };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
+ }
#endif
- SetDlgItemInt(hwnd, IDC_TAB_WIDTH, Globals.fvCurFile.iTabWidth, false);
- SendDlgItemMessage(hwnd,IDC_TAB_WIDTH,EM_LIMITTEXT,15,0);
+ SetDlgItemInt(hwnd, IDC_TAB_WIDTH, Globals.fvCurFile.iTabWidth, false);
+ SendDlgItemMessage(hwnd,IDC_TAB_WIDTH,EM_LIMITTEXT,15,0);
- SetDlgItemInt(hwnd,IDC_INDENT_DEPTH, Globals.fvCurFile.iIndentWidth,false);
- SendDlgItemMessage(hwnd,IDC_INDENT_DEPTH,EM_LIMITTEXT,15,0);
+ SetDlgItemInt(hwnd,IDC_INDENT_DEPTH, Globals.fvCurFile.iIndentWidth,false);
+ SendDlgItemMessage(hwnd,IDC_INDENT_DEPTH,EM_LIMITTEXT,15,0);
- CheckDlgButton(hwnd,IDC_TAB_AS_SPC, SetBtn(Globals.fvCurFile.bTabsAsSpaces));
- CheckDlgButton(hwnd,IDC_TAB_INDENTS, SetBtn(Globals.fvCurFile.bTabIndents));
- CheckDlgButton(hwnd,IDC_BACKTAB_INDENTS, SetBtn(Settings.BackspaceUnindents));
- CheckDlgButton(hwnd,IDC_WARN_INCONSISTENT_INDENTS, SetBtn(Settings.WarnInconsistentIndents));
- CheckDlgButton(hwnd,IDC_AUTO_DETECT_INDENTS, SetBtn(Settings.AutoDetectIndentSettings));
+ CheckDlgButton(hwnd,IDC_TAB_AS_SPC, SetBtn(Globals.fvCurFile.bTabsAsSpaces));
+ CheckDlgButton(hwnd,IDC_TAB_INDENTS, SetBtn(Globals.fvCurFile.bTabIndents));
+ CheckDlgButton(hwnd,IDC_BACKTAB_INDENTS, SetBtn(Settings.BackspaceUnindents));
+ CheckDlgButton(hwnd,IDC_WARN_INCONSISTENT_INDENTS, SetBtn(Settings.WarnInconsistentIndents));
+ CheckDlgButton(hwnd,IDC_AUTO_DETECT_INDENTS, SetBtn(Settings.AutoDetectIndentSettings));
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
+ case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDOK: {
- BOOL fTranslated1, fTranslated2;
- int const _iNewTabWidth = GetDlgItemInt(hwnd, IDC_TAB_WIDTH, &fTranslated1, FALSE);
- int const _iNewIndentWidth = GetDlgItemInt(hwnd, IDC_INDENT_DEPTH, &fTranslated2, FALSE);
+ switch(LOWORD(wParam)) {
+ case IDOK: {
+ BOOL fTranslated1, fTranslated2;
+ int const _iNewTabWidth = GetDlgItemInt(hwnd, IDC_TAB_WIDTH, &fTranslated1, FALSE);
+ int const _iNewIndentWidth = GetDlgItemInt(hwnd, IDC_INDENT_DEPTH, &fTranslated2, FALSE);
- if (fTranslated1 && fTranslated2) {
- Settings.TabWidth = _iNewTabWidth;
- Globals.fvCurFile.iTabWidth = _iNewTabWidth;
+ if (fTranslated1 && fTranslated2) {
+ Settings.TabWidth = _iNewTabWidth;
+ Globals.fvCurFile.iTabWidth = _iNewTabWidth;
- Settings.IndentWidth = _iNewIndentWidth;
- Globals.fvCurFile.iIndentWidth = _iNewIndentWidth;
+ Settings.IndentWidth = _iNewIndentWidth;
+ Globals.fvCurFile.iIndentWidth = _iNewIndentWidth;
- bool const _bTabsAsSpaces = IsButtonChecked(hwnd, IDC_TAB_AS_SPC);
- Settings.TabsAsSpaces = _bTabsAsSpaces;
- Globals.fvCurFile.bTabsAsSpaces = _bTabsAsSpaces;
+ bool const _bTabsAsSpaces = IsButtonChecked(hwnd, IDC_TAB_AS_SPC);
+ Settings.TabsAsSpaces = _bTabsAsSpaces;
+ Globals.fvCurFile.bTabsAsSpaces = _bTabsAsSpaces;
- bool const _bTabIndents = IsButtonChecked(hwnd, IDC_TAB_INDENTS);
- Settings.TabIndents = _bTabIndents;
- Globals.fvCurFile.bTabIndents = _bTabIndents;
+ bool const _bTabIndents = IsButtonChecked(hwnd, IDC_TAB_INDENTS);
+ Settings.TabIndents = _bTabIndents;
+ Globals.fvCurFile.bTabIndents = _bTabIndents;
- Settings.BackspaceUnindents = IsButtonChecked(hwnd, IDC_BACKTAB_INDENTS);
- Settings.WarnInconsistentIndents = IsButtonChecked(hwnd, IDC_WARN_INCONSISTENT_INDENTS);
- Settings.AutoDetectIndentSettings = IsButtonChecked(hwnd, IDC_AUTO_DETECT_INDENTS);
- EndDialog(hwnd, IDOK);
- } else {
- PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, (fTranslated1) ? IDC_INDENT_DEPTH : IDC_TAB_WIDTH)), 1);
- }
- }
- break;
+ Settings.BackspaceUnindents = IsButtonChecked(hwnd, IDC_BACKTAB_INDENTS);
+ Settings.WarnInconsistentIndents = IsButtonChecked(hwnd, IDC_WARN_INCONSISTENT_INDENTS);
+ Settings.AutoDetectIndentSettings = IsButtonChecked(hwnd, IDC_AUTO_DETECT_INDENTS);
+ EndDialog(hwnd, IDOK);
+ } else {
+ PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, (fTranslated1) ? IDC_INDENT_DEPTH : IDC_TAB_WIDTH)), 1);
+ }
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd,IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
- default:
- break;
- }
- return TRUE;
- }
- return FALSE;
+ default:
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -3378,15 +3378,15 @@ CASE_WM_CTLCOLOR_SET:
bool TabSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber)
{
- INT_PTR iResult;
+ INT_PTR iResult;
- iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCE(uidDlg),
- hwnd,
- TabSettingsDlgProc,(LPARAM)iNumber);
+ iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCE(uidDlg),
+ hwnd,
+ TabSettingsDlgProc,(LPARAM)iNumber);
- return (iResult == IDOK) ? true : false;
+ return (iResult == IDOK) ? true : false;
}
@@ -3397,188 +3397,188 @@ bool TabSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber)
//
//
typedef struct encodedlg {
- bool bRecodeOnly;
- cpi_enc_t idEncoding;
- int cxDlg;
- int cyDlg;
+ bool bRecodeOnly;
+ cpi_enc_t idEncoding;
+ int cxDlg;
+ int cyDlg;
}
ENCODEDLG, *PENCODEDLG;
static INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- static cpi_enc_t s_iEnc;
- static bool s_bUseAsFallback;
- static bool s_bLoadASCIIasUTF8;
+ static cpi_enc_t s_iEnc;
+ static bool s_bUseAsFallback;
+ static bool s_bLoadASCIIasUTF8;
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ SetDialogIconNP3(hwnd);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //~SetExplorerTheme(GetDlgItem(hwnd, IDC_ENCODINGLIST)); ~ OWNERDRAWN -> WM_DRAWITEM
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { IDC_ENCODINGLIST, IDC_USEASREADINGFALLBACK, IDC_ASCIIASUTF8, IDC_RELIABLE_DETECTION_RES,
- IDC_NFOASOEM, IDC_ENCODINGFROMFILEVARS, IDC_NOUNICODEDETECTION, IDC_NOANSICPDETECTION, IDC_STATIC, IDC_STATIC2
- };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //~SetExplorerTheme(GetDlgItem(hwnd, IDC_ENCODINGLIST)); ~ OWNERDRAWN -> WM_DRAWITEM
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { IDC_ENCODINGLIST, IDC_USEASREADINGFALLBACK, IDC_ASCIIASUTF8, IDC_RELIABLE_DETECTION_RES,
+ IDC_NFOASOEM, IDC_ENCODINGFROMFILEVARS, IDC_NOUNICODEDETECTION, IDC_NOANSICPDETECTION, IDC_STATIC, IDC_STATIC2
+ };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
+ }
#endif
- PENCODEDLG const pdd = (PENCODEDLG)lParam;
- HBITMAP hbmp = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDB_ENCODING), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
- hbmp = ResampleImageBitmap(hwnd, hbmp, -1, -1);
+ PENCODEDLG const pdd = (PENCODEDLG)lParam;
+ HBITMAP hbmp = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDB_ENCODING), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ hbmp = ResampleImageBitmap(hwnd, hbmp, -1, -1);
- HIMAGELIST himl = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
- ImageList_AddMasked(himl, hbmp, CLR_DEFAULT);
- DeleteObject(hbmp);
- SendDlgItemMessage(hwnd, IDC_ENCODINGLIST, CBEM_SETIMAGELIST, 0, (LPARAM)himl);
- SendDlgItemMessage(hwnd, IDC_ENCODINGLIST, CB_SETEXTENDEDUI, true, 0);
- //SendDlgItemMessage(hwnd, IDC_ENCODINGLIST, CBEM_SETEXTENDEDSTYLE, 0, CBES_EX_TEXTENDELLIPSIS);
+ HIMAGELIST himl = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
+ ImageList_AddMasked(himl, hbmp, CLR_DEFAULT);
+ DeleteObject(hbmp);
+ SendDlgItemMessage(hwnd, IDC_ENCODINGLIST, CBEM_SETIMAGELIST, 0, (LPARAM)himl);
+ SendDlgItemMessage(hwnd, IDC_ENCODINGLIST, CB_SETEXTENDEDUI, true, 0);
+ //SendDlgItemMessage(hwnd, IDC_ENCODINGLIST, CBEM_SETEXTENDEDSTYLE, 0, CBES_EX_TEXTENDELLIPSIS);
- Encoding_AddToComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), pdd->idEncoding, 0);
+ Encoding_AddToComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), pdd->idEncoding, 0);
- Encoding_GetFromComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), &s_iEnc);
- s_bLoadASCIIasUTF8 = Settings.LoadASCIIasUTF8;
- s_bUseAsFallback = Encoding_IsASCII(s_iEnc) ? Settings.UseDefaultForFileEncoding : false;
+ Encoding_GetFromComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), &s_iEnc);
+ s_bLoadASCIIasUTF8 = Settings.LoadASCIIasUTF8;
+ s_bUseAsFallback = Encoding_IsASCII(s_iEnc) ? Settings.UseDefaultForFileEncoding : false;
- DialogEnableControl(hwnd, IDC_USEASREADINGFALLBACK, Encoding_IsASCII(s_iEnc));
- CheckDlgButton(hwnd, IDC_USEASREADINGFALLBACK, SetBtn(s_bUseAsFallback));
+ DialogEnableControl(hwnd, IDC_USEASREADINGFALLBACK, Encoding_IsASCII(s_iEnc));
+ CheckDlgButton(hwnd, IDC_USEASREADINGFALLBACK, SetBtn(s_bUseAsFallback));
- CheckDlgButton(hwnd, IDC_ASCIIASUTF8, SetBtn(s_bLoadASCIIasUTF8));
- CheckDlgButton(hwnd, IDC_RELIABLE_DETECTION_RES, SetBtn(Settings.UseReliableCEDonly));
- CheckDlgButton(hwnd, IDC_NFOASOEM, SetBtn(Settings.LoadNFOasOEM));
- CheckDlgButton(hwnd, IDC_ENCODINGFROMFILEVARS, SetBtn(!Settings.NoEncodingTags));
- CheckDlgButton(hwnd, IDC_NOUNICODEDETECTION, SetBtn(!Settings.SkipUnicodeDetection));
- CheckDlgButton(hwnd, IDC_NOANSICPDETECTION, SetBtn(!Settings.SkipANSICodePageDetection));
+ CheckDlgButton(hwnd, IDC_ASCIIASUTF8, SetBtn(s_bLoadASCIIasUTF8));
+ CheckDlgButton(hwnd, IDC_RELIABLE_DETECTION_RES, SetBtn(Settings.UseReliableCEDonly));
+ CheckDlgButton(hwnd, IDC_NFOASOEM, SetBtn(Settings.LoadNFOasOEM));
+ CheckDlgButton(hwnd, IDC_ENCODINGFROMFILEVARS, SetBtn(!Settings.NoEncodingTags));
+ CheckDlgButton(hwnd, IDC_NOUNICODEDETECTION, SetBtn(!Settings.SkipUnicodeDetection));
+ CheckDlgButton(hwnd, IDC_NOANSICPDETECTION, SetBtn(!Settings.SkipANSICodePageDetection));
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
- case WM_DRAWITEM: {
- /// TODO: migrate: currently "ComboBoxEx32" control is used, instead of COMBOBOX control
- /// "ComboBoxEx32" does not support WM_DRAWITEM (OwnerDrawn)
- /// see https://docs.microsoft.com/en-us/windows/win32/controls/comboboxex-control-reference
- /// vs
- /// https://docs.microsoft.com/en-us/windows/win32/controls/create-an-owner-drawn-combo-box
- ///
- if (LOWORD(wParam) == IDC_ENCODINGLIST) {
- const DRAWITEMSTRUCT *const pDIS = (const DRAWITEMSTRUCT *const)lParam;
- //HWND const hWndItem = pDIS->hwndItem;
- HDC const hdc = pDIS->hDC;
- //RECT const rc = pDIS->rcItem;
- SetModeBkColor(hdc, UseDarkMode());
- SetModeTextColor(hdc, UseDarkMode());
- }
- }
- break;
+ case WM_DRAWITEM: {
+ /// TODO: migrate: currently "ComboBoxEx32" control is used, instead of COMBOBOX control
+ /// "ComboBoxEx32" does not support WM_DRAWITEM (OwnerDrawn)
+ /// see https://docs.microsoft.com/en-us/windows/win32/controls/comboboxex-control-reference
+ /// vs
+ /// https://docs.microsoft.com/en-us/windows/win32/controls/create-an-owner-drawn-combo-box
+ ///
+ if (LOWORD(wParam) == IDC_ENCODINGLIST) {
+ const DRAWITEMSTRUCT *const pDIS = (const DRAWITEMSTRUCT *const)lParam;
+ //HWND const hWndItem = pDIS->hwndItem;
+ HDC const hdc = pDIS->hDC;
+ //RECT const rc = pDIS->rcItem;
+ SetModeBkColor(hdc, UseDarkMode());
+ SetModeTextColor(hdc, UseDarkMode());
+ }
+ }
+ break;
#endif
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_ENCODINGLIST:
- case IDC_USEASREADINGFALLBACK:
- case IDC_ASCIIASUTF8: {
- Encoding_GetFromComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), &s_iEnc);
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_ENCODINGLIST:
+ case IDC_USEASREADINGFALLBACK:
+ case IDC_ASCIIASUTF8: {
+ Encoding_GetFromComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), &s_iEnc);
- s_bUseAsFallback = Encoding_IsASCII(s_iEnc) ? IsButtonChecked(hwnd, IDC_USEASREADINGFALLBACK) : false;
- s_bLoadASCIIasUTF8 = IsButtonChecked(hwnd, IDC_ASCIIASUTF8);
+ s_bUseAsFallback = Encoding_IsASCII(s_iEnc) ? IsButtonChecked(hwnd, IDC_USEASREADINGFALLBACK) : false;
+ s_bLoadASCIIasUTF8 = IsButtonChecked(hwnd, IDC_ASCIIASUTF8);
- DialogEnableControl(hwnd, IDC_USEASREADINGFALLBACK, Encoding_IsASCII(s_iEnc));
- CheckDlgButton(hwnd, IDC_USEASREADINGFALLBACK, SetBtn(s_bUseAsFallback));
+ DialogEnableControl(hwnd, IDC_USEASREADINGFALLBACK, Encoding_IsASCII(s_iEnc));
+ CheckDlgButton(hwnd, IDC_USEASREADINGFALLBACK, SetBtn(s_bUseAsFallback));
- DialogEnableControl(hwnd, IDC_ASCIIASUTF8, true);
- CheckDlgButton(hwnd, IDC_ASCIIASUTF8, SetBtn(s_bLoadASCIIasUTF8));
+ DialogEnableControl(hwnd, IDC_ASCIIASUTF8, true);
+ CheckDlgButton(hwnd, IDC_ASCIIASUTF8, SetBtn(s_bLoadASCIIasUTF8));
- if (s_iEnc == CPI_UTF8) {
- if (s_bUseAsFallback) {
- s_bLoadASCIIasUTF8 = true;
- DialogEnableControl(hwnd, IDC_ASCIIASUTF8, false);
- CheckDlgButton(hwnd, IDC_ASCIIASUTF8, SetBtn(s_bLoadASCIIasUTF8));
- }
- } else if (s_iEnc == CPI_ANSI_DEFAULT) {
- if (s_bUseAsFallback) {
- s_bLoadASCIIasUTF8 = false;
- DialogEnableControl(hwnd, IDC_ASCIIASUTF8, false);
- CheckDlgButton(hwnd, IDC_ASCIIASUTF8, SetBtn(s_bLoadASCIIasUTF8));
- }
- }
- }
- break;
+ if (s_iEnc == CPI_UTF8) {
+ if (s_bUseAsFallback) {
+ s_bLoadASCIIasUTF8 = true;
+ DialogEnableControl(hwnd, IDC_ASCIIASUTF8, false);
+ CheckDlgButton(hwnd, IDC_ASCIIASUTF8, SetBtn(s_bLoadASCIIasUTF8));
+ }
+ } else if (s_iEnc == CPI_ANSI_DEFAULT) {
+ if (s_bUseAsFallback) {
+ s_bLoadASCIIasUTF8 = false;
+ DialogEnableControl(hwnd, IDC_ASCIIASUTF8, false);
+ CheckDlgButton(hwnd, IDC_ASCIIASUTF8, SetBtn(s_bLoadASCIIasUTF8));
+ }
+ }
+ }
+ break;
- case IDOK: {
- PENCODEDLG pdd = (PENCODEDLG)GetWindowLongPtr(hwnd, DWLP_USER);
- if (Encoding_GetFromComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), &pdd->idEncoding)) {
- if (pdd->idEncoding < 0) {
- InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_ENCODINGNA);
- EndDialog(hwnd, IDCANCEL);
- } else {
- Settings.UseDefaultForFileEncoding = IsButtonChecked(hwnd, IDC_USEASREADINGFALLBACK);
- Settings.LoadASCIIasUTF8 = IsButtonChecked(hwnd, IDC_ASCIIASUTF8);
- Settings.UseReliableCEDonly = IsButtonChecked(hwnd, IDC_RELIABLE_DETECTION_RES);
- Settings.LoadNFOasOEM = IsButtonChecked(hwnd, IDC_NFOASOEM);
- Settings.NoEncodingTags = !IsButtonChecked(hwnd, IDC_ENCODINGFROMFILEVARS);
- Settings.SkipUnicodeDetection = !IsButtonChecked(hwnd, IDC_NOUNICODEDETECTION);
- Settings.SkipANSICodePageDetection = !IsButtonChecked(hwnd, IDC_NOANSICPDETECTION);
- EndDialog(hwnd, IDOK);
- }
- } else {
- PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_ENCODINGLIST)), 1);
- }
- }
- break;
+ case IDOK: {
+ PENCODEDLG pdd = (PENCODEDLG)GetWindowLongPtr(hwnd, DWLP_USER);
+ if (Encoding_GetFromComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), &pdd->idEncoding)) {
+ if (pdd->idEncoding < 0) {
+ InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_ENCODINGNA);
+ EndDialog(hwnd, IDCANCEL);
+ } else {
+ Settings.UseDefaultForFileEncoding = IsButtonChecked(hwnd, IDC_USEASREADINGFALLBACK);
+ Settings.LoadASCIIasUTF8 = IsButtonChecked(hwnd, IDC_ASCIIASUTF8);
+ Settings.UseReliableCEDonly = IsButtonChecked(hwnd, IDC_RELIABLE_DETECTION_RES);
+ Settings.LoadNFOasOEM = IsButtonChecked(hwnd, IDC_NFOASOEM);
+ Settings.NoEncodingTags = !IsButtonChecked(hwnd, IDC_ENCODINGFROMFILEVARS);
+ Settings.SkipUnicodeDetection = !IsButtonChecked(hwnd, IDC_NOUNICODEDETECTION);
+ Settings.SkipANSICodePageDetection = !IsButtonChecked(hwnd, IDC_NOANSICPDETECTION);
+ EndDialog(hwnd, IDOK);
+ }
+ } else {
+ PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_ENCODINGLIST)), 1);
+ }
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd, IDCANCEL);
- break;
- }
- return TRUE;
- }
- return FALSE;
+ case IDCANCEL:
+ EndDialog(hwnd, IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -3588,23 +3588,23 @@ CASE_WM_CTLCOLOR_SET:
//
bool SelectDefEncodingDlg(HWND hwnd, cpi_enc_t* pidREncoding)
{
- INT_PTR iResult;
- ENCODEDLG dd = { 0 };
- dd.bRecodeOnly = false;
- dd.idEncoding = *pidREncoding;
+ INT_PTR iResult;
+ ENCODEDLG dd = { 0 };
+ dd.bRecodeOnly = false;
+ dd.idEncoding = *pidREncoding;
- iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCE(IDD_MUI_DEFENCODING),
- hwnd,
- SelectDefEncodingDlgProc,
- (LPARAM)&dd);
+ iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCE(IDD_MUI_DEFENCODING),
+ hwnd,
+ SelectDefEncodingDlgProc,
+ (LPARAM)&dd);
- if (iResult == IDOK) {
- *pidREncoding = dd.idEncoding;
- return TRUE;
- }
- return FALSE;
+ if (iResult == IDOK) {
+ *pidREncoding = dd.idEncoding;
+ return TRUE;
+ }
+ return FALSE;
}
@@ -3615,168 +3615,168 @@ bool SelectDefEncodingDlg(HWND hwnd, cpi_enc_t* pidREncoding)
//
static INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
- static HWND hwndLV = NULL;
- static HIMAGELIST himl = NULL;
+ static HWND hwndLV = NULL;
+ static HIMAGELIST himl = NULL;
- switch(umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch(umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ }
#endif
- PENCODEDLG const pdd = (PENCODEDLG)lParam;
- LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
- ResizeDlg_Init(hwnd, pdd->cxDlg, pdd->cyDlg, IDC_RESIZEGRIP);
+ PENCODEDLG const pdd = (PENCODEDLG)lParam;
+ LVCOLUMN lvc = { LVCF_FMT | LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 };
+ ResizeDlg_Init(hwnd, pdd->cxDlg, pdd->cyDlg, IDC_RESIZEGRIP);
- hwndLV = GetDlgItem(hwnd, IDC_ENCODINGLIST);
- InitWindowCommon(hwndLV, true);
- InitListView(hwndLV);
+ hwndLV = GetDlgItem(hwnd, IDC_ENCODINGLIST);
+ InitWindowCommon(hwndLV, true);
+ InitListView(hwndLV);
- HBITMAP hbmp = LoadImage(Globals.hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
- hbmp = ResampleImageBitmap(hwnd, hbmp, -1, -1);
+ HBITMAP hbmp = LoadImage(Globals.hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
+ hbmp = ResampleImageBitmap(hwnd, hbmp, -1, -1);
- himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0);
- ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
- DeleteObject(hbmp);
- ListView_SetImageList(hwndLV, himl, LVSIL_SMALL);
+ himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0);
+ ImageList_AddMasked(himl,hbmp,CLR_DEFAULT);
+ DeleteObject(hbmp);
+ ListView_SetImageList(hwndLV, himl, LVSIL_SMALL);
- ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
- ListView_InsertColumn(hwndLV,0,&lvc);
+ ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
+ ListView_InsertColumn(hwndLV,0,&lvc);
- Encoding_AddToListView(hwndLV,pdd->idEncoding,pdd->bRecodeOnly);
+ Encoding_AddToListView(hwndLV,pdd->idEncoding,pdd->bRecodeOnly);
- ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER);
+ ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER);
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
- case WM_DESTROY: {
- ImageList_Destroy(himl);
- himl = NULL;
- PENCODEDLG pdd = (PENCODEDLG)GetWindowLongPtr(hwnd, DWLP_USER);
- ResizeDlg_Destroy(hwnd, &pdd->cxDlg, &pdd->cyDlg);
- }
- return FALSE;
+ case WM_DESTROY: {
+ ImageList_Destroy(himl);
+ himl = NULL;
+ PENCODEDLG pdd = (PENCODEDLG)GetWindowLongPtr(hwnd, DWLP_USER);
+ ResizeDlg_Destroy(hwnd, &pdd->cxDlg, &pdd->cyDlg);
+ }
+ return FALSE;
- case WM_SIZE: {
- int dx, dy;
- ResizeDlg_Size(hwnd,lParam,&dx,&dy);
+ case WM_SIZE: {
+ int dx, dy;
+ ResizeDlg_Size(hwnd,lParam,&dx,&dy);
- HDWP hdwp = BeginDeferWindowPos(4);
- hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
- hdwp = DeferCtlPos(hdwp,hwnd,IDC_ENCODINGLIST,dx,dy,SWP_NOMOVE);
- EndDeferWindowPos(hdwp);
- ListView_SetColumnWidth(hwndLV, 0, LVSCW_AUTOSIZE_USEHEADER);
- }
- return TRUE;
+ HDWP hdwp = BeginDeferWindowPos(4);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE);
+ hdwp = DeferCtlPos(hdwp,hwnd,IDC_ENCODINGLIST,dx,dy,SWP_NOMOVE);
+ EndDeferWindowPos(hdwp);
+ ListView_SetColumnWidth(hwndLV, 0, LVSCW_AUTOSIZE_USEHEADER);
+ }
+ return TRUE;
- case WM_GETMINMAXINFO:
- ResizeDlg_GetMinMaxInfo(hwnd,lParam);
- return TRUE;
+ case WM_GETMINMAXINFO:
+ ResizeDlg_GetMinMaxInfo(hwnd,lParam);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL, IDC_RESIZEGRIP };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- SendMessage(hwndLV, WM_THEMECHANGED, 0, 0);
+ int const buttons[] = { IDOK, IDCANCEL, IDC_RESIZEGRIP };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ SendMessage(hwndLV, WM_THEMECHANGED, 0, 0);
- UpdateWindowEx(hwnd);
- }
- break;
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_NOTIFY: {
- if (((LPNMHDR)(lParam))->idFrom == IDC_ENCODINGLIST) {
+ case WM_NOTIFY: {
+ if (((LPNMHDR)(lParam))->idFrom == IDC_ENCODINGLIST) {
- switch (((LPNMHDR)(lParam))->code) {
+ switch (((LPNMHDR)(lParam))->code) {
- case NM_DBLCLK:
- SendWMCommand(hwnd, IDOK);
- break;
+ case NM_DBLCLK:
+ SendWMCommand(hwnd, IDOK);
+ break;
- case LVN_ITEMCHANGED:
- case LVN_DELETEITEM: {
- int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED);
- DialogEnableControl(hwnd,IDOK,i != -1);
- }
- break;
- }
- }
- }
- return TRUE;
+ case LVN_ITEMCHANGED:
+ case LVN_DELETEITEM: {
+ int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED);
+ DialogEnableControl(hwnd,IDOK,i != -1);
+ }
+ break;
+ }
+ }
+ }
+ return TRUE;
- case WM_COMMAND:
+ case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDOK: {
- PENCODEDLG pdd = (PENCODEDLG)GetWindowLongPtr(hwnd, DWLP_USER);
- if (Encoding_GetFromListView(hwndLV, &pdd->idEncoding)) {
- if (pdd->idEncoding < 0) {
- InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_ENCODINGNA);
- EndDialog(hwnd, IDCANCEL);
- } else {
- EndDialog(hwnd, IDOK);
- }
- } else {
- PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)hwndLV, 1);
- }
- }
- break;
+ switch(LOWORD(wParam)) {
+ case IDOK: {
+ PENCODEDLG pdd = (PENCODEDLG)GetWindowLongPtr(hwnd, DWLP_USER);
+ if (Encoding_GetFromListView(hwndLV, &pdd->idEncoding)) {
+ if (pdd->idEncoding < 0) {
+ InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_ENCODINGNA);
+ EndDialog(hwnd, IDCANCEL);
+ } else {
+ EndDialog(hwnd, IDOK);
+ }
+ } else {
+ PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)hwndLV, 1);
+ }
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd,IDCANCEL);
- break;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
- default:
- break;
- }
- return TRUE;
- }
- return FALSE;
+ default:
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -3787,28 +3787,28 @@ CASE_WM_CTLCOLOR_SET:
bool SelectEncodingDlg(HWND hwnd, cpi_enc_t* pidREncoding)
{
- INT_PTR iResult;
- ENCODEDLG dd = { 0 };
- dd.bRecodeOnly = false;
- dd.idEncoding = *pidREncoding;
- dd.cxDlg = Settings.EncodingDlgSizeX;
- dd.cyDlg = Settings.EncodingDlgSizeY;
+ INT_PTR iResult;
+ ENCODEDLG dd = { 0 };
+ dd.bRecodeOnly = false;
+ dd.idEncoding = *pidREncoding;
+ dd.cxDlg = Settings.EncodingDlgSizeX;
+ dd.cyDlg = Settings.EncodingDlgSizeY;
- iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCE(IDD_MUI_ENCODING),
- hwnd,
- SelectEncodingDlgProc,
- (LPARAM)&dd);
+ iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCE(IDD_MUI_ENCODING),
+ hwnd,
+ SelectEncodingDlgProc,
+ (LPARAM)&dd);
- Settings.EncodingDlgSizeX = dd.cxDlg;
- Settings.EncodingDlgSizeY = dd.cyDlg;
+ Settings.EncodingDlgSizeX = dd.cxDlg;
+ Settings.EncodingDlgSizeY = dd.cyDlg;
- if (iResult == IDOK) {
- *pidREncoding = dd.idEncoding;
- return TRUE;
- }
- return FALSE;
+ if (iResult == IDOK) {
+ *pidREncoding = dd.idEncoding;
+ return TRUE;
+ }
+ return FALSE;
}
@@ -3819,28 +3819,28 @@ bool SelectEncodingDlg(HWND hwnd, cpi_enc_t* pidREncoding)
bool RecodeDlg(HWND hwnd, cpi_enc_t* pidREncoding)
{
- INT_PTR iResult = 0;
- ENCODEDLG dd = { 0 };
- dd.bRecodeOnly = true;
- dd.idEncoding = *pidREncoding;
- dd.cxDlg = Settings.RecodeDlgSizeX;
- dd.cyDlg = Settings.RecodeDlgSizeY;
+ INT_PTR iResult = 0;
+ ENCODEDLG dd = { 0 };
+ dd.bRecodeOnly = true;
+ dd.idEncoding = *pidREncoding;
+ dd.cxDlg = Settings.RecodeDlgSizeX;
+ dd.cyDlg = Settings.RecodeDlgSizeY;
- iResult = ThemedDialogBoxParam(
- Globals.hLngResContainer,
- MAKEINTRESOURCE(IDD_MUI_RECODE),
- hwnd,
- SelectEncodingDlgProc,
- (LPARAM)&dd);
+ iResult = ThemedDialogBoxParam(
+ Globals.hLngResContainer,
+ MAKEINTRESOURCE(IDD_MUI_RECODE),
+ hwnd,
+ SelectEncodingDlgProc,
+ (LPARAM)&dd);
- Settings.RecodeDlgSizeX = dd.cxDlg;
- Settings.RecodeDlgSizeY = dd.cyDlg;
+ Settings.RecodeDlgSizeX = dd.cxDlg;
+ Settings.RecodeDlgSizeY = dd.cyDlg;
- if (iResult == IDOK) {
- *pidREncoding = dd.idEncoding;
- return TRUE;
- }
- return FALSE;
+ if (iResult == IDOK) {
+ *pidREncoding = dd.idEncoding;
+ return TRUE;
+ }
+ return FALSE;
}
@@ -3851,101 +3851,101 @@ bool RecodeDlg(HWND hwnd, cpi_enc_t* pidREncoding)
//
static INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
- switch(umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
+ switch(umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { IDC_EOLMODELIST, IDC_WARN_INCONSISTENT_EOLS, IDC_CONSISTENT_EOLS, IDC_AUTOSTRIPBLANKS, IDC_STATIC };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { IDC_EOLMODELIST, IDC_WARN_INCONSISTENT_EOLS, IDC_CONSISTENT_EOLS, IDC_AUTOSTRIPBLANKS, IDC_STATIC };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
+ }
#endif
- int const iOption = *((int*)lParam);
+ int const iOption = *((int*)lParam);
- // Load options
- WCHAR wch[256] = { L'\0' };
- for (int i = 0; i < 3; i++) {
- GetLngString(IDS_EOL_WIN+i,wch,COUNTOF(wch));
- SendDlgItemMessage(hwnd, IDC_EOLMODELIST,CB_ADDSTRING,0,(LPARAM)wch);
- }
+ // Load options
+ WCHAR wch[256] = { L'\0' };
+ for (int i = 0; i < 3; i++) {
+ GetLngString(IDS_EOL_WIN+i,wch,COUNTOF(wch));
+ SendDlgItemMessage(hwnd, IDC_EOLMODELIST,CB_ADDSTRING,0,(LPARAM)wch);
+ }
- SendDlgItemMessage(hwnd, IDC_EOLMODELIST,CB_SETCURSEL,iOption,0);
- SendDlgItemMessage(hwnd, IDC_EOLMODELIST,CB_SETEXTENDEDUI,true,0);
+ SendDlgItemMessage(hwnd, IDC_EOLMODELIST,CB_SETCURSEL,iOption,0);
+ SendDlgItemMessage(hwnd, IDC_EOLMODELIST,CB_SETEXTENDEDUI,true,0);
- CheckDlgButton(hwnd,IDC_WARN_INCONSISTENT_EOLS, SetBtn(Settings.WarnInconsistEOLs));
- CheckDlgButton(hwnd,IDC_CONSISTENT_EOLS, SetBtn(Settings.FixLineEndings));
- CheckDlgButton(hwnd,IDC_AUTOSTRIPBLANKS, SetBtn(Settings.FixTrailingBlanks));
+ CheckDlgButton(hwnd,IDC_WARN_INCONSISTENT_EOLS, SetBtn(Settings.WarnInconsistEOLs));
+ CheckDlgButton(hwnd,IDC_CONSISTENT_EOLS, SetBtn(Settings.FixLineEndings));
+ CheckDlgButton(hwnd,IDC_AUTOSTRIPBLANKS, SetBtn(Settings.FixTrailingBlanks));
- CenterDlgInParent(hwnd, NULL);
- }
- return TRUE;
+ CenterDlgInParent(hwnd, NULL);
+ }
+ return TRUE;
- case WM_DPICHANGED:
- UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
- return TRUE;
+ case WM_DPICHANGED:
+ UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0);
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDOK: {
- int* piOption = (int*)GetWindowLongPtr(hwnd, DWLP_USER);
- *piOption = (int)SendDlgItemMessage(hwnd,IDC_EOLMODELIST,CB_GETCURSEL,0,0);
- Settings.WarnInconsistEOLs = IsButtonChecked(hwnd,IDC_WARN_INCONSISTENT_EOLS);
- Settings.FixLineEndings = IsButtonChecked(hwnd,IDC_CONSISTENT_EOLS);
- Settings.FixTrailingBlanks = IsButtonChecked(hwnd,IDC_AUTOSTRIPBLANKS);
- EndDialog(hwnd,IDOK);
- }
- break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDOK: {
+ int* piOption = (int*)GetWindowLongPtr(hwnd, DWLP_USER);
+ *piOption = (int)SendDlgItemMessage(hwnd,IDC_EOLMODELIST,CB_GETCURSEL,0,0);
+ Settings.WarnInconsistEOLs = IsButtonChecked(hwnd,IDC_WARN_INCONSISTENT_EOLS);
+ Settings.FixLineEndings = IsButtonChecked(hwnd,IDC_CONSISTENT_EOLS);
+ Settings.FixTrailingBlanks = IsButtonChecked(hwnd,IDC_AUTOSTRIPBLANKS);
+ EndDialog(hwnd,IDOK);
+ }
+ break;
- case IDCANCEL:
- EndDialog(hwnd,IDCANCEL);
- break;
- }
- return TRUE;
- }
- return FALSE;
+ case IDCANCEL:
+ EndDialog(hwnd,IDCANCEL);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -3955,13 +3955,13 @@ CASE_WM_CTLCOLOR_SET:
//
bool SelectDefLineEndingDlg(HWND hwnd, LPARAM piOption)
{
- INT_PTR const iResult = ThemedDialogBoxParam(Globals.hLngResContainer,
- MAKEINTRESOURCE(IDD_MUI_DEFEOLMODE),
- hwnd,
- SelectDefLineEndingDlgProc,
- piOption);
+ INT_PTR const iResult = ThemedDialogBoxParam(Globals.hLngResContainer,
+ MAKEINTRESOURCE(IDD_MUI_DEFEOLMODE),
+ hwnd,
+ SelectDefLineEndingDlgProc,
+ piOption);
- return (iResult == IDOK);
+ return (iResult == IDOK);
}
@@ -3973,97 +3973,97 @@ bool SelectDefLineEndingDlg(HWND hwnd, LPARAM piOption)
//
static INT_PTR CALLBACK WarnLineEndingDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ SetDialogIconNP3(hwnd);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- SetWindowTheme(GetDlgItem(hwnd, IDC_WARN_INCONSISTENT_EOLS), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ SetWindowTheme(GetDlgItem(hwnd, IDC_WARN_INCONSISTENT_EOLS), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
#endif
- const EditFileIOStatus* const fioStatus = (EditFileIOStatus*)lParam;
- int const iEOLMode = fioStatus->iEOLMode;
+ const EditFileIOStatus* const fioStatus = (EditFileIOStatus*)lParam;
+ int const iEOLMode = fioStatus->iEOLMode;
- // Load options
- WCHAR wch[128];
- for (int i = 0; i < 3; i++) {
- GetLngString(IDS_MUI_EOLMODENAME_CRLF + i, wch, COUNTOF(wch));
- SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_ADDSTRING, 0, (LPARAM)wch);
- }
+ // Load options
+ WCHAR wch[128];
+ for (int i = 0; i < 3; i++) {
+ GetLngString(IDS_MUI_EOLMODENAME_CRLF + i, wch, COUNTOF(wch));
+ SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_ADDSTRING, 0, (LPARAM)wch);
+ }
- SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_SETCURSEL, iEOLMode, 0);
- SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_SETEXTENDEDUI, TRUE, 0);
+ SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_SETCURSEL, iEOLMode, 0);
+ SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_SETEXTENDEDUI, TRUE, 0);
- WCHAR tchFmt[128];
- for (int i = 0; i < 3; ++i) {
- WCHAR tchLn[32];
- StringCchPrintf(tchLn, COUNTOF(tchLn), DOCPOSFMTW, fioStatus->eolCount[i]);
- FormatNumberStr(tchLn, COUNTOF(tchLn), 0);
- GetDlgItemText(hwnd, IDC_EOL_SUM_CRLF + i, tchFmt, COUNTOF(tchFmt));
- StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchLn);
- SetDlgItemText(hwnd, IDC_EOL_SUM_CRLF + i, wch);
- }
+ WCHAR tchFmt[128];
+ for (int i = 0; i < 3; ++i) {
+ WCHAR tchLn[32];
+ StringCchPrintf(tchLn, COUNTOF(tchLn), DOCPOSFMTW, fioStatus->eolCount[i]);
+ FormatNumberStr(tchLn, COUNTOF(tchLn), 0);
+ GetDlgItemText(hwnd, IDC_EOL_SUM_CRLF + i, tchFmt, COUNTOF(tchFmt));
+ StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchLn);
+ SetDlgItemText(hwnd, IDC_EOL_SUM_CRLF + i, wch);
+ }
- CheckDlgButton(hwnd, IDC_WARN_INCONSISTENT_EOLS, SetBtn(Settings.WarnInconsistEOLs));
- CenterDlgInParent(hwnd, NULL);
+ CheckDlgButton(hwnd, IDC_WARN_INCONSISTENT_EOLS, SetBtn(Settings.WarnInconsistEOLs));
+ CenterDlgInParent(hwnd, NULL);
- AttentionBeep(MB_ICONEXCLAMATION);
- }
- return TRUE;
+ AttentionBeep(MB_ICONEXCLAMATION);
+ }
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK:
- case IDCANCEL: {
- EditFileIOStatus* status = (EditFileIOStatus*)GetWindowLongPtr(hwnd, DWLP_USER);
- const int iEOLMode = (int)SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_GETCURSEL, 0, 0);
- status->iEOLMode = iEOLMode;
- Settings.WarnInconsistEOLs = IsButtonChecked(hwnd, IDC_WARN_INCONSISTENT_EOLS);
- EndDialog(hwnd, LOWORD(wParam));
- }
- break;
- }
- return TRUE;
- }
- return FALSE;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ case IDCANCEL: {
+ EditFileIOStatus* status = (EditFileIOStatus*)GetWindowLongPtr(hwnd, DWLP_USER);
+ const int iEOLMode = (int)SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_GETCURSEL, 0, 0);
+ status->iEOLMode = iEOLMode;
+ Settings.WarnInconsistEOLs = IsButtonChecked(hwnd, IDC_WARN_INCONSISTENT_EOLS);
+ EndDialog(hwnd, LOWORD(wParam));
+ }
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -4073,12 +4073,12 @@ CASE_WM_CTLCOLOR_SET:
//
bool WarnLineEndingDlg(HWND hwnd, EditFileIOStatus* fioStatus)
{
- const INT_PTR iResult = ThemedDialogBoxParam(Globals.hLngResContainer,
- MAKEINTRESOURCE(IDD_MUI_WARNLINEENDS),
- hwnd,
- WarnLineEndingDlgProc,
- (LPARAM)fioStatus);
- return (iResult == IDOK);
+ const INT_PTR iResult = ThemedDialogBoxParam(Globals.hLngResContainer,
+ MAKEINTRESOURCE(IDD_MUI_WARNLINEENDS),
+ hwnd,
+ WarnLineEndingDlgProc,
+ (LPARAM)fioStatus);
+ return (iResult == IDOK);
}
@@ -4089,134 +4089,134 @@ bool WarnLineEndingDlg(HWND hwnd, EditFileIOStatus* fioStatus)
//
static INT_PTR CALLBACK WarnIndentationDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- switch (umsg) {
- case WM_INITDIALOG: {
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
+ switch (umsg) {
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
- SetDialogIconNP3(hwnd);
- InitWindowCommon(hwnd, true);
+ SetDialogIconNP3(hwnd);
+ InitWindowCommon(hwnd, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hwnd, IDOK));
- SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { IDC_INDENT_BY_SPCS, IDC_INDENT_BY_TABS, IDC_WARN_INCONSISTENT_INDENTS,
- IDC_STATIC, IDC_STATIC2
- };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hwnd, IDOK));
+ SetExplorerTheme(GetDlgItem(hwnd, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { IDC_INDENT_BY_SPCS, IDC_INDENT_BY_TABS, IDC_WARN_INCONSISTENT_INDENTS,
+ IDC_STATIC, IDC_STATIC2
+ };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hwnd, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
+ }
+ }
#endif
- const EditFileIOStatus* const fioStatus = (EditFileIOStatus*)lParam;
+ const EditFileIOStatus* const fioStatus = (EditFileIOStatus*)lParam;
- WCHAR wch[128];
- WCHAR tchFmt[128];
- WCHAR tchCnt[64];
+ WCHAR wch[128];
+ WCHAR tchFmt[128];
+ WCHAR tchCnt[64];
- StringCchPrintf(tchCnt, COUNTOF(tchCnt), L"%i", Globals.fvCurFile.iTabWidth);
- FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
- GetDlgItemText(hwnd, IDC_INDENT_WIDTH_TAB, tchFmt, COUNTOF(tchFmt));
- StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
- SetDlgItemText(hwnd, IDC_INDENT_WIDTH_TAB, wch);
+ StringCchPrintf(tchCnt, COUNTOF(tchCnt), L"%i", Globals.fvCurFile.iTabWidth);
+ FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
+ GetDlgItemText(hwnd, IDC_INDENT_WIDTH_TAB, tchFmt, COUNTOF(tchFmt));
+ StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
+ SetDlgItemText(hwnd, IDC_INDENT_WIDTH_TAB, wch);
- StringCchPrintf(tchCnt, COUNTOF(tchCnt), L"%i", Globals.fvCurFile.iIndentWidth);
- FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
- GetDlgItemText(hwnd, IDC_INDENT_WIDTH_SPC, tchFmt, COUNTOF(tchFmt));
- StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
- SetDlgItemText(hwnd, IDC_INDENT_WIDTH_SPC, wch);
+ StringCchPrintf(tchCnt, COUNTOF(tchCnt), L"%i", Globals.fvCurFile.iIndentWidth);
+ FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
+ GetDlgItemText(hwnd, IDC_INDENT_WIDTH_SPC, tchFmt, COUNTOF(tchFmt));
+ StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
+ SetDlgItemText(hwnd, IDC_INDENT_WIDTH_SPC, wch);
- StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_TAB_LN]);
- FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
- GetDlgItemText(hwnd, IDC_INDENT_SUM_TAB, tchFmt, COUNTOF(tchFmt));
- StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
- SetDlgItemText(hwnd, IDC_INDENT_SUM_TAB, wch);
+ StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_TAB_LN]);
+ FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
+ GetDlgItemText(hwnd, IDC_INDENT_SUM_TAB, tchFmt, COUNTOF(tchFmt));
+ StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
+ SetDlgItemText(hwnd, IDC_INDENT_SUM_TAB, wch);
- StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_SPC_LN]);
- FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
- GetDlgItemText(hwnd, IDC_INDENT_SUM_SPC, tchFmt, COUNTOF(tchFmt));
- StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
- SetDlgItemText(hwnd, IDC_INDENT_SUM_SPC, wch);
+ StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_SPC_LN]);
+ FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
+ GetDlgItemText(hwnd, IDC_INDENT_SUM_SPC, tchFmt, COUNTOF(tchFmt));
+ StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
+ SetDlgItemText(hwnd, IDC_INDENT_SUM_SPC, wch);
- StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_MIX_LN]);
- FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
- GetDlgItemText(hwnd, IDC_INDENT_SUM_MIX, tchFmt, COUNTOF(tchFmt));
- StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
- SetDlgItemText(hwnd, IDC_INDENT_SUM_MIX, wch);
+ StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_MIX_LN]);
+ FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
+ GetDlgItemText(hwnd, IDC_INDENT_SUM_MIX, tchFmt, COUNTOF(tchFmt));
+ StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
+ SetDlgItemText(hwnd, IDC_INDENT_SUM_MIX, wch);
- StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_TAB_MOD_X]);
- FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
- GetDlgItemText(hwnd, IDC_INDENT_TAB_MODX, tchFmt, COUNTOF(tchFmt));
- StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
- SetDlgItemText(hwnd, IDC_INDENT_TAB_MODX, wch);
+ StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_TAB_MOD_X]);
+ FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
+ GetDlgItemText(hwnd, IDC_INDENT_TAB_MODX, tchFmt, COUNTOF(tchFmt));
+ StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
+ SetDlgItemText(hwnd, IDC_INDENT_TAB_MODX, wch);
- StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_SPC_MOD_X]);
- FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
- GetDlgItemText(hwnd, IDC_INDENT_SPC_MODX, tchFmt, COUNTOF(tchFmt));
- StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
- SetDlgItemText(hwnd, IDC_INDENT_SPC_MODX, wch);
+ StringCchPrintf(tchCnt, COUNTOF(tchCnt), DOCPOSFMTW, fioStatus->indentCount[I_SPC_MOD_X]);
+ FormatNumberStr(tchCnt, COUNTOF(tchCnt), 0);
+ GetDlgItemText(hwnd, IDC_INDENT_SPC_MODX, tchFmt, COUNTOF(tchFmt));
+ StringCchPrintf(wch, COUNTOF(wch), tchFmt, tchCnt);
+ SetDlgItemText(hwnd, IDC_INDENT_SPC_MODX, wch);
- CheckDlgButton(hwnd, Globals.fvCurFile.bTabsAsSpaces ? IDC_INDENT_BY_SPCS : IDC_INDENT_BY_TABS, true);
- CheckDlgButton(hwnd, IDC_WARN_INCONSISTENT_INDENTS, SetBtn(Settings.WarnInconsistentIndents));
- CenterDlgInParent(hwnd, NULL);
+ CheckDlgButton(hwnd, Globals.fvCurFile.bTabsAsSpaces ? IDC_INDENT_BY_SPCS : IDC_INDENT_BY_TABS, true);
+ CheckDlgButton(hwnd, IDC_WARN_INCONSISTENT_INDENTS, SetBtn(Settings.WarnInconsistentIndents));
+ CenterDlgInParent(hwnd, NULL);
- AttentionBeep(MB_ICONEXCLAMATION);
- }
- return TRUE;
+ AttentionBeep(MB_ICONEXCLAMATION);
+ }
+ return TRUE;
#ifdef D_NP3_WIN10_DARK_MODE
CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
- RefreshTitleBarThemeColor(hwnd);
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hwnd, darkModeEnabled);
+ RefreshTitleBarThemeColor(hwnd);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- UpdateWindowEx(hwnd);
- }
- break;
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hwnd, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ UpdateWindowEx(hwnd);
+ }
+ break;
#endif
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK: {
- EditFileIOStatus* fioStatus = (EditFileIOStatus*)GetWindowLongPtr(hwnd, DWLP_USER);
- fioStatus->iGlobalIndent = IsButtonChecked(hwnd, IDC_INDENT_BY_TABS) ? I_TAB_LN : I_SPC_LN;
- Settings.WarnInconsistentIndents = IsButtonChecked(hwnd, IDC_WARN_INCONSISTENT_INDENTS);
- EndDialog(hwnd, IDOK);
- }
- break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK: {
+ EditFileIOStatus* fioStatus = (EditFileIOStatus*)GetWindowLongPtr(hwnd, DWLP_USER);
+ fioStatus->iGlobalIndent = IsButtonChecked(hwnd, IDC_INDENT_BY_TABS) ? I_TAB_LN : I_SPC_LN;
+ Settings.WarnInconsistentIndents = IsButtonChecked(hwnd, IDC_WARN_INCONSISTENT_INDENTS);
+ EndDialog(hwnd, IDOK);
+ }
+ break;
- case IDCANCEL: {
- EditFileIOStatus* fioStatus = (EditFileIOStatus*)GetWindowLongPtr(hwnd, DWLP_USER);
- fioStatus->iGlobalIndent = I_MIX_LN;
- Settings.WarnInconsistentIndents = IsButtonChecked(hwnd, IDC_WARN_INCONSISTENT_INDENTS);
- EndDialog(hwnd, IDCANCEL);
- }
- break;
- }
- return TRUE;
- }
- return FALSE;
+ case IDCANCEL: {
+ EditFileIOStatus* fioStatus = (EditFileIOStatus*)GetWindowLongPtr(hwnd, DWLP_USER);
+ fioStatus->iGlobalIndent = I_MIX_LN;
+ Settings.WarnInconsistentIndents = IsButtonChecked(hwnd, IDC_WARN_INCONSISTENT_INDENTS);
+ EndDialog(hwnd, IDCANCEL);
+ }
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
@@ -4226,12 +4226,12 @@ CASE_WM_CTLCOLOR_SET:
//
bool WarnIndentationDlg(HWND hwnd, EditFileIOStatus* fioStatus)
{
- const INT_PTR iResult = ThemedDialogBoxParam(Globals.hLngResContainer,
- MAKEINTRESOURCE(IDD_MUI_WARNINDENTATION),
- hwnd,
- WarnIndentationDlgProc,
- (LPARAM)fioStatus);
- return (iResult == IDOK);
+ const INT_PTR iResult = ThemedDialogBoxParam(Globals.hLngResContainer,
+ MAKEINTRESOURCE(IDD_MUI_WARNINDENTATION),
+ hwnd,
+ WarnIndentationDlgProc,
+ (LPARAM)fioStatus);
+ return (iResult == IDOK);
}
@@ -4241,15 +4241,15 @@ bool WarnIndentationDlg(HWND hwnd, EditFileIOStatus* fioStatus)
//
//
void RelAdjustRectForDPI(LPRECT rc, const UINT oldDPI, const UINT newDPI) {
- float const scale = (float)newDPI / (float)(oldDPI != 0 ? oldDPI : 1);
- LONG const oldWidth = (rc->right - rc->left);
- LONG const oldHeight = (rc->bottom - rc->top);
- LONG const newWidth = lroundf((float)oldWidth * scale);
- LONG const newHeight = lroundf((float)oldHeight * scale);
- rc->left -= (newWidth - oldWidth) >> 1;
- rc->right = rc->left + newWidth;
- rc->top -= (newHeight - oldHeight) >> 1;
- rc->bottom = rc->top + newHeight;
+ float const scale = (float)newDPI / (float)(oldDPI != 0 ? oldDPI : 1);
+ LONG const oldWidth = (rc->right - rc->left);
+ LONG const oldHeight = (rc->bottom - rc->top);
+ LONG const newWidth = lroundf((float)oldWidth * scale);
+ LONG const newHeight = lroundf((float)oldHeight * scale);
+ rc->left -= (newWidth - oldWidth) >> 1;
+ rc->right = rc->left + newWidth;
+ rc->top -= (newHeight - oldHeight) >> 1;
+ rc->bottom = rc->top + newHeight;
}
@@ -4259,23 +4259,23 @@ void RelAdjustRectForDPI(LPRECT rc, const UINT oldDPI, const UINT newDPI) {
//
bool GetMonitorInfoFromRect(const LPRECT rc, MONITORINFO *hMonitorInfo) {
- bool result = false;
- if (hMonitorInfo) {
- HMONITOR const hMonitor = MonitorFromRect(rc, MONITOR_DEFAULTTONEAREST);
- ZeroMemory(hMonitorInfo, sizeof(MONITORINFO));
- hMonitorInfo->cbSize = sizeof(MONITORINFO);
- if (!GetMonitorInfo(hMonitor, hMonitorInfo)) {
- RECT _rc = { 0, 0, 0, 0 };
- if (SystemParametersInfo(SPI_GETWORKAREA, 0, &_rc, 0) != 0) {
- hMonitorInfo->rcWork = _rc;
- SetRect(&(hMonitorInfo->rcMonitor), 0, 0, _rc.right, _rc.bottom);
- result = true;
- }
- } else {
- result = true;
- }
- }
- return result;
+ bool result = false;
+ if (hMonitorInfo) {
+ HMONITOR const hMonitor = MonitorFromRect(rc, MONITOR_DEFAULTTONEAREST);
+ ZeroMemory(hMonitorInfo, sizeof(MONITORINFO));
+ hMonitorInfo->cbSize = sizeof(MONITORINFO);
+ if (!GetMonitorInfo(hMonitor, hMonitorInfo)) {
+ RECT _rc = { 0, 0, 0, 0 };
+ if (SystemParametersInfo(SPI_GETWORKAREA, 0, &_rc, 0) != 0) {
+ hMonitorInfo->rcWork = _rc;
+ SetRect(&(hMonitorInfo->rcMonitor), 0, 0, _rc.right, _rc.bottom);
+ result = true;
+ }
+ } else {
+ result = true;
+ }
+ }
+ return result;
}
// ----------------------------------------------------------------------------
@@ -4285,15 +4285,15 @@ bool GetMonitorInfoFromRect(const LPRECT rc, MONITORINFO *hMonitorInfo) {
// WinInfoToScreenCoord()
//
void WinInfoToScreenCoord(WININFO *pWinInfo) {
- if (pWinInfo) {
- MONITORINFO mi = { sizeof(MONITORINFO) };
- RECT rc = { 0 };
- RectFromWinInfo(pWinInfo, &rc);
- if (GetMonitorInfoFromRect(&rc, &mi)) {
- pWinInfo->x += (mi.rcWork.left - mi.rcMonitor.left);
- pWinInfo->y += (mi.rcWork.top - mi.rcMonitor.top);
- }
- }
+ if (pWinInfo) {
+ MONITORINFO mi = { sizeof(MONITORINFO) };
+ RECT rc = { 0 };
+ RectFromWinInfo(pWinInfo, &rc);
+ if (GetMonitorInfoFromRect(&rc, &mi)) {
+ pWinInfo->x += (mi.rcWork.left - mi.rcMonitor.left);
+ pWinInfo->y += (mi.rcWork.top - mi.rcMonitor.top);
+ }
+ }
}
@@ -4303,38 +4303,38 @@ void WinInfoToScreenCoord(WININFO *pWinInfo) {
//
bool GetWindowRectEx(HWND hwnd, LPRECT pRect) {
- bool bMainWndTray = false;
- if (Globals.hwndMain == hwnd) {
- bMainWndTray = Settings.MinimizeToTray && Globals.bMinimizedToTray;
- }
- bool const res = bMainWndTray ? GetTrayWndRect(pRect) : GetWindowRect(hwnd, pRect);
+ bool bMainWndTray = false;
+ if (Globals.hwndMain == hwnd) {
+ bMainWndTray = Settings.MinimizeToTray && Globals.bMinimizedToTray;
+ }
+ bool const res = bMainWndTray ? GetTrayWndRect(pRect) : GetWindowRect(hwnd, pRect);
- WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
- GetWindowPlacement(hwnd, &wndpl);
+ WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
+ GetWindowPlacement(hwnd, &wndpl);
- switch (wndpl.showCmd) {
- case SW_HIDE:
- case SW_SHOWMINIMIZED:
- if (res) {
- POINT pt = { 0 };
- GetCursorPos(&pt);
- pRect->left = pRect->right = pt.x;
- pRect->top = pRect->bottom = pt.y;
- return res;
- }
- break;
+ switch (wndpl.showCmd) {
+ case SW_HIDE:
+ case SW_SHOWMINIMIZED:
+ if (res) {
+ POINT pt = { 0 };
+ GetCursorPos(&pt);
+ pRect->left = pRect->right = pt.x;
+ pRect->top = pRect->bottom = pt.y;
+ return res;
+ }
+ break;
- case SW_SHOWMAXIMIZED:
- case SW_MAX: {
- MONITORINFO mi = { sizeof(MONITORINFO) };
- GetMonitorInfoFromRect(pRect, &mi);
- *pRect = mi.rcWork;
- } break;
+ case SW_SHOWMAXIMIZED:
+ case SW_MAX: {
+ MONITORINFO mi = { sizeof(MONITORINFO) };
+ GetMonitorInfoFromRect(pRect, &mi);
+ *pRect = mi.rcWork;
+ } break;
- default:
- break;
- }
- return res;
+ default:
+ break;
+ }
+ return res;
}
@@ -4344,60 +4344,60 @@ bool GetWindowRectEx(HWND hwnd, LPRECT pRect) {
//
void FitIntoMonitorGeometry(LPRECT pRect, WININFO *pWinInfo, SCREEN_MODE mode, bool bTopLeft) {
- MONITORINFO mi = { sizeof(MONITORINFO) };
- GetMonitorInfoFromRect(pRect, &mi);
+ MONITORINFO mi = { sizeof(MONITORINFO) };
+ GetMonitorInfoFromRect(pRect, &mi);
- if (mode == SCR_FULL_SCREEN) {
- SetRect(pRect, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom);
- // monitor coord -> screen coord
- pWinInfo->x = mi.rcMonitor.left - (mi.rcWork.left - mi.rcMonitor.left);
- pWinInfo->y = mi.rcMonitor.top - (mi.rcWork.top - mi.rcMonitor.top);
- pWinInfo->cx = (mi.rcMonitor.right - mi.rcMonitor.left);
- pWinInfo->cy = (mi.rcMonitor.bottom - mi.rcMonitor.top);
- pWinInfo->max = true;
- //~pWinInfo->dpi = Scintilla_GetWindowDPI(hwnd); // don't change
- } else {
- WININFO wi = *pWinInfo;
- WinInfoToScreenCoord(&wi);
- // fit into area
- if (wi.x < mi.rcWork.left) {
- wi.x = mi.rcWork.left;
- }
- if (wi.y < mi.rcWork.top) {
- wi.y = mi.rcWork.top;
- }
- if (bTopLeft && (((wi.x + wi.cx) > mi.rcWork.right) ||
- ((wi.y + wi.cy) > mi.rcWork.bottom))) {
- wi.y = mi.rcWork.top;
- wi.x = mi.rcWork.left;
- } else {
- if ((wi.x + wi.cx) > mi.rcWork.right) {
- wi.x -= (wi.x + wi.cx - mi.rcWork.right);
- if (wi.x < mi.rcWork.left) {
- wi.x = mi.rcWork.left;
- }
- if ((wi.x + wi.cx) > mi.rcWork.right) {
- wi.cx = mi.rcWork.right - wi.x;
- }
- }
- if ((wi.y + wi.cy) > mi.rcWork.bottom) {
- wi.y -= (wi.y + wi.cy - mi.rcWork.bottom);
- if (wi.y < mi.rcWork.top) {
- wi.y = mi.rcWork.top;
- }
- if ((wi.y + wi.cy) > mi.rcWork.bottom) {
- wi.cy = mi.rcWork.bottom - wi.y;
- }
- }
- }
- RectFromWinInfo(&wi, pRect);
- // screen coord -> work area coord
- pWinInfo->x = wi.x - (mi.rcWork.left - mi.rcMonitor.left);
- pWinInfo->y = wi.y - (mi.rcWork.top - mi.rcMonitor.top);
- pWinInfo->cx = wi.cx;
- pWinInfo->cy = wi.cy;
- //~pWinInfo->dpi = Scintilla_GetWindowDPI(hwnd); // don't change
- }
+ if (mode == SCR_FULL_SCREEN) {
+ SetRect(pRect, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom);
+ // monitor coord -> screen coord
+ pWinInfo->x = mi.rcMonitor.left - (mi.rcWork.left - mi.rcMonitor.left);
+ pWinInfo->y = mi.rcMonitor.top - (mi.rcWork.top - mi.rcMonitor.top);
+ pWinInfo->cx = (mi.rcMonitor.right - mi.rcMonitor.left);
+ pWinInfo->cy = (mi.rcMonitor.bottom - mi.rcMonitor.top);
+ pWinInfo->max = true;
+ //~pWinInfo->dpi = Scintilla_GetWindowDPI(hwnd); // don't change
+ } else {
+ WININFO wi = *pWinInfo;
+ WinInfoToScreenCoord(&wi);
+ // fit into area
+ if (wi.x < mi.rcWork.left) {
+ wi.x = mi.rcWork.left;
+ }
+ if (wi.y < mi.rcWork.top) {
+ wi.y = mi.rcWork.top;
+ }
+ if (bTopLeft && (((wi.x + wi.cx) > mi.rcWork.right) ||
+ ((wi.y + wi.cy) > mi.rcWork.bottom))) {
+ wi.y = mi.rcWork.top;
+ wi.x = mi.rcWork.left;
+ } else {
+ if ((wi.x + wi.cx) > mi.rcWork.right) {
+ wi.x -= (wi.x + wi.cx - mi.rcWork.right);
+ if (wi.x < mi.rcWork.left) {
+ wi.x = mi.rcWork.left;
+ }
+ if ((wi.x + wi.cx) > mi.rcWork.right) {
+ wi.cx = mi.rcWork.right - wi.x;
+ }
+ }
+ if ((wi.y + wi.cy) > mi.rcWork.bottom) {
+ wi.y -= (wi.y + wi.cy - mi.rcWork.bottom);
+ if (wi.y < mi.rcWork.top) {
+ wi.y = mi.rcWork.top;
+ }
+ if ((wi.y + wi.cy) > mi.rcWork.bottom) {
+ wi.cy = mi.rcWork.bottom - wi.y;
+ }
+ }
+ }
+ RectFromWinInfo(&wi, pRect);
+ // screen coord -> work area coord
+ pWinInfo->x = wi.x - (mi.rcWork.left - mi.rcMonitor.left);
+ pWinInfo->y = wi.y - (mi.rcWork.top - mi.rcMonitor.top);
+ pWinInfo->cx = wi.cx;
+ pWinInfo->cy = wi.cy;
+ //~pWinInfo->dpi = Scintilla_GetWindowDPI(hwnd); // don't change
+ }
}
// ----------------------------------------------------------------------------
@@ -4407,50 +4407,50 @@ void FitIntoMonitorGeometry(LPRECT pRect, WININFO *pWinInfo, SCREEN_MODE mode, b
// GetMyWindowPlacement()
//
WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int offset) {
- RECT rc;
- GetWindowRect(hwnd, &rc);
+ RECT rc;
+ GetWindowRect(hwnd, &rc);
- MONITORINFO mi = { sizeof(MONITORINFO) };
- GetMonitorInfoFromRect(&rc, &mi);
+ MONITORINFO mi = { sizeof(MONITORINFO) };
+ GetMonitorInfoFromRect(&rc, &mi);
- // set monitor info
- if (hMonitorInfo) {
- if (hMonitorInfo->cbSize == mi.cbSize) {
- *hMonitorInfo = mi;
- } else {
- GetMonitorInfoFromRect(&rc, hMonitorInfo);
- }
- }
+ // set monitor info
+ if (hMonitorInfo) {
+ if (hMonitorInfo->cbSize == mi.cbSize) {
+ *hMonitorInfo = mi;
+ } else {
+ GetMonitorInfoFromRect(&rc, hMonitorInfo);
+ }
+ }
- WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
- GetWindowPlacement(hwnd, &wndpl);
+ WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
+ GetWindowPlacement(hwnd, &wndpl);
- // corrections in case of aero snapped position
- if (SW_SHOWNORMAL == wndpl.showCmd) {
- LONG const width = rc.right - rc.left;
- LONG const height = rc.bottom - rc.top;
- rc.left -= (mi.rcWork.left - mi.rcMonitor.left);
- rc.right = rc.left + width;
- rc.top -= (mi.rcWork.top - mi.rcMonitor.top);
- rc.bottom = rc.top + height;
- wndpl.rcNormalPosition = rc;
- }
+ // corrections in case of aero snapped position
+ if (SW_SHOWNORMAL == wndpl.showCmd) {
+ LONG const width = rc.right - rc.left;
+ LONG const height = rc.bottom - rc.top;
+ rc.left -= (mi.rcWork.left - mi.rcMonitor.left);
+ rc.right = rc.left + width;
+ rc.top -= (mi.rcWork.top - mi.rcMonitor.top);
+ rc.bottom = rc.top + height;
+ wndpl.rcNormalPosition = rc;
+ }
- WININFO wi = { 0 };
- wi.x = wndpl.rcNormalPosition.left + offset;
- wi.y = wndpl.rcNormalPosition.top + offset;
- wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
- wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
- wi.max = (hwnd ? IsZoomed(hwnd) : false) || (wndpl.flags & WPF_RESTORETOMAXIMIZED);
- wi.zoom = hwnd ? SciCall_GetZoom() : 100;
- wi.dpi = Scintilla_GetWindowDPI(hwnd);
+ WININFO wi = { 0 };
+ wi.x = wndpl.rcNormalPosition.left + offset;
+ wi.y = wndpl.rcNormalPosition.top + offset;
+ wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
+ wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
+ wi.max = (hwnd ? IsZoomed(hwnd) : false) || (wndpl.flags & WPF_RESTORETOMAXIMIZED);
+ wi.zoom = hwnd ? SciCall_GetZoom() : 100;
+ wi.dpi = Scintilla_GetWindowDPI(hwnd);
- if (Settings2.LaunchInstanceFullVisible) {
- RECT rci;
- RectFromWinInfo(&wi, &rci);
- FitIntoMonitorGeometry(&rci, &wi, SCR_NORMAL, true);
- }
- return wi;
+ if (Settings2.LaunchInstanceFullVisible) {
+ RECT rci;
+ RectFromWinInfo(&wi, &rci);
+ FitIntoMonitorGeometry(&rci, &wi, SCR_NORMAL, true);
+ }
+ return wi;
}
@@ -4461,34 +4461,34 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int off
//
WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo, SCREEN_MODE mode)
{
- WINDOWPLACEMENT wndpl = {0};
- wndpl.length = sizeof(WINDOWPLACEMENT);
- wndpl.flags = WPF_ASYNCWINDOWPLACEMENT;
+ WINDOWPLACEMENT wndpl = {0};
+ wndpl.length = sizeof(WINDOWPLACEMENT);
+ wndpl.flags = WPF_ASYNCWINDOWPLACEMENT;
- WININFO winfo = INIT_WININFO;
- if (pWinInfo) {
- RECT rc = { 0 };
- RectFromWinInfo(pWinInfo, &rc);
+ WININFO winfo = INIT_WININFO;
+ if (pWinInfo) {
+ RECT rc = { 0 };
+ RectFromWinInfo(pWinInfo, &rc);
- winfo = *pWinInfo;
- FitIntoMonitorGeometry(&rc, &winfo, mode, false);
- if (pWinInfo->max) {
- wndpl.flags &= WPF_RESTORETOMAXIMIZED;
- }
- wndpl.showCmd = SW_RESTORE;
- } else {
- RECT rc = {0};
- if (hwnd) {
- GetWindowRect(hwnd, &rc);
- } else {
- GetWindowRect(GetDesktopWindow(), &rc);
- }
- FitIntoMonitorGeometry(&rc, &winfo, mode, false);
+ winfo = *pWinInfo;
+ FitIntoMonitorGeometry(&rc, &winfo, mode, false);
+ if (pWinInfo->max) {
+ wndpl.flags &= WPF_RESTORETOMAXIMIZED;
+ }
+ wndpl.showCmd = SW_RESTORE;
+ } else {
+ RECT rc = {0};
+ if (hwnd) {
+ GetWindowRect(hwnd, &rc);
+ } else {
+ GetWindowRect(GetDesktopWindow(), &rc);
+ }
+ FitIntoMonitorGeometry(&rc, &winfo, mode, false);
- wndpl.showCmd = SW_SHOW;
- }
- RectFromWinInfo(&winfo, &(wndpl.rcNormalPosition));
- return wndpl;
+ wndpl.showCmd = SW_SHOW;
+ }
+ RectFromWinInfo(&winfo, &(wndpl.rcNormalPosition));
+ return wndpl;
}
@@ -4499,55 +4499,55 @@ WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo, SCRE
//
void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, LPCWSTR lpcwFilePath, WININFO* wi) {
- if (bSaveOnRunTools && !FileSave(false, true, false, false, Flags.bPreserveFileModTime)) {
- return;
- }
+ if (bSaveOnRunTools && !FileSave(false, true, false, false, Flags.bPreserveFileModTime)) {
+ return;
+ }
- WCHAR szModuleName[MAX_PATH] = { L'\0' };
- GetModuleFileName(NULL, szModuleName, COUNTOF(szModuleName));
- PathCanonicalizeEx(szModuleName, COUNTOF(szModuleName));
+ WCHAR szModuleName[MAX_PATH] = { L'\0' };
+ GetModuleFileName(NULL, szModuleName, COUNTOF(szModuleName));
+ PathCanonicalizeEx(szModuleName, COUNTOF(szModuleName));
- WCHAR tch[64] = { L'\0' };
- WCHAR szParameters[2 * MAX_PATH + 64] = { L'\0' };
- StringCchPrintf(tch, COUNTOF(tch), L"\"-appid=%s\"", Settings2.AppUserModelID);
- StringCchCopy(szParameters, COUNTOF(szParameters), tch);
+ WCHAR tch[64] = { L'\0' };
+ WCHAR szParameters[2 * MAX_PATH + 64] = { L'\0' };
+ StringCchPrintf(tch, COUNTOF(tch), L"\"-appid=%s\"", Settings2.AppUserModelID);
+ StringCchCopy(szParameters, COUNTOF(szParameters), tch);
- StringCchPrintf(tch, COUNTOF(tch), L"\" -sysmru=%i\"", (Flags.ShellUseSystemMRU ? 1 : 0));
- StringCchCat(szParameters, COUNTOF(szParameters), tch);
+ StringCchPrintf(tch, COUNTOF(tch), L"\" -sysmru=%i\"", (Flags.ShellUseSystemMRU ? 1 : 0));
+ StringCchCat(szParameters, COUNTOF(szParameters), tch);
- StringCchCat(szParameters, COUNTOF(szParameters), L" -f");
- if (Path_IsNotEmpty(Paths.IniFile)) {
- StringCchCat(szParameters, COUNTOF(szParameters), L" \"");
- StringCchCat(szParameters, COUNTOF(szParameters), Path_Get(Paths.IniFile)); //TODO: §§§ MAX_PATH limit §§§ @@@!
- StringCchCat(szParameters, COUNTOF(szParameters), L"\"");
- } else {
- StringCchCat(szParameters, COUNTOF(szParameters), L"0");
- }
- StringCchCat(szParameters, COUNTOF(szParameters), Flags.bSingleFileInstance ? L" -ns" : L" -n");
+ StringCchCat(szParameters, COUNTOF(szParameters), L" -f");
+ if (Path_IsNotEmpty(Paths.IniFile)) {
+ StringCchCat(szParameters, COUNTOF(szParameters), L" \"");
+ StringCchCat(szParameters, COUNTOF(szParameters), Path_Get(Paths.IniFile)); //TODO: §§§ MAX_PATH limit §§§ @@@!
+ StringCchCat(szParameters, COUNTOF(szParameters), L"\"");
+ } else {
+ StringCchCat(szParameters, COUNTOF(szParameters), L"0");
+ }
+ StringCchCat(szParameters, COUNTOF(szParameters), Flags.bSingleFileInstance ? L" -ns" : L" -n");
- WININFO const _wi = (Flags.bStickyWindowPosition ? g_IniWinInfo :
- (wi ? *wi : GetMyWindowPlacement(hwnd, NULL, Settings2.LaunchInstanceWndPosOffset)));
+ WININFO const _wi = (Flags.bStickyWindowPosition ? g_IniWinInfo :
+ (wi ? *wi : GetMyWindowPlacement(hwnd, NULL, Settings2.LaunchInstanceWndPosOffset)));
- StringCchPrintf(tch, COUNTOF(tch), L" -pos %i,%i,%i,%i,%i", _wi.x, _wi.y, _wi.cx, _wi.cy, _wi.max);
- StringCchCat(szParameters, COUNTOF(szParameters), tch);
+ StringCchPrintf(tch, COUNTOF(tch), L" -pos %i,%i,%i,%i,%i", _wi.x, _wi.y, _wi.cx, _wi.cy, _wi.max);
+ StringCchCat(szParameters, COUNTOF(szParameters), tch);
- if (StrIsNotEmpty(lpcwFilePath)) {
- WCHAR szFileName[MAX_PATH] = { L'\0' };
- StringCchCopy(szFileName, COUNTOF(szFileName), lpcwFilePath);
- PathQuoteSpaces(szFileName);
- StringCchCat(szParameters, COUNTOF(szParameters), L" ");
- StringCchCat(szParameters, COUNTOF(szParameters), szFileName);
- }
+ if (StrIsNotEmpty(lpcwFilePath)) {
+ WCHAR szFileName[MAX_PATH] = { L'\0' };
+ StringCchCopy(szFileName, COUNTOF(szFileName), lpcwFilePath);
+ PathQuoteSpaces(szFileName);
+ StringCchCat(szParameters, COUNTOF(szParameters), L" ");
+ StringCchCat(szParameters, COUNTOF(szParameters), szFileName);
+ }
- SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
- sei.fMask = SEE_MASK_NOASYNC | SEE_MASK_NOZONECHECKS;
- sei.hwnd = hwnd;
- sei.lpVerb = NULL;
- sei.lpFile = szModuleName;
- sei.lpParameters = szParameters;
- sei.lpDirectory = Path_Get(Paths.WorkingDirectory);
- sei.nShow = SW_SHOWNORMAL;
- ShellExecuteEx(&sei);
+ SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
+ sei.fMask = SEE_MASK_NOASYNC | SEE_MASK_NOZONECHECKS;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = szModuleName;
+ sei.lpParameters = szParameters;
+ sei.lpDirectory = Path_Get(Paths.WorkingDirectory);
+ sei.nShow = SW_SHOWNORMAL;
+ ShellExecuteEx(&sei);
}
@@ -4558,68 +4558,68 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, LPCWSTR lpcwFilePath, WINI
//
void DialogFileBrowse(HWND hwnd)
{
- wchar_t* const param_buf = AllocMem((PATHLONG_MAX_CCH + 1) * sizeof(wchar_t), HEAP_ZERO_MEMORY);
- if (!param_buf) {
- return;
- }
+ wchar_t* const param_buf = AllocMem((PATHLONG_MAX_CCH + 1) * sizeof(wchar_t), HEAP_ZERO_MEMORY);
+ if (!param_buf) {
+ return;
+ }
- HPATHL hExeFile = Path_Allocate(NULL);
- wchar_t* const pth_buf = Path_WriteAccessBuf(hExeFile, PATHLONG_MAX_CCH);
+ HPATHL hExeFile = Path_Allocate(NULL);
+ wchar_t* const pth_buf = Path_WriteAccessBuf(hExeFile, PATHLONG_MAX_CCH);
- if (StrIsNotEmpty(Settings2.FileBrowserPath)) {
- ExtractFirstArgument(Settings2.FileBrowserPath, pth_buf, param_buf, PATHLONG_MAX_CCH);
- Path_ExpandEnvStrings(hExeFile);
- }
- Path_Sanitize(hExeFile);
+ if (StrIsNotEmpty(Settings2.FileBrowserPath)) {
+ ExtractFirstArgument(Settings2.FileBrowserPath, pth_buf, param_buf, PATHLONG_MAX_CCH);
+ Path_ExpandEnvStrings(hExeFile);
+ }
+ Path_Sanitize(hExeFile);
- if (StrStrIW(Path_Get(hExeFile), L"explorer.exe") && StrIsEmpty(param_buf)) {
- SendWMCommand(hwnd, IDM_FILE_EXPLORE_DIR);
- Path_Release(hExeFile);
- FreeMem(param_buf);
- return;
- }
+ if (StrStrIW(Path_Get(hExeFile), L"explorer.exe") && StrIsEmpty(param_buf)) {
+ SendWMCommand(hwnd, IDM_FILE_EXPLORE_DIR);
+ Path_Release(hExeFile);
+ FreeMem(param_buf);
+ return;
+ }
- if (Path_IsEmpty(hExeFile)) {
- Path_Reset(hExeFile, Constants.FileBrowserMiniPath);
- }
+ if (Path_IsEmpty(hExeFile)) {
+ Path_Reset(hExeFile, Constants.FileBrowserMiniPath);
+ }
- if (Path_IsRelative(hExeFile)) {
- HPATHL hTemp = Path_Allocate(NULL);
- Path_GetAppDirectory(hTemp);
- Path_Append(hTemp, hExeFile);
- if (Path_IsExistingFile(hTemp)) {
- Path_Swap(hExeFile, hTemp);
- }
- Path_Release(hTemp);
- }
+ if (Path_IsRelative(hExeFile)) {
+ HPATHL hTemp = Path_Allocate(NULL);
+ Path_GetAppDirectory(hTemp);
+ Path_Append(hTemp, hExeFile);
+ if (Path_IsExistingFile(hTemp)) {
+ Path_Swap(hExeFile, hTemp);
+ }
+ Path_Release(hTemp);
+ }
- if (StrIsNotEmpty(param_buf) && Path_IsNotEmpty(Paths.CurrentFile)) {
- StringCchCat(param_buf, PATHLONG_MAX_CCH, L" ");
- }
+ if (StrIsNotEmpty(param_buf) && Path_IsNotEmpty(Paths.CurrentFile)) {
+ StringCchCat(param_buf, PATHLONG_MAX_CCH, L" ");
+ }
- if (Path_IsNotEmpty(Paths.CurrentFile)) {
- HPATHL pthTmp = Path_Copy(Paths.CurrentFile);
- Path_QuoteSpaces(pthTmp);
- StringCchCat(param_buf, PATHLONG_MAX_CCH, Path_Get(pthTmp));
- Path_Release(pthTmp);
- }
+ if (Path_IsNotEmpty(Paths.CurrentFile)) {
+ HPATHL pthTmp = Path_Copy(Paths.CurrentFile);
+ Path_QuoteSpaces(pthTmp);
+ StringCchCat(param_buf, PATHLONG_MAX_CCH, Path_Get(pthTmp));
+ Path_Release(pthTmp);
+ }
- SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
- sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOZONECHECKS;
- sei.hwnd = hwnd;
- sei.lpVerb = NULL;
- sei.lpFile = Path_Get(hExeFile);
- sei.lpParameters = param_buf;
- sei.lpDirectory = NULL;
- sei.nShow = SW_SHOWNORMAL;
- ShellExecuteEx(&sei);
+ SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
+ sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOZONECHECKS;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = Path_Get(hExeFile);
+ sei.lpParameters = param_buf;
+ sei.lpDirectory = NULL;
+ sei.nShow = SW_SHOWNORMAL;
+ ShellExecuteEx(&sei);
- if ((INT_PTR)sei.hInstApp < 32) {
- InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BROWSE);
- }
+ if ((INT_PTR)sei.hInstApp < 32) {
+ InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BROWSE);
+ }
- Path_Release(hExeFile);
- FreeMem(param_buf);
+ Path_Release(hExeFile);
+ FreeMem(param_buf);
}
@@ -4630,25 +4630,25 @@ void DialogFileBrowse(HWND hwnd)
//
typedef struct _grepwin_ini {
- const WCHAR* const key;
- const WCHAR* const val;
+ const WCHAR* const key;
+ const WCHAR* const val;
}
grepWin_t;
static grepWin_t grepWinIniSettings[13] = {
- { L"onlyone", L"1" },
- { L"AllSize", L"1" },
- { L"Size", L"2000" },
- { L"CaseSensitive", L"0" },
- { L"CreateBackup", L"1" },
- { L"DateLimit", L"0" },
- { L"IncludeBinary", L"0" },
- { L"IncludeHidden", L"1" },
- { L"IncludeSubfolders", L"1" },
- { L"IncludeSystem", L"1" },
- { L"UseFileMatchRegex", L"0" },
- { L"UseRegex", L"0" },
- { L"UTF8", L"1" }
+ { L"onlyone", L"1" },
+ { L"AllSize", L"1" },
+ { L"Size", L"2000" },
+ { L"CaseSensitive", L"0" },
+ { L"CreateBackup", L"1" },
+ { L"DateLimit", L"0" },
+ { L"IncludeBinary", L"0" },
+ { L"IncludeHidden", L"1" },
+ { L"IncludeSubfolders", L"1" },
+ { L"IncludeSystem", L"1" },
+ { L"UseFileMatchRegex", L"0" },
+ { L"UseRegex", L"0" },
+ { L"UTF8", L"1" }
};
//=============================================================================
@@ -4658,169 +4658,169 @@ static grepWin_t grepWinIniSettings[13] = {
//
void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern)
{
- WCHAR tchTemp[MAX_PATH] = { L'\0' };
- WCHAR tchExeFile[MAX_PATH] = { L'\0' };
- WCHAR tchOptions[MAX_PATH] = { L'\0' };
+ WCHAR tchTemp[MAX_PATH] = { L'\0' };
+ WCHAR tchExeFile[MAX_PATH] = { L'\0' };
+ WCHAR tchOptions[MAX_PATH] = { L'\0' };
- HPATHL hNotepad3Path = Path_Allocate(NULL);
- Path_GetModuleFilePath(hNotepad3Path);
- //Path_CanonicalizeEx(hNotepad3Path);
- HPATHL hgrepwin_ini_pth = Path_Copy(Paths.IniFile);
+ HPATHL hNotepad3Path = Path_Allocate(NULL);
+ Path_GetModuleFilePath(hNotepad3Path);
+ //Path_CanonicalizeEx(hNotepad3Path);
+ HPATHL hgrepwin_ini_pth = Path_Copy(Paths.IniFile);
- // find grepWin executable (side-by-side .ini file)
- if (StrIsNotEmpty(Settings2.GrepWinPath)) {
- ExtractFirstArgument(Settings2.GrepWinPath, tchExeFile, tchOptions, COUNTOF(tchExeFile));
- ExpandEnvironmentStringsEx(tchExeFile, COUNTOF(tchExeFile));
- }
- if (StrIsEmpty(tchExeFile)) {
- StringCchCopy(tchExeFile, COUNTOF(tchExeFile), Constants.FileSearchGrepWin);
- }
- if (PathIsRelative(tchExeFile)) {
- StringCchCopy(tchTemp, COUNTOF(tchTemp), Path_Get(hNotepad3Path));
- PathRemoveFileSpec(tchTemp);
- PathAppend(tchTemp, tchExeFile);
- if (PathIsExistingFile(tchTemp)) {
- StringCchCopy(tchExeFile, COUNTOF(tchExeFile), tchTemp);
- }
- }
+ // find grepWin executable (side-by-side .ini file)
+ if (StrIsNotEmpty(Settings2.GrepWinPath)) {
+ ExtractFirstArgument(Settings2.GrepWinPath, tchExeFile, tchOptions, COUNTOF(tchExeFile));
+ ExpandEnvironmentStringsEx(tchExeFile, COUNTOF(tchExeFile));
+ }
+ if (StrIsEmpty(tchExeFile)) {
+ StringCchCopy(tchExeFile, COUNTOF(tchExeFile), Constants.FileSearchGrepWin);
+ }
+ if (PathIsRelative(tchExeFile)) {
+ StringCchCopy(tchTemp, COUNTOF(tchTemp), Path_Get(hNotepad3Path));
+ PathRemoveFileSpec(tchTemp);
+ PathAppend(tchTemp, tchExeFile);
+ if (PathIsExistingFile(tchTemp)) {
+ StringCchCopy(tchExeFile, COUNTOF(tchExeFile), tchTemp);
+ }
+ }
- // working (grepWinNP3.ini) directory
- HPATHL hTemp = Path_Allocate(NULL);
- HPATHL hGrepWinDir = Path_Allocate(tchExeFile);
- Path_RemoveFileSpec(hGrepWinDir);
+ // working (grepWinNP3.ini) directory
+ HPATHL hTemp = Path_Allocate(NULL);
+ HPATHL hGrepWinDir = Path_Allocate(tchExeFile);
+ Path_RemoveFileSpec(hGrepWinDir);
- if (PathIsExistingFile(tchExeFile)) {
+ if (PathIsExistingFile(tchExeFile)) {
- // relative Notepad3 path (for grepWin's EditorCmd)
- if (Path_RelativePathTo(hTemp, hGrepWinDir, FILE_ATTRIBUTE_DIRECTORY, hNotepad3Path, FILE_ATTRIBUTE_NORMAL)) {
- Path_Swap(hNotepad3Path, hTemp);
- }
+ // relative Notepad3 path (for grepWin's EditorCmd)
+ if (Path_RelativePathTo(hTemp, hGrepWinDir, FILE_ATTRIBUTE_DIRECTORY, hNotepad3Path, FILE_ATTRIBUTE_NORMAL)) {
+ Path_Swap(hNotepad3Path, hTemp);
+ }
- // grepWin INI-File
- HPATHL hIniFileName = Path_Allocate(L"grepWinNP3.ini");
- if (Path_IsEmpty(hgrepwin_ini_pth)) {
- Path_Reset(hgrepwin_ini_pth, Path_Get(Paths.IniFileDefault));
- }
- Path_RemoveFileSpec(hgrepwin_ini_pth);
- Path_Append(hgrepwin_ini_pth, hIniFileName);
+ // grepWin INI-File
+ HPATHL hIniFileName = Path_Allocate(L"grepWinNP3.ini");
+ if (Path_IsEmpty(hgrepwin_ini_pth)) {
+ Path_Reset(hgrepwin_ini_pth, Path_Get(Paths.IniFileDefault));
+ }
+ Path_RemoveFileSpec(hgrepwin_ini_pth);
+ Path_Append(hgrepwin_ini_pth, hIniFileName);
- if (Path_IsRelative(hgrepwin_ini_pth)) {
- Path_Reset(hgrepwin_ini_pth, Path_Get(hGrepWinDir));
- Path_Append(hgrepwin_ini_pth, hIniFileName);
- }
+ if (Path_IsRelative(hgrepwin_ini_pth)) {
+ Path_Reset(hgrepwin_ini_pth, Path_Get(hGrepWinDir));
+ Path_Append(hgrepwin_ini_pth, hIniFileName);
+ }
- ResetIniFileCache();
- if (CreateIniFile(hgrepwin_ini_pth, NULL) && LoadIniFileCache(Path_Get(hgrepwin_ini_pth))) {
- // preserve [global] user settings from last call
- const WCHAR* const globalSection = L"global";
+ ResetIniFileCache();
+ if (CreateIniFile(hgrepwin_ini_pth, NULL) && LoadIniFileCache(Path_Get(hgrepwin_ini_pth))) {
+ // preserve [global] user settings from last call
+ const WCHAR* const globalSection = L"global";
- WCHAR value[HUGE_BUFFER];
- for (int i = 0; i < COUNTOF(grepWinIniSettings); ++i) {
- IniSectionGetString(globalSection, grepWinIniSettings[i].key, grepWinIniSettings[i].val, value, COUNTOF(value));
- IniSectionSetString(globalSection, grepWinIniSettings[i].key, value);
- }
+ WCHAR value[HUGE_BUFFER];
+ for (int i = 0; i < COUNTOF(grepWinIniSettings); ++i) {
+ IniSectionGetString(globalSection, grepWinIniSettings[i].key, grepWinIniSettings[i].val, value, COUNTOF(value));
+ IniSectionSetString(globalSection, grepWinIniSettings[i].key, value);
+ }
- // get grepWin language
- int lngIdx = -1;
- for (unsigned i = 0; i < grepWinLang_CountOf(); ++i) {
- if (IsSameLocale(grepWinLangResName[i].localename, Globals.CurrentLngLocaleName)) {
- lngIdx = i;
- break;
- }
- }
- if (lngIdx >= 0) {
- IniSectionGetString(globalSection, L"languagefile", grepWinLangResName[lngIdx].filename, tchTemp, COUNTOF(tchTemp));
- IniSectionSetString(globalSection, L"languagefile", tchTemp);
- } else {
- IniSectionGetString(globalSection, L"languagefile", L"", tchTemp, COUNTOF(tchTemp));
- if (StrIsEmpty(tchTemp)) {
- IniSectionDelete(globalSection, L"languagefile", false);
- }
- }
+ // get grepWin language
+ int lngIdx = -1;
+ for (unsigned i = 0; i < grepWinLang_CountOf(); ++i) {
+ if (IsSameLocale(grepWinLangResName[i].localename, Globals.CurrentLngLocaleName)) {
+ lngIdx = i;
+ break;
+ }
+ }
+ if (lngIdx >= 0) {
+ IniSectionGetString(globalSection, L"languagefile", grepWinLangResName[lngIdx].filename, tchTemp, COUNTOF(tchTemp));
+ IniSectionSetString(globalSection, L"languagefile", tchTemp);
+ } else {
+ IniSectionGetString(globalSection, L"languagefile", L"", tchTemp, COUNTOF(tchTemp));
+ if (StrIsEmpty(tchTemp)) {
+ IniSectionDelete(globalSection, L"languagefile", false);
+ }
+ }
- bool const bDarkMode = UseDarkMode(); // <- override usr ~ IniSectionGetBool(globalSection, L"darkmode", UseDarkMode());
- IniSectionSetBool(globalSection, L"darkmode", bDarkMode);
+ bool const bDarkMode = UseDarkMode(); // <- override usr ~ IniSectionGetBool(globalSection, L"darkmode", UseDarkMode());
+ IniSectionSetBool(globalSection, L"darkmode", bDarkMode);
- StringCchPrintf(tchTemp, COUNTOF(tchTemp), L"%s /%%mode%% \"%%pattern%%\" /g %%line%% - %%path%%", Path_Get(hNotepad3Path));
- IniSectionSetString(globalSection, L"editorcmd", tchTemp);
+ StringCchPrintf(tchTemp, COUNTOF(tchTemp), L"%s /%%mode%% \"%%pattern%%\" /g %%line%% - %%path%%", Path_Get(hNotepad3Path));
+ IniSectionSetString(globalSection, L"editorcmd", tchTemp);
- long const iOpacity = IniSectionGetLong(globalSection, L"OpacityNoFocus", Settings2.FindReplaceOpacityLevel);
- IniSectionSetLong(globalSection, L"OpacityNoFocus", iOpacity);
+ long const iOpacity = IniSectionGetLong(globalSection, L"OpacityNoFocus", Settings2.FindReplaceOpacityLevel);
+ IniSectionSetLong(globalSection, L"OpacityNoFocus", iOpacity);
- // [settings]
- const WCHAR *const settingsSection = L"settings";
+ // [settings]
+ const WCHAR *const settingsSection = L"settings";
- bool const bEscClose = IniSectionGetBool(settingsSection, L"escclose", (Settings.EscFunction == 2));
- IniSectionSetBool(settingsSection, L"escclose", bEscClose);
- bool const bBackupInFolder = IniSectionGetBool(settingsSection, L"backupinfolder", true);
- IniSectionSetBool(settingsSection, L"backupinfolder", bBackupInFolder);
+ bool const bEscClose = IniSectionGetBool(settingsSection, L"escclose", (Settings.EscFunction == 2));
+ IniSectionSetBool(settingsSection, L"escclose", bEscClose);
+ bool const bBackupInFolder = IniSectionGetBool(settingsSection, L"backupinfolder", true);
+ IniSectionSetBool(settingsSection, L"backupinfolder", bBackupInFolder);
- // [export]
- const WCHAR *const exportSection = L"export";
- bool const bExpPaths = IniSectionGetBool(exportSection, L"paths", true);
- IniSectionSetBool(exportSection, L"paths", bExpPaths);
- bool const bExpLnNums = IniSectionGetBool(exportSection, L"linenumbers", true);
- IniSectionSetBool(exportSection, L"linenumbers", bExpLnNums);
- bool const bExpContent = IniSectionGetBool(exportSection, L"linecontent", true);
- IniSectionSetBool(exportSection, L"linecontent", bExpContent);
+ // [export]
+ const WCHAR *const exportSection = L"export";
+ bool const bExpPaths = IniSectionGetBool(exportSection, L"paths", true);
+ IniSectionSetBool(exportSection, L"paths", bExpPaths);
+ bool const bExpLnNums = IniSectionGetBool(exportSection, L"linenumbers", true);
+ IniSectionSetBool(exportSection, L"linenumbers", bExpLnNums);
+ bool const bExpContent = IniSectionGetBool(exportSection, L"linecontent", true);
+ IniSectionSetBool(exportSection, L"linecontent", bExpContent);
- // search directory
- HPATHL pthSearchDir = NULL;
- if (Path_IsNotEmpty(Paths.CurrentFile)) {
- pthSearchDir = Path_Copy(Paths.CurrentFile);
- Path_RemoveFileSpec(pthSearchDir);
- }
- else {
- pthSearchDir = Path_Copy(Paths.WorkingDirectory);
- }
- IniSectionSetString(globalSection, L"searchpath", Path_Get(pthSearchDir));
- Path_Release(pthSearchDir);
+ // search directory
+ HPATHL pthSearchDir = NULL;
+ if (Path_IsNotEmpty(Paths.CurrentFile)) {
+ pthSearchDir = Path_Copy(Paths.CurrentFile);
+ Path_RemoveFileSpec(pthSearchDir);
+ }
+ else {
+ pthSearchDir = Path_Copy(Paths.WorkingDirectory);
+ }
+ IniSectionSetString(globalSection, L"searchpath", Path_Get(pthSearchDir));
+ Path_Release(pthSearchDir);
- // search pattern
- IniSectionSetString(globalSection, L"searchfor", searchPattern);
+ // search pattern
+ IniSectionSetString(globalSection, L"searchfor", searchPattern);
- SaveIniFileCache(Path_Get(hgrepwin_ini_pth));
- ResetIniFileCache();
+ SaveIniFileCache(Path_Get(hgrepwin_ini_pth));
+ ResetIniFileCache();
- }
- Path_Release(hIniFileName);
- }
+ }
+ Path_Release(hIniFileName);
+ }
- // grepWin arguments
- WCHAR tchParams[MAX_PATH<<2] = { L'\0' };
+ // grepWin arguments
+ WCHAR tchParams[MAX_PATH<<2] = { L'\0' };
- if (Path_IsExistingFile(hgrepwin_ini_pth)) {
- // relative grepWinNP3.ini path (for shorter cmdline)
- if (Path_RelativePathTo(hTemp, hGrepWinDir, FILE_ATTRIBUTE_DIRECTORY, hgrepwin_ini_pth, FILE_ATTRIBUTE_NORMAL)) {
- Path_Swap(hgrepwin_ini_pth, hTemp);
- }
- StringCchPrintf(tchParams, COUNTOF(tchParams), L"/portable /content %s /inipath:\"%s\"", tchOptions, Path_Get(hgrepwin_ini_pth));
- } else {
- StringCchPrintf(tchParams, COUNTOF(tchParams), L"/portable /content %s", tchOptions);
- }
- //if (StrIsNotEmpty(searchPattern)) {
- // SetClipboardText(Globals.hwndMain, searchPattern, StringCchLen(searchPattern, 0));
- //}
+ if (Path_IsExistingFile(hgrepwin_ini_pth)) {
+ // relative grepWinNP3.ini path (for shorter cmdline)
+ if (Path_RelativePathTo(hTemp, hGrepWinDir, FILE_ATTRIBUTE_DIRECTORY, hgrepwin_ini_pth, FILE_ATTRIBUTE_NORMAL)) {
+ Path_Swap(hgrepwin_ini_pth, hTemp);
+ }
+ StringCchPrintf(tchParams, COUNTOF(tchParams), L"/portable /content %s /inipath:\"%s\"", tchOptions, Path_Get(hgrepwin_ini_pth));
+ } else {
+ StringCchPrintf(tchParams, COUNTOF(tchParams), L"/portable /content %s", tchOptions);
+ }
+ //if (StrIsNotEmpty(searchPattern)) {
+ // SetClipboardText(Globals.hwndMain, searchPattern, StringCchLen(searchPattern, 0));
+ //}
- SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
- sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOZONECHECKS;
- sei.hwnd = hwnd;
- sei.lpVerb = NULL;
- sei.lpFile = tchExeFile;
- sei.lpParameters = tchParams;
- sei.lpDirectory = Path_Get(hGrepWinDir);
- sei.nShow = SW_SHOWNORMAL;
- ShellExecuteEx(&sei);
+ SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
+ sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOZONECHECKS;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = tchExeFile;
+ sei.lpParameters = tchParams;
+ sei.lpDirectory = Path_Get(hGrepWinDir);
+ sei.nShow = SW_SHOWNORMAL;
+ ShellExecuteEx(&sei);
- if ((INT_PTR)sei.hInstApp < 32) {
- InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_GREPWIN);
- }
+ if ((INT_PTR)sei.hInstApp < 32) {
+ InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_GREPWIN);
+ }
- Path_Release(hgrepwin_ini_pth);
- Path_Release(hGrepWinDir);
- Path_Release(hNotepad3Path);
- Path_Release(hTemp);
+ Path_Release(hgrepwin_ini_pth);
+ Path_Release(hGrepWinDir);
+ Path_Release(hNotepad3Path);
+ Path_Release(hTemp);
}
@@ -4831,42 +4831,42 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern)
//
void DialogAdminExe(HWND hwnd, bool bExecInstaller)
{
- WCHAR tchExe[MAX_PATH];
+ WCHAR tchExe[MAX_PATH];
- StringCchCopyW(tchExe, COUNTOF(tchExe), Settings2.AdministrationTool);
- if (bExecInstaller && StrIsEmpty(tchExe)) {
- return;
- }
+ StringCchCopyW(tchExe, COUNTOF(tchExe), Settings2.AdministrationTool);
+ if (bExecInstaller && StrIsEmpty(tchExe)) {
+ return;
+ }
- WCHAR tchExePath[MAX_PATH];
- if (!SearchPath(NULL, tchExe, L".exe", COUNTOF(tchExePath), tchExePath, NULL)) {
- // try Notepad3's dir path
- PathGetAppDirectory(tchExePath, COUNTOF(tchExePath));
- PathAppend(tchExePath, tchExe);
- }
+ WCHAR tchExePath[MAX_PATH];
+ if (!SearchPath(NULL, tchExe, L".exe", COUNTOF(tchExePath), tchExePath, NULL)) {
+ // try Notepad3's dir path
+ PathGetAppDirectory(tchExePath, COUNTOF(tchExePath));
+ PathAppend(tchExePath, tchExe);
+ }
- SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
- sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOZONECHECKS;
- sei.hwnd = hwnd;
- sei.lpVerb = NULL;
- sei.lpFile = tchExePath;
- sei.lpParameters = NULL; // tchParam;
- sei.lpDirectory = Path_Get(Paths.WorkingDirectory);
- sei.nShow = SW_SHOWNORMAL;
+ SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
+ sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOZONECHECKS;
+ sei.hwnd = hwnd;
+ sei.lpVerb = NULL;
+ sei.lpFile = tchExePath;
+ sei.lpParameters = NULL; // tchParam;
+ sei.lpDirectory = Path_Get(Paths.WorkingDirectory);
+ sei.nShow = SW_SHOWNORMAL;
- if (bExecInstaller) {
- ShellExecuteEx(&sei);
- if ((INT_PTR)sei.hInstApp < 32) {
- WORD const answer = INFOBOX_ANSW(InfoBoxLng(MB_OKCANCEL, L"NoAdminTool", IDS_MUI_ERR_ADMINEXE));
- if ((IDOK == answer) || (IDYES == answer)) {
- sei.lpFile = VERSION_UPDATE_CHECK;
- ShellExecuteEx(&sei);
- }
- }
- } else {
- sei.lpFile = VERSION_UPDATE_CHECK;
- ShellExecuteEx(&sei);
- }
+ if (bExecInstaller) {
+ ShellExecuteEx(&sei);
+ if ((INT_PTR)sei.hInstApp < 32) {
+ WORD const answer = INFOBOX_ANSW(InfoBoxLng(MB_OKCANCEL, L"NoAdminTool", IDS_MUI_ERR_ADMINEXE));
+ if ((IDOK == answer) || (IDYES == answer)) {
+ sei.lpFile = VERSION_UPDATE_CHECK;
+ ShellExecuteEx(&sei);
+ }
+ }
+ } else {
+ sei.lpFile = VERSION_UPDATE_CHECK;
+ ShellExecuteEx(&sei);
+ }
}
// ============================================================================
@@ -4883,11 +4883,11 @@ bool s_bFreezeAppTitle = false; // extern visible
static WCHAR s_wchAdditionalTitleInfo[MAX_PATH] = { L'\0' };
void SetAdditionalTitleInfo(LPCWSTR lpszAddTitleInfo) {
- StringCchCopy(s_wchAdditionalTitleInfo, COUNTOF(s_wchAdditionalTitleInfo), lpszAddTitleInfo);
+ StringCchCopy(s_wchAdditionalTitleInfo, COUNTOF(s_wchAdditionalTitleInfo), lpszAddTitleInfo);
}
void AppendAdditionalTitleInfo(LPCWSTR lpszAddTitleInfo) {
- StringCchCat(s_wchAdditionalTitleInfo, COUNTOF(s_wchAdditionalTitleInfo), lpszAddTitleInfo);
+ StringCchCat(s_wchAdditionalTitleInfo, COUNTOF(s_wchAdditionalTitleInfo), lpszAddTitleInfo);
}
static const WCHAR *pszMod = DOCMODDIFYD;
@@ -4900,105 +4900,105 @@ static WCHAR s_wchCachedDisplayName[80] = { L'\0' };
// ----------------------------------------------------------------------------
void SetWindowTitle(HWND hwnd, const HPATHL pthFilePath, int iFormat,
- bool bPasteBoard, bool bIsElevated, bool bModified,
- bool bFileLocked, bool bFileChanged, bool bFileDeleted, bool bReadOnly, LPCWSTR lpszExcerpt) {
+ bool bPasteBoard, bool bIsElevated, bool bModified,
+ bool bFileLocked, bool bFileChanged, bool bFileDeleted, bool bReadOnly, LPCWSTR lpszExcerpt) {
- if (s_bFreezeAppTitle) {
- return;
- }
- if (!s_pthCachedFilePath) {
- s_pthCachedFilePath = Path_Allocate(L"");
- // TODO: cleanup on exit §§§ @@@
- }
+ if (s_bFreezeAppTitle) {
+ return;
+ }
+ if (!s_pthCachedFilePath) {
+ s_pthCachedFilePath = Path_Allocate(L"");
+ // TODO: cleanup on exit §§§ @@@
+ }
- WCHAR szAppName[SMALL_BUFFER] = { L'\0' };
- if (bPasteBoard) {
- FormatLngStringW(szAppName, COUNTOF(szAppName), IDS_MUI_APPTITLE_PASTEBOARD, _W(SAPPNAME));
- }
- else if (bIsElevated) {
- WCHAR szElevatedAppName[SMALL_BUFFER] = { L'\0' };
- FormatLngStringW(szElevatedAppName, COUNTOF(szElevatedAppName), IDS_MUI_APPTITLE_ELEVATED, _W(SAPPNAME));
- StringCchCopy(szAppName, COUNTOF(szAppName), szElevatedAppName);
- }
- else {
- StringCchCopy(szAppName, COUNTOF(szAppName), _W(SAPPNAME));
- }
+ WCHAR szAppName[SMALL_BUFFER] = { L'\0' };
+ if (bPasteBoard) {
+ FormatLngStringW(szAppName, COUNTOF(szAppName), IDS_MUI_APPTITLE_PASTEBOARD, _W(SAPPNAME));
+ }
+ else if (bIsElevated) {
+ WCHAR szElevatedAppName[SMALL_BUFFER] = { L'\0' };
+ FormatLngStringW(szElevatedAppName, COUNTOF(szElevatedAppName), IDS_MUI_APPTITLE_ELEVATED, _W(SAPPNAME));
+ StringCchCopy(szAppName, COUNTOF(szAppName), szElevatedAppName);
+ }
+ else {
+ StringCchCopy(szAppName, COUNTOF(szAppName), _W(SAPPNAME));
+ }
- if (StrIsEmpty(s_szUntitled)) {
- GetLngString(IDS_MUI_UNTITLED, s_szUntitled, COUNTOF(s_szUntitled));
- }
+ if (StrIsEmpty(s_szUntitled)) {
+ GetLngString(IDS_MUI_UNTITLED, s_szUntitled, COUNTOF(s_szUntitled));
+ }
- WCHAR szTitle[MIDSZ_BUFFER] = { L'\0' };
+ WCHAR szTitle[MIDSZ_BUFFER] = { L'\0' };
- if (bModified) {
- StringCchCat(szTitle, COUNTOF(szTitle), pszMod);
- }
- if (bFileChanged) {
- if (bFileDeleted) {
- StringCchCatN(szTitle, COUNTOF(szTitle), Settings2.FileDeletedIndicator, 3);
- } else {
- StringCchCatN(szTitle, COUNTOF(szTitle), Settings2.FileChangedIndicator, 3);
- }
- StringCchCat(szTitle, COUNTOF(szTitle), L" ");
- }
- if (StrIsNotEmpty(lpszExcerpt)) {
+ if (bModified) {
+ StringCchCat(szTitle, COUNTOF(szTitle), pszMod);
+ }
+ if (bFileChanged) {
+ if (bFileDeleted) {
+ StringCchCatN(szTitle, COUNTOF(szTitle), Settings2.FileDeletedIndicator, 3);
+ } else {
+ StringCchCatN(szTitle, COUNTOF(szTitle), Settings2.FileChangedIndicator, 3);
+ }
+ StringCchCat(szTitle, COUNTOF(szTitle), L" ");
+ }
+ if (StrIsNotEmpty(lpszExcerpt)) {
- WCHAR szExcrptFmt[32] = { L'\0' };
- WCHAR szExcrptQuot[SMALL_BUFFER] = { L'\0' };
- GetLngString(IDS_MUI_TITLEEXCERPT, szExcrptFmt, COUNTOF(szExcrptFmt));
- StringCchPrintf(szExcrptQuot, COUNTOF(szExcrptQuot), szExcrptFmt, lpszExcerpt);
- StringCchCat(szTitle, COUNTOF(szTitle), szExcrptQuot);
+ WCHAR szExcrptFmt[32] = { L'\0' };
+ WCHAR szExcrptQuot[SMALL_BUFFER] = { L'\0' };
+ GetLngString(IDS_MUI_TITLEEXCERPT, szExcrptFmt, COUNTOF(szExcrptFmt));
+ StringCchPrintf(szExcrptQuot, COUNTOF(szExcrptQuot), szExcrptFmt, lpszExcerpt);
+ StringCchCat(szTitle, COUNTOF(szTitle), szExcrptQuot);
- }
- else if (Path_IsNotEmpty(pthFilePath)) {
+ }
+ else if (Path_IsNotEmpty(pthFilePath)) {
- if (iFormat < 2) {
- if (Path_StrgComparePath(s_pthCachedFilePath, pthFilePath) != 0) {
- Path_Reset(s_pthCachedFilePath, Path_Get(pthFilePath));
- Path_GetDisplayName(s_wchCachedDisplayName, COUNTOF(s_wchCachedDisplayName), s_pthCachedFilePath, s_szUntitled);
- }
- StringCchCat(szTitle, COUNTOF(szTitle), Path_FindFileName(s_pthCachedFilePath));
- if (iFormat == 1) {
- HPATHL hdir = Path_Copy(s_pthCachedFilePath);
- if (Path_IsNotEmpty(hdir)) {
- Path_RemoveFileSpec(hdir);
- }
- StringCchCat(szTitle, COUNTOF(szTitle), L" [");
- StringCchCat(szTitle, COUNTOF(szTitle), Path_Get(hdir));
- StringCchCat(szTitle, COUNTOF(szTitle), L"]");
- Path_Release(hdir);
- }
- } else {
- StringCchCat(szTitle, COUNTOF(szTitle), Path_Get(pthFilePath));
- }
- } else {
- Path_Empty(s_pthCachedFilePath, false);
- StringCchCopy(s_wchCachedDisplayName, COUNTOF(s_wchCachedDisplayName), L"");
- StringCchCat(szTitle, COUNTOF(szTitle), s_szUntitled);
- }
+ if (iFormat < 2) {
+ if (Path_StrgComparePath(s_pthCachedFilePath, pthFilePath) != 0) {
+ Path_Reset(s_pthCachedFilePath, Path_Get(pthFilePath));
+ Path_GetDisplayName(s_wchCachedDisplayName, COUNTOF(s_wchCachedDisplayName), s_pthCachedFilePath, s_szUntitled);
+ }
+ StringCchCat(szTitle, COUNTOF(szTitle), Path_FindFileName(s_pthCachedFilePath));
+ if (iFormat == 1) {
+ HPATHL hdir = Path_Copy(s_pthCachedFilePath);
+ if (Path_IsNotEmpty(hdir)) {
+ Path_RemoveFileSpec(hdir);
+ }
+ StringCchCat(szTitle, COUNTOF(szTitle), L" [");
+ StringCchCat(szTitle, COUNTOF(szTitle), Path_Get(hdir));
+ StringCchCat(szTitle, COUNTOF(szTitle), L"]");
+ Path_Release(hdir);
+ }
+ } else {
+ StringCchCat(szTitle, COUNTOF(szTitle), Path_Get(pthFilePath));
+ }
+ } else {
+ Path_Empty(s_pthCachedFilePath, false);
+ StringCchCopy(s_wchCachedDisplayName, COUNTOF(s_wchCachedDisplayName), L"");
+ StringCchCat(szTitle, COUNTOF(szTitle), s_szUntitled);
+ }
- WCHAR wchModeEx[64] = { L'\0' };
- if (bFileLocked) {
- GetLngString(IDS_MUI_FILELOCKED, wchModeEx, COUNTOF(wchModeEx));
- StringCchCat(szTitle, COUNTOF(szTitle), L" ");
- StringCchCat(szTitle, COUNTOF(szTitle), wchModeEx);
- }
- if (bReadOnly) {
- GetLngString(IDS_MUI_READONLY, wchModeEx, COUNTOF(wchModeEx));
- StringCchCat(szTitle, COUNTOF(szTitle), L" ");
- StringCchCat(szTitle, COUNTOF(szTitle), wchModeEx);
- }
+ WCHAR wchModeEx[64] = { L'\0' };
+ if (bFileLocked) {
+ GetLngString(IDS_MUI_FILELOCKED, wchModeEx, COUNTOF(wchModeEx));
+ StringCchCat(szTitle, COUNTOF(szTitle), L" ");
+ StringCchCat(szTitle, COUNTOF(szTitle), wchModeEx);
+ }
+ if (bReadOnly) {
+ GetLngString(IDS_MUI_READONLY, wchModeEx, COUNTOF(wchModeEx));
+ StringCchCat(szTitle, COUNTOF(szTitle), L" ");
+ StringCchCat(szTitle, COUNTOF(szTitle), wchModeEx);
+ }
- StringCchCat(szTitle, COUNTOF(szTitle), pszSep);
- StringCchCat(szTitle, COUNTOF(szTitle), szAppName);
+ StringCchCat(szTitle, COUNTOF(szTitle), pszSep);
+ StringCchCat(szTitle, COUNTOF(szTitle), szAppName);
- // UCHARDET
- if (StrIsNotEmpty(s_wchAdditionalTitleInfo)) {
- StringCchCat(szTitle, COUNTOF(szTitle), pszSep);
- StringCchCat(szTitle, COUNTOF(szTitle), s_wchAdditionalTitleInfo);
- }
+ // UCHARDET
+ if (StrIsNotEmpty(s_wchAdditionalTitleInfo)) {
+ StringCchCat(szTitle, COUNTOF(szTitle), pszSep);
+ StringCchCat(szTitle, COUNTOF(szTitle), s_wchAdditionalTitleInfo);
+ }
- SetWindowText(hwnd, szTitle);
+ SetWindowText(hwnd, szTitle);
}
@@ -5008,14 +5008,14 @@ void SetWindowTitle(HWND hwnd, const HPATHL pthFilePath, int iFormat,
//
void SetWindowTransparentMode(HWND hwnd, bool bTransparentMode, int iOpacityLevel)
{
- const DWORD exStyle = GetWindowExStyle(hwnd);
- if (bTransparentMode) {
- SetWindowExStyle(hwnd, exStyle | WS_EX_LAYERED);
- BYTE const bAlpha = (BYTE)MulDiv(iOpacityLevel, 255, 100);
- SetLayeredWindowAttributes(hwnd, 0, bAlpha, LWA_ALPHA);
- } else {
- SetWindowExStyle(hwnd, exStyle & ~WS_EX_LAYERED);
- }
+ const DWORD exStyle = GetWindowExStyle(hwnd);
+ if (bTransparentMode) {
+ SetWindowExStyle(hwnd, exStyle | WS_EX_LAYERED);
+ BYTE const bAlpha = (BYTE)MulDiv(iOpacityLevel, 255, 100);
+ SetLayeredWindowAttributes(hwnd, 0, bAlpha, LWA_ALPHA);
+ } else {
+ SetWindowExStyle(hwnd, exStyle & ~WS_EX_LAYERED);
+ }
}
@@ -5025,12 +5025,12 @@ void SetWindowTransparentMode(HWND hwnd, bool bTransparentMode, int iOpacityLeve
//
void SetWindowLayoutRTL(HWND hwnd, bool bRTL)
{
- DWORD const exStyle = GetWindowExStyle(hwnd);
- if (bRTL) {
- SetWindowExStyle(hwnd, exStyle | WS_EX_LAYOUTRTL);
- } else {
- SetWindowExStyle(hwnd, exStyle & ~WS_EX_LAYOUTRTL);
- }
+ DWORD const exStyle = GetWindowExStyle(hwnd);
+ if (bRTL) {
+ SetWindowExStyle(hwnd, exStyle | WS_EX_LAYOUTRTL);
+ } else {
+ SetWindowExStyle(hwnd, exStyle & ~WS_EX_LAYOUTRTL);
+ }
}
@@ -5040,12 +5040,12 @@ void SetWindowLayoutRTL(HWND hwnd, bool bRTL)
//
void SetWindowReadingRTL(HWND hwnd, bool bRTL)
{
- DWORD const exStyle = GetWindowExStyle(hwnd);
- if (bRTL) {
- SetWindowExStyle(hwnd, exStyle | WS_EX_RTLREADING);
- } else {
- SetWindowExStyle(hwnd, exStyle & ~WS_EX_RTLREADING);
- }
+ DWORD const exStyle = GetWindowExStyle(hwnd);
+ if (bRTL) {
+ SetWindowExStyle(hwnd, exStyle | WS_EX_RTLREADING);
+ } else {
+ SetWindowExStyle(hwnd, exStyle & ~WS_EX_RTLREADING);
+ }
}
@@ -5056,44 +5056,44 @@ void SetWindowReadingRTL(HWND hwnd, bool bRTL)
UINT ComboBox_GetTextLengthEx(HWND hDlg, int nIDDlgItem)
{
- return (UINT)ComboBox_GetTextLength(GetDlgItem(hDlg, nIDDlgItem));
+ return (UINT)ComboBox_GetTextLength(GetDlgItem(hDlg, nIDDlgItem));
}
UINT ComboBox_GetCurSelEx(HWND hDlg, int nIDDlgItem) {
- return (UINT)ComboBox_GetCurSel(GetDlgItem(hDlg, nIDDlgItem));
+ return (UINT)ComboBox_GetCurSel(GetDlgItem(hDlg, nIDDlgItem));
}
-UINT ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount) {
- WCHAR wsz[FNDRPL_BUFFER] = { L'\0' };
- HWND const hwndCtl = GetDlgItem(hDlg, nIDDlgItem);
- UINT const uRet = (UINT)ComboBox_GetTextLength(hwndCtl);
+int ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, size_t cch)
+{
+ HWND const hwndCtl = GetDlgItem(hDlg, nIDDlgItem);
+ int const len = ComboBox_GetTextLength(hwndCtl) + 1;
+ wchar_t* const buf = AllocMem(len * sizeof(wchar_t), HEAP_ZERO_MEMORY);
int const idx = ComboBox_GetCurSel(hwndCtl);
- if (idx >= 0) {
- if (uRet < COUNTOF(wsz)) {
- ComboBox_GetLBText(hwndCtl, ComboBox_GetCurSel(hwndCtl), wsz);
- }
- } else {
- ComboBox_GetText(hwndCtl, wsz, COUNTOF(wsz));
- }
- ZeroMemory(lpString, nMaxCount);
- WideCharToMultiByte(Encoding_SciCP, 0, wsz, -1, lpString, nMaxCount - 1, NULL, NULL);
- return uRet;
+ if (idx >= 0) {
+ ComboBox_GetLBText(hwndCtl, ComboBox_GetCurSel(hwndCtl), buf);
+ } else {
+ ComboBox_GetText(hwndCtl, buf, len);
+ }
+ WideCharToMultiByte(CP_UTF8, 0, buf, -1, lpString, (int)cch, NULL, NULL);
+ FreeMem(buf);
+ return len;
}
void ComboBox_SetTextMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
{
- WCHAR wsz[FNDRPL_BUFFER] = { L'\0' };
- MultiByteToWideChar(Encoding_SciCP, 0, lpString, -1, wsz, (int)COUNTOF(wsz));
- ComboBox_SetText(GetDlgItem(hDlg, nIDDlgItem), wsz);
- //return SetDlgItemText(hDlg, nIDDlgItem, wsz);
+ int const len = MultiByteToWideChar(CP_UTF8, 0, lpString, -1, NULL, 0) + 1;
+ wchar_t* const buf = AllocMem(len * sizeof(wchar_t), HEAP_ZERO_MEMORY);
+ MultiByteToWideChar(CP_UTF8, 0, lpString, -1, buf, len);
+ ComboBox_SetText(GetDlgItem(hDlg, nIDDlgItem), buf);
+ FreeMem(buf);
}
#if 0
void ComboBox_AddStringMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
{
- WCHAR wsz[FNDRPL_BUFFER] = { L'\0' };
- MultiByteToWideChar(Encoding_SciCP, 0, lpString, -1, wsz, (int)COUNTOF(wsz));
- ComboBox_AddString(GetDlgItem(hDlg, nIDDlgItem), wsz);
+ WCHAR wsz[FNDRPL_BUFFER] = { L'\0' };
+ MultiByteToWideChar(Encoding_SciCP, 0, lpString, -1, wsz, (int)COUNTOF(wsz));
+ ComboBox_AddString(GetDlgItem(hDlg, nIDDlgItem), wsz);
}
#endif
@@ -5104,21 +5104,21 @@ void ComboBox_AddStringMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
POINT GetCenterOfDlgInParent(const RECT* rcDlg, const RECT* rcParent)
{
- HMONITOR const hMonitor = MonitorFromRect(rcParent, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi = { sizeof(MONITORINFO) };
- GetMonitorInfo(hMonitor, &mi);
- int const xMin = mi.rcWork.left;
- int const xMax = (mi.rcWork.right) - (rcDlg->right - rcDlg->left);
- int const yMin = mi.rcWork.top;
- int const yMax = (mi.rcWork.bottom) - (rcDlg->bottom - rcDlg->top);
+ HMONITOR const hMonitor = MonitorFromRect(rcParent, MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi = { sizeof(MONITORINFO) };
+ GetMonitorInfo(hMonitor, &mi);
+ int const xMin = mi.rcWork.left;
+ int const xMax = (mi.rcWork.right) - (rcDlg->right - rcDlg->left);
+ int const yMin = mi.rcWork.top;
+ int const yMax = (mi.rcWork.bottom) - (rcDlg->bottom - rcDlg->top);
- int const x = rcParent->left + (((rcParent->right - rcParent->left) - (rcDlg->right - rcDlg->left)) >> 1);
- int const y = rcParent->top + (((rcParent->bottom - rcParent->top) - (rcDlg->bottom - rcDlg->top)) >> 1);
+ int const x = rcParent->left + (((rcParent->right - rcParent->left) - (rcDlg->right - rcDlg->left)) >> 1);
+ int const y = rcParent->top + (((rcParent->bottom - rcParent->top) - (rcDlg->bottom - rcDlg->top)) >> 1);
- POINT ptRet = { 0, 0 };
- ptRet.x = clampi(x, xMin, xMax);
- ptRet.y = clampi(y, yMin, yMax);
- return ptRet;
+ POINT ptRet = { 0, 0 };
+ ptRet.x = clampi(x, xMin, xMax);
+ ptRet.y = clampi(y, yMin, yMax);
+ return ptRet;
}
@@ -5128,8 +5128,8 @@ POINT GetCenterOfDlgInParent(const RECT* rcDlg, const RECT* rcParent)
//
HWND GetParentOrDesktop(HWND hDlg)
{
- HWND const hParent = GetParent(hDlg);
- return hParent ? hParent : GetDesktopWindow();
+ HWND const hParent = GetParent(hDlg);
+ return hParent ? hParent : GetDesktopWindow();
}
@@ -5139,19 +5139,19 @@ HWND GetParentOrDesktop(HWND hDlg)
//
void CenterDlgInParent(HWND hDlg, HWND hDlgParent)
{
- if (!hDlg) { return; }
+ if (!hDlg) { return; }
- RECT rcDlg = { 0 };
- GetWindowRect(hDlg, &rcDlg);
+ RECT rcDlg = { 0 };
+ GetWindowRect(hDlg, &rcDlg);
- HWND const hParentWnd = hDlgParent ? hDlgParent : GetParentOrDesktop(hDlg);
- RECT rcParent = { 0 };
- GetWindowRectEx(hParentWnd, &rcParent);
+ HWND const hParentWnd = hDlgParent ? hDlgParent : GetParentOrDesktop(hDlg);
+ RECT rcParent = { 0 };
+ GetWindowRectEx(hParentWnd, &rcParent);
- POINT const ptTopLeft = GetCenterOfDlgInParent(&rcDlg, &rcParent);
+ POINT const ptTopLeft = GetCenterOfDlgInParent(&rcDlg, &rcParent);
- SetWindowPos(hDlg, NULL, ptTopLeft.x, ptTopLeft.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- SetForegroundWindow(hDlg);
+ SetWindowPos(hDlg, NULL, ptTopLeft.x, ptTopLeft.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ SetForegroundWindow(hDlg);
}
@@ -5161,26 +5161,26 @@ void CenterDlgInParent(HWND hDlg, HWND hDlgParent)
//
void GetDlgPos(HWND hDlg, LPINT xDlg, LPINT yDlg)
{
- if (!hDlg) {
- return;
- }
+ if (!hDlg) {
+ return;
+ }
- UINT const dpi = Scintilla_GetWindowDPI(hDlg);
+ UINT const dpi = Scintilla_GetWindowDPI(hDlg);
- RECT rcDlg;
- GetWindowRect(hDlg, &rcDlg);
+ RECT rcDlg;
+ GetWindowRect(hDlg, &rcDlg);
- HWND const hParent = GetParent(hDlg);
- RECT rcParent;
- GetWindowRect(hParent, &rcParent);
+ HWND const hParent = GetParent(hDlg);
+ RECT rcParent;
+ GetWindowRect(hParent, &rcParent);
- // return positions relative to parent window (normalized DPI)
- if (xDlg) {
- *xDlg = MulDiv((rcDlg.left - rcParent.left), USER_DEFAULT_SCREEN_DPI, (dpi ? dpi : USER_DEFAULT_SCREEN_DPI));
- }
- if (yDlg) {
- *yDlg = MulDiv((rcDlg.top - rcParent.top), USER_DEFAULT_SCREEN_DPI, (dpi ? dpi : USER_DEFAULT_SCREEN_DPI));
- }
+ // return positions relative to parent window (normalized DPI)
+ if (xDlg) {
+ *xDlg = MulDiv((rcDlg.left - rcParent.left), USER_DEFAULT_SCREEN_DPI, (dpi ? dpi : USER_DEFAULT_SCREEN_DPI));
+ }
+ if (yDlg) {
+ *yDlg = MulDiv((rcDlg.top - rcParent.top), USER_DEFAULT_SCREEN_DPI, (dpi ? dpi : USER_DEFAULT_SCREEN_DPI));
+ }
}
@@ -5190,35 +5190,35 @@ void GetDlgPos(HWND hDlg, LPINT xDlg, LPINT yDlg)
//
void SetDlgPos(HWND hDlg, int xDlg, int yDlg)
{
- if (!hDlg) {
- return;
- }
+ if (!hDlg) {
+ return;
+ }
- UINT const dpi = Scintilla_GetWindowDPI(hDlg);
+ UINT const dpi = Scintilla_GetWindowDPI(hDlg);
- RECT rcDlg;
- GetWindowRect(hDlg, &rcDlg);
+ RECT rcDlg;
+ GetWindowRect(hDlg, &rcDlg);
- HWND const hParent = GetParent(hDlg);
- RECT rcParent;
- GetWindowRect(hParent, &rcParent);
+ HWND const hParent = GetParent(hDlg);
+ RECT rcParent;
+ GetWindowRect(hParent, &rcParent);
- HMONITOR const hMonitor = MonitorFromRect(&rcParent, MONITOR_DEFAULTTONEAREST);
+ HMONITOR const hMonitor = MonitorFromRect(&rcParent, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi = { sizeof(MONITORINFO) };
- GetMonitorInfo(hMonitor, &mi);
+ MONITORINFO mi = { sizeof(MONITORINFO) };
+ GetMonitorInfo(hMonitor, &mi);
- int const xMin = mi.rcWork.left;
- int const yMin = mi.rcWork.top;
+ int const xMin = mi.rcWork.left;
+ int const yMin = mi.rcWork.top;
- int const xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left);
- int const yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top);
+ int const xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left);
+ int const yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top);
- // desired positions relative to parent window (normalized DPI)
- int const x = rcParent.left + MulDiv(xDlg, dpi, USER_DEFAULT_SCREEN_DPI);
- int const y = rcParent.top + MulDiv(yDlg, dpi, USER_DEFAULT_SCREEN_DPI);
+ // desired positions relative to parent window (normalized DPI)
+ int const x = rcParent.left + MulDiv(xDlg, dpi, USER_DEFAULT_SCREEN_DPI);
+ int const y = rcParent.top + MulDiv(yDlg, dpi, USER_DEFAULT_SCREEN_DPI);
- SetWindowPos(hDlg, NULL, clampi(x, xMin, xMax), clampi(y, yMin, yMax), 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ SetWindowPos(hDlg, NULL, clampi(x, xMin, xMax), clampi(y, yMin, yMax), 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
@@ -5233,235 +5233,235 @@ void SetDlgPos(HWND hDlg, int xDlg, int yDlg)
#define NP3_ENABLE_RESIZEDLG_TEMP_FIX 1
typedef struct _resizeDlg {
- int direction;
- UINT dpi;
- int cxClient;
- int cyClient;
- int mmiPtMinX;
- int mmiPtMinY;
- int mmiPtMaxX; // only Y direction
- int mmiPtMaxY; // only X direction
- int attrs[MAX_RESIZEDLG_ATTR_COUNT];
+ int direction;
+ UINT dpi;
+ int cxClient;
+ int cyClient;
+ int mmiPtMinX;
+ int mmiPtMinY;
+ int mmiPtMaxX; // only Y direction
+ int mmiPtMaxY; // only X direction
+ int attrs[MAX_RESIZEDLG_ATTR_COUNT];
} RESIZEDLG, * PRESIZEDLG;
typedef const RESIZEDLG* LPCRESIZEDLG;
void ResizeDlg_InitEx(HWND hwnd, int cxFrame, int cyFrame, int nIdGrip, RSZ_DLG_DIR iDirection)
{
- RESIZEDLG* const pm = (RESIZEDLG*)AllocMem(sizeof(RESIZEDLG), HEAP_ZERO_MEMORY);
- pm->direction = iDirection;
- pm->dpi = Scintilla_GetWindowDPI(hwnd);
+ RESIZEDLG* const pm = (RESIZEDLG*)AllocMem(sizeof(RESIZEDLG), HEAP_ZERO_MEMORY);
+ pm->direction = iDirection;
+ pm->dpi = Scintilla_GetWindowDPI(hwnd);
- RECT rc;
- GetClientRect(hwnd, &rc);
- pm->cxClient = rc.right - rc.left;
- pm->cyClient = rc.bottom - rc.top;
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ pm->cxClient = rc.right - rc.left;
+ pm->cyClient = rc.bottom - rc.top;
- const DWORD style = (pm->direction < 0) ? (GetWindowStyle(hwnd) & ~WS_THICKFRAME) : (GetWindowStyle(hwnd) | WS_THICKFRAME);
+ const DWORD style = (pm->direction < 0) ? (GetWindowStyle(hwnd) & ~WS_THICKFRAME) : (GetWindowStyle(hwnd) | WS_THICKFRAME);
- Scintilla_AdjustWindowRectForDpi((LPWRECT)&rc, style, 0, pm->dpi);
+ Scintilla_AdjustWindowRectForDpi((LPWRECT)&rc, style, 0, pm->dpi);
- pm->mmiPtMinX = rc.right - rc.left;
- pm->mmiPtMinY = rc.bottom - rc.top;
+ pm->mmiPtMinX = rc.right - rc.left;
+ pm->mmiPtMinY = rc.bottom - rc.top;
- // only one direction
- switch (iDirection) {
- case RSZ_ONLY_X:
- pm->mmiPtMaxY = pm->mmiPtMinY;
- break;
- case RSZ_ONLY_Y:
- pm->mmiPtMaxX = pm->mmiPtMinX;
- break;
- }
+ // only one direction
+ switch (iDirection) {
+ case RSZ_ONLY_X:
+ pm->mmiPtMaxY = pm->mmiPtMinY;
+ break;
+ case RSZ_ONLY_Y:
+ pm->mmiPtMaxX = pm->mmiPtMinX;
+ break;
+ }
- cxFrame = max_i(cxFrame, pm->mmiPtMinX);
- cyFrame = max_i(cyFrame, pm->mmiPtMinY);
+ cxFrame = max_i(cxFrame, pm->mmiPtMinX);
+ cyFrame = max_i(cyFrame, pm->mmiPtMinY);
- SetProp(hwnd, RESIZEDLG_PROP_KEY, (HANDLE)pm);
+ SetProp(hwnd, RESIZEDLG_PROP_KEY, (HANDLE)pm);
- SetWindowPos(hwnd, NULL, rc.left, rc.top, cxFrame, cyFrame, SWP_NOZORDER);
+ SetWindowPos(hwnd, NULL, rc.left, rc.top, cxFrame, cyFrame, SWP_NOZORDER);
- SetWindowStyle(hwnd, style);
- SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
+ SetWindowStyle(hwnd, style);
+ SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
- 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);
+ 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);
- if (pm->direction >= 0) {
- HWND const hwndCtl = GetDlgItem(hwnd, nIdGrip);
- if (hwndCtl) {
- SetWindowStyle(hwndCtl, GetWindowStyle(hwndCtl) | SBS_SIZEGRIP | WS_CLIPSIBLINGS);
- int const cGrip = Scintilla_GetSystemMetricsForDpi(SM_CXHTHUMB, pm->dpi);
- SetWindowPos(hwndCtl, NULL, pm->cxClient - cGrip, pm->cyClient - cGrip, cGrip, cGrip, SWP_NOZORDER);
- }
- }
+ if (pm->direction >= 0) {
+ HWND const hwndCtl = GetDlgItem(hwnd, nIdGrip);
+ if (hwndCtl) {
+ SetWindowStyle(hwndCtl, GetWindowStyle(hwndCtl) | SBS_SIZEGRIP | WS_CLIPSIBLINGS);
+ int const cGrip = Scintilla_GetSystemMetricsForDpi(SM_CXHTHUMB, pm->dpi);
+ SetWindowPos(hwndCtl, NULL, pm->cxClient - cGrip, pm->cyClient - cGrip, cGrip, cGrip, SWP_NOZORDER);
+ }
+ }
}
void ResizeDlg_Destroy(HWND hwnd, int* cxFrame, int* cyFrame)
{
- PRESIZEDLG const pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
+ PRESIZEDLG const pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
- RECT rc;
- GetWindowRect(hwnd, &rc);
- if (cxFrame) {
- *cxFrame = (rc.right - rc.left);
- }
- if (cyFrame) {
- *cyFrame = (rc.bottom - rc.top);
- }
- RemoveProp(hwnd, RESIZEDLG_PROP_KEY);
- FreeMem(pm);
+ RECT rc;
+ GetWindowRect(hwnd, &rc);
+ if (cxFrame) {
+ *cxFrame = (rc.right - rc.left);
+ }
+ if (cyFrame) {
+ *cyFrame = (rc.bottom - rc.top);
+ }
+ RemoveProp(hwnd, RESIZEDLG_PROP_KEY);
+ FreeMem(pm);
}
void ResizeDlg_Size(HWND hwnd, LPARAM lParam, int* cx, int* cy)
{
- PRESIZEDLG pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
- if (pm) {
- const int cxClient = LOWORD(lParam);
- const int cyClient = HIWORD(lParam);
+ PRESIZEDLG pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
+ if (pm) {
+ const int cxClient = LOWORD(lParam);
+ const int cyClient = HIWORD(lParam);
#if NP3_ENABLE_RESIZEDLG_TEMP_FIX
- const UINT dpi = Scintilla_GetWindowDPI(hwnd);
- const UINT old = pm->dpi;
- if (cx) {
- *cx = cxClient - MulDiv(pm->cxClient, dpi, old);
- }
- if (cy) {
- *cy = cyClient - MulDiv(pm->cyClient, dpi, old);
- }
- // store in original DPI.
- pm->cxClient = MulDiv(cxClient, old, dpi);
- pm->cyClient = MulDiv(cyClient, old, dpi);
+ const UINT dpi = Scintilla_GetWindowDPI(hwnd);
+ const UINT old = pm->dpi;
+ if (cx) {
+ *cx = cxClient - MulDiv(pm->cxClient, dpi, old);
+ }
+ if (cy) {
+ *cy = cyClient - MulDiv(pm->cyClient, dpi, old);
+ }
+ // store in original DPI.
+ pm->cxClient = MulDiv(cxClient, old, dpi);
+ pm->cyClient = MulDiv(cyClient, old, dpi);
#else
- if (cx) {
- *cx = cxClient - pm->cxClient;
- }
- if (cy) {
- *cy = cyClient - pm->cyClient;
- }
- pm->cxClient = cxClient;
- pm->cyClient = cyClient;
+ if (cx) {
+ *cx = cxClient - pm->cxClient;
+ }
+ if (cy) {
+ *cy = cyClient - pm->cyClient;
+ }
+ pm->cxClient = cxClient;
+ pm->cyClient = cyClient;
#endif
- }
+ }
}
void ResizeDlg_GetMinMaxInfo(HWND hwnd, LPARAM lParam)
{
- LPCRESIZEDLG pm = (LPCRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
- LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
+ LPCRESIZEDLG pm = (LPCRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
+ LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
#if NP3_ENABLE_RESIZEDLG_TEMP_FIX
- UINT const dpi = Scintilla_GetWindowDPI(hwnd);
- UINT const old = pm->dpi;
+ UINT const dpi = Scintilla_GetWindowDPI(hwnd);
+ UINT const old = pm->dpi;
- lpmmi->ptMinTrackSize.x = MulDiv(pm->mmiPtMinX, dpi, old);
- lpmmi->ptMinTrackSize.y = MulDiv(pm->mmiPtMinY, dpi, old);
+ lpmmi->ptMinTrackSize.x = MulDiv(pm->mmiPtMinX, dpi, old);
+ lpmmi->ptMinTrackSize.y = MulDiv(pm->mmiPtMinY, dpi, old);
- // only one direction
- switch (pm->direction) {
- case RSZ_ONLY_X:
- lpmmi->ptMaxTrackSize.y = MulDiv(pm->mmiPtMaxY, dpi, old);
- break;
+ // only one direction
+ switch (pm->direction) {
+ case RSZ_ONLY_X:
+ lpmmi->ptMaxTrackSize.y = MulDiv(pm->mmiPtMaxY, dpi, old);
+ break;
- case RSZ_ONLY_Y:
- lpmmi->ptMaxTrackSize.x = MulDiv(pm->mmiPtMaxX, dpi, old);
- break;
- }
+ case RSZ_ONLY_Y:
+ lpmmi->ptMaxTrackSize.x = MulDiv(pm->mmiPtMaxX, dpi, old);
+ break;
+ }
#else
- lpmmi->ptMinTrackSize.x = pm->mmiPtMinX;
- lpmmi->ptMinTrackSize.y = pm->mmiPtMinY;
+ lpmmi->ptMinTrackSize.x = pm->mmiPtMinX;
+ lpmmi->ptMinTrackSize.y = pm->mmiPtMinY;
- // only one direction
- switch (pm->direction) {
- case RSZ_ONLY_X:
- lpmmi->ptMaxTrackSize.y = pm->mmiPtMaxY;
- break;
+ // only one direction
+ switch (pm->direction) {
+ case RSZ_ONLY_X:
+ lpmmi->ptMaxTrackSize.y = pm->mmiPtMaxY;
+ break;
- case RSZ_ONLY_Y:
- lpmmi->ptMaxTrackSize.x = pm->mmiPtMaxX;
- break;
- }
+ case RSZ_ONLY_Y:
+ lpmmi->ptMaxTrackSize.x = pm->mmiPtMaxX;
+ break;
+ }
#endif
}
void ResizeDlg_SetAttr(HWND hwnd, int index, int value)
{
- if (index < MAX_RESIZEDLG_ATTR_COUNT) {
- PRESIZEDLG pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
- pm->attrs[index] = value;
- }
+ if (index < MAX_RESIZEDLG_ATTR_COUNT) {
+ PRESIZEDLG pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
+ pm->attrs[index] = value;
+ }
}
int ResizeDlg_GetAttr(HWND hwnd, int index)
{
- if (index < MAX_RESIZEDLG_ATTR_COUNT) {
- const LPCRESIZEDLG pm = (LPCRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
- return pm->attrs[index];
- }
- return FALSE;
+ if (index < MAX_RESIZEDLG_ATTR_COUNT) {
+ const LPCRESIZEDLG pm = (LPCRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
+ return pm->attrs[index];
+ }
+ return FALSE;
}
void ResizeDlg_InitY2Ex(HWND hwnd, int cxFrame, int cyFrame, int nIdGrip, int iDirection, int nCtlId1, int nCtlId2)
{
- const int hMin1 = GetDlgCtrlHeight(hwnd, nCtlId1);
- const int hMin2 = GetDlgCtrlHeight(hwnd, nCtlId2);
- ResizeDlg_InitEx(hwnd, cxFrame, cyFrame, nIdGrip, iDirection);
- PRESIZEDLG pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
- pm->attrs[0] = hMin1;
- pm->attrs[1] = hMin2;
+ const int hMin1 = GetDlgCtrlHeight(hwnd, nCtlId1);
+ const int hMin2 = GetDlgCtrlHeight(hwnd, nCtlId2);
+ ResizeDlg_InitEx(hwnd, cxFrame, cyFrame, nIdGrip, iDirection);
+ PRESIZEDLG pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
+ pm->attrs[0] = hMin1;
+ pm->attrs[1] = hMin2;
}
int ResizeDlg_CalcDeltaY2(HWND hwnd, int dy, int cy, int nCtlId1, int nCtlId2)
{
- if (dy == 0) {
- return FALSE;
- }
- if (dy > 0) {
- return MulDiv(dy, cy, 100);
- }
- const LPCRESIZEDLG pm = (LPCRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
+ if (dy == 0) {
+ return FALSE;
+ }
+ if (dy > 0) {
+ return MulDiv(dy, cy, 100);
+ }
+ const LPCRESIZEDLG pm = (LPCRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
#if NP3_ENABLE_RESIZEDLG_TEMP_FIX
- UINT const dpi = Scintilla_GetWindowDPI(hwnd);
- int const hMinX = MulDiv(pm->attrs[0], dpi, pm->dpi);
- int const hMinY = MulDiv(pm->attrs[1], dpi, pm->dpi);
+ UINT const dpi = Scintilla_GetWindowDPI(hwnd);
+ int const hMinX = MulDiv(pm->attrs[0], dpi, pm->dpi);
+ int const hMinY = MulDiv(pm->attrs[1], dpi, pm->dpi);
#else
- int const hMinX = pm->attrs[0];
- int const hMinY = pm->attrs[1];
+ int const hMinX = pm->attrs[0];
+ int const hMinY = pm->attrs[1];
#endif
- int const h1 = GetDlgCtrlHeight(hwnd, nCtlId1);
- int const h2 = GetDlgCtrlHeight(hwnd, nCtlId2);
- // cy + h1 >= hMin1 cy >= hMin1 - h1
- // dy - cy + h2 >= hMin2 cy <= dy + h2 - hMin2
- int const cyMin = hMinX - h1;
- int const cyMax = dy + h2 - hMinY;
- cy = dy - MulDiv(dy, 100 - cy, 100);
- cy = clampi(cy, cyMin, cyMax);
- return cy;
+ int const h1 = GetDlgCtrlHeight(hwnd, nCtlId1);
+ int const h2 = GetDlgCtrlHeight(hwnd, nCtlId2);
+ // cy + h1 >= hMin1 cy >= hMin1 - h1
+ // dy - cy + h2 >= hMin2 cy <= dy + h2 - hMin2
+ int const cyMin = hMinX - h1;
+ int const cyMax = dy + h2 - hMinY;
+ cy = dy - MulDiv(dy, 100 - cy, 100);
+ cy = clampi(cy, cyMin, cyMax);
+ return cy;
}
HDWP DeferCtlPos(HDWP hdwp, HWND hwndDlg, int nCtlId, int dx, int dy, UINT uFlags)
{
- HWND const hwndCtl = GetDlgItem(hwndDlg, nCtlId);
- RECT rc;
- GetWindowRect(hwndCtl, &rc);
- MapWindowPoints(NULL, hwndDlg, (LPPOINT)& rc, 2);
- if (uFlags & SWP_NOSIZE) {
- return DeferWindowPos(hdwp, hwndCtl, NULL, rc.left + dx, rc.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- }
- return DeferWindowPos(hdwp, hwndCtl, NULL, 0, 0, rc.right - rc.left + dx, rc.bottom - rc.top + dy, SWP_NOZORDER | SWP_NOMOVE);
+ HWND const hwndCtl = GetDlgItem(hwndDlg, nCtlId);
+ RECT rc;
+ GetWindowRect(hwndCtl, &rc);
+ MapWindowPoints(NULL, hwndDlg, (LPPOINT)& rc, 2);
+ if (uFlags & SWP_NOSIZE) {
+ return DeferWindowPos(hdwp, hwndCtl, NULL, rc.left + dx, rc.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ }
+ return DeferWindowPos(hdwp, hwndCtl, NULL, 0, 0, rc.right - rc.left + dx, rc.bottom - rc.top + dy, SWP_NOZORDER | SWP_NOMOVE);
}
void ResizeDlgCtl(HWND hwndDlg, int nCtlId, int dx, int dy)
{
- HWND const hwndCtl = GetDlgItem(hwndDlg, nCtlId);
- RECT rc;
- GetWindowRect(hwndCtl, &rc);
- MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc, 2);
- SetWindowPos(hwndCtl, NULL, 0, 0, rc.right - rc.left + dx, rc.bottom - rc.top + dy, SWP_NOZORDER | SWP_NOMOVE);
- InvalidateRect(hwndCtl, NULL, TRUE);
+ HWND const hwndCtl = GetDlgItem(hwndDlg, nCtlId);
+ RECT rc;
+ GetWindowRect(hwndCtl, &rc);
+ MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc, 2);
+ SetWindowPos(hwndCtl, NULL, 0, 0, rc.right - rc.left + dx, rc.bottom - rc.top + dy, SWP_NOZORDER | SWP_NOMOVE);
+ InvalidateRect(hwndCtl, NULL, TRUE);
}
@@ -5471,11 +5471,11 @@ void ResizeDlgCtl(HWND hwndDlg, int nCtlId, int dx, int dy)
//
void SetBitmapControl(HWND hwnd, int nCtrlId, HBITMAP hBmp)
{
- HBITMAP hBmpOld = (HBITMAP)SendDlgItemMessage(hwnd, nCtrlId, STM_GETIMAGE, IMAGE_BITMAP, 0);
- if (hBmpOld) {
- DeleteObject(hBmpOld);
- }
- SendDlgItemMessage(hwnd, nCtrlId, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmp);
+ HBITMAP hBmpOld = (HBITMAP)SendDlgItemMessage(hwnd, nCtrlId, STM_GETIMAGE, IMAGE_BITMAP, 0);
+ if (hBmpOld) {
+ DeleteObject(hBmpOld);
+ }
+ SendDlgItemMessage(hwnd, nCtrlId, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmp);
}
@@ -5486,13 +5486,13 @@ void SetBitmapControl(HWND hwnd, int nCtrlId, HBITMAP hBmp)
//
void SetBitmapControlResample(HWND hwnd, int nCtrlId, HBITMAP hBmp, int width, int height)
{
- if ((width == 0) || (height == 0)) {
- width = GetDlgCtrlWidth(hwnd, nCtrlId);
- height = GetDlgCtrlHeight(hwnd, nCtrlId);
- }
- hBmp = ResampleImageBitmap(hwnd, hBmp, width, height);
+ if ((width == 0) || (height == 0)) {
+ width = GetDlgCtrlWidth(hwnd, nCtrlId);
+ height = GetDlgCtrlHeight(hwnd, nCtrlId);
+ }
+ hBmp = ResampleImageBitmap(hwnd, hBmp, width, height);
- SetBitmapControl(hwnd, nCtrlId, hBmp);
+ SetBitmapControl(hwnd, nCtrlId, hBmp);
}
@@ -5503,25 +5503,25 @@ void SetBitmapControlResample(HWND hwnd, int nCtrlId, HBITMAP hBmp, int width, i
//
void MakeBitmapButton(HWND hwnd, int nCtrlId, WORD uBmpId, int width, int height)
{
- HWND const hwndCtrl = GetDlgItem(hwnd, nCtrlId);
- if ((width == 0) || (height == 0)) {
- width = GetDlgCtrlWidth(hwnd, nCtrlId);
- height = GetDlgCtrlHeight(hwnd, nCtrlId);
- }
- HBITMAP hBmp = LoadImage(Globals.hInstance, MAKEINTRESOURCE(uBmpId), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
- hBmp = ResampleImageBitmap(hwnd, hBmp, width, height);
+ HWND const hwndCtrl = GetDlgItem(hwnd, nCtrlId);
+ if ((width == 0) || (height == 0)) {
+ width = GetDlgCtrlWidth(hwnd, nCtrlId);
+ height = GetDlgCtrlHeight(hwnd, nCtrlId);
+ }
+ HBITMAP hBmp = LoadImage(Globals.hInstance, MAKEINTRESOURCE(uBmpId), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ hBmp = ResampleImageBitmap(hwnd, hBmp, width, height);
- BITMAP bmp = { 0 };
- GetObject(hBmp, sizeof(BITMAP), &bmp);
- BUTTON_IMAGELIST bi = { 0 };
- bi.himl = ImageList_Create(bmp.bmWidth, bmp.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
- ImageList_AddMasked(bi.himl, hBmp, CLR_DEFAULT);
+ BITMAP bmp = { 0 };
+ GetObject(hBmp, sizeof(BITMAP), &bmp);
+ BUTTON_IMAGELIST bi = { 0 };
+ bi.himl = ImageList_Create(bmp.bmWidth, bmp.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
+ ImageList_AddMasked(bi.himl, hBmp, CLR_DEFAULT);
- DeleteObject(hBmp);
+ DeleteObject(hBmp);
- SetRect(&bi.margin, 0, 0, 0, 0);
- bi.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
- SendMessage(hwndCtrl, BCM_SETIMAGELIST, 0, (LPARAM)&bi);
+ SetRect(&bi.margin, 0, 0, 0, 0);
+ bi.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
+ SendMessage(hwndCtrl, BCM_SETIMAGELIST, 0, (LPARAM)&bi);
}
@@ -5531,49 +5531,49 @@ void MakeBitmapButton(HWND hwnd, int nCtrlId, WORD uBmpId, int width, int height
//
void MakeColorPickButton(HWND hwnd, int nCtrlId, HINSTANCE hInstance, COLORREF crColor)
{
- HWND const hwndCtl = GetDlgItem(hwnd, nCtrlId);
- HIMAGELIST himlOld = NULL;
- COLORMAP colormap[2] = { {0,0}, {0,0} };
+ HWND const hwndCtl = GetDlgItem(hwnd, nCtrlId);
+ HIMAGELIST himlOld = NULL;
+ COLORMAP colormap[2] = { {0,0}, {0,0} };
- BUTTON_IMAGELIST bi = { 0 };
- if (SendMessage(hwndCtl, BCM_GETIMAGELIST, 0, (LPARAM)&bi)) {
- himlOld = bi.himl;
- }
- if (IsWindowEnabled(hwndCtl) && (crColor != COLORREF_MAX)) {
- colormap[0].from = RGB(0x00, 0x00, 0x00);
- colormap[0].to = GetSysColor(COLOR_3DSHADOW);
- } else {
- colormap[0].from = RGB(0x00, 0x00, 0x00);
- colormap[0].to = RGB(0xFF, 0xFF, 0xFF);
- }
+ BUTTON_IMAGELIST bi = { 0 };
+ if (SendMessage(hwndCtl, BCM_GETIMAGELIST, 0, (LPARAM)&bi)) {
+ himlOld = bi.himl;
+ }
+ if (IsWindowEnabled(hwndCtl) && (crColor != COLORREF_MAX)) {
+ colormap[0].from = RGB(0x00, 0x00, 0x00);
+ colormap[0].to = GetSysColor(COLOR_3DSHADOW);
+ } else {
+ colormap[0].from = RGB(0x00, 0x00, 0x00);
+ colormap[0].to = RGB(0xFF, 0xFF, 0xFF);
+ }
- if (IsWindowEnabled(hwndCtl) && (crColor != COLORREF_MAX)) {
+ if (IsWindowEnabled(hwndCtl) && (crColor != COLORREF_MAX)) {
- if (crColor == RGB(0xFF, 0xFF, 0xFF)) {
- crColor = RGB(0xFF, 0xFF, 0xFE);
- }
- colormap[1].from = RGB(0xFF, 0xFF, 0xFF);
- colormap[1].to = crColor;
- } else {
- colormap[1].from = RGB(0xFF, 0xFF, 0xFF);
- colormap[1].to = RGB(0xFF, 0xFF, 0xFF);
- }
+ if (crColor == RGB(0xFF, 0xFF, 0xFF)) {
+ crColor = RGB(0xFF, 0xFF, 0xFE);
+ }
+ colormap[1].from = RGB(0xFF, 0xFF, 0xFF);
+ colormap[1].to = crColor;
+ } else {
+ colormap[1].from = RGB(0xFF, 0xFF, 0xFF);
+ colormap[1].to = RGB(0xFF, 0xFF, 0xFF);
+ }
- HBITMAP hBmp = CreateMappedBitmap(hInstance, IDB_PICK, 0, colormap, 2);
+ HBITMAP hBmp = CreateMappedBitmap(hInstance, IDB_PICK, 0, colormap, 2);
- bi.himl = ImageList_Create(10, 10, ILC_COLORDDB | ILC_MASK, 1, 0);
- ImageList_AddMasked(bi.himl, hBmp, RGB(0xFF, 0xFF, 0xFF));
- DeleteObject(hBmp);
+ bi.himl = ImageList_Create(10, 10, ILC_COLORDDB | ILC_MASK, 1, 0);
+ ImageList_AddMasked(bi.himl, hBmp, RGB(0xFF, 0xFF, 0xFF));
+ DeleteObject(hBmp);
- SetRect(&bi.margin, 0, 0, 4, 0);
- bi.uAlign = BUTTON_IMAGELIST_ALIGN_RIGHT;
+ SetRect(&bi.margin, 0, 0, 4, 0);
+ bi.uAlign = BUTTON_IMAGELIST_ALIGN_RIGHT;
- SendMessage(hwndCtl, BCM_SETIMAGELIST, 0, (LPARAM)&bi);
- InvalidateRect(hwndCtl, NULL, TRUE);
+ SendMessage(hwndCtl, BCM_SETIMAGELIST, 0, (LPARAM)&bi);
+ InvalidateRect(hwndCtl, NULL, TRUE);
- if (himlOld) {
- ImageList_Destroy(himlOld);
- }
+ if (himlOld) {
+ ImageList_Destroy(himlOld);
+ }
}
@@ -5583,11 +5583,11 @@ void MakeColorPickButton(HWND hwnd, int nCtrlId, HINSTANCE hInstance, COLORREF c
//
void DeleteBitmapButton(HWND hwnd, int nCtrlId)
{
- HWND const hwndCtl = GetDlgItem(hwnd, nCtrlId);
- BUTTON_IMAGELIST bi = { 0 };
- if (SendMessage(hwndCtl, BCM_GETIMAGELIST, 0, (LPARAM)&bi)) {
- ImageList_Destroy(bi.himl);
- }
+ HWND const hwndCtl = GetDlgItem(hwnd, nCtrlId);
+ BUTTON_IMAGELIST bi = { 0 };
+ if (SendMessage(hwndCtl, BCM_GETIMAGELIST, 0, (LPARAM)&bi)) {
+ ImageList_Destroy(bi.himl);
+ }
}
@@ -5597,15 +5597,15 @@ void DeleteBitmapButton(HWND hwnd, int nCtrlId)
//
void StatusSetText(HWND hwnd, BYTE nPart, LPCWSTR lpszText)
{
- if (lpszText) {
- bool const bSimplSB = (nPart == SB_SIMPLEID);
- if (bSimplSB) {
- int aSingleSect[1] = { -1 };
- SendMessage(hwnd, SB_SETPARTS, (WPARAM)1, (LPARAM)aSingleSect);
- }
- DWORD const wParam = (bSimplSB ? 0 : nPart) | SBT_OWNERDRAW;
- SendMessage(hwnd, SB_SETTEXT, (WPARAM)wParam, (LPARAM)lpszText);
- }
+ if (lpszText) {
+ bool const bSimplSB = (nPart == SB_SIMPLEID);
+ if (bSimplSB) {
+ int aSingleSect[1] = { -1 };
+ SendMessage(hwnd, SB_SETPARTS, (WPARAM)1, (LPARAM)aSingleSect);
+ }
+ DWORD const wParam = (bSimplSB ? 0 : nPart) | SBT_OWNERDRAW;
+ SendMessage(hwnd, SB_SETTEXT, (WPARAM)wParam, (LPARAM)lpszText);
+ }
}
//=============================================================================
@@ -5614,22 +5614,22 @@ void StatusSetText(HWND hwnd, BYTE nPart, LPCWSTR lpszText)
//
void StatusSetTextID(HWND hwnd, BYTE nPart, UINT uID)
{
- bool const bSimplSB = (nPart == SB_SIMPLEID);
- if (bSimplSB) {
- int aSingleSect[1] = { -1 };
- SendMessage(hwnd, SB_SETPARTS, (WPARAM)1, (LPARAM)aSingleSect);
- }
- DWORD const wParam = (bSimplSB ? 0 : nPart) | SBT_OWNERDRAW;
- if (!uID) {
- SendMessage(hwnd, SB_SETTEXT, (WPARAM)wParam, (LPARAM)L"");
- } else {
- WCHAR szText[MAX_PATH] = { L'\0' };
- if (!GetLngString(uID, szText, COUNTOF(szText))) {
- SendMessage(hwnd, SB_SETTEXT, (WPARAM)wParam, (LPARAM)L"");
- } else {
- SendMessage(hwnd, SB_SETTEXT, (WPARAM)wParam, (LPARAM)szText);
- }
- }
+ bool const bSimplSB = (nPart == SB_SIMPLEID);
+ if (bSimplSB) {
+ int aSingleSect[1] = { -1 };
+ SendMessage(hwnd, SB_SETPARTS, (WPARAM)1, (LPARAM)aSingleSect);
+ }
+ DWORD const wParam = (bSimplSB ? 0 : nPart) | SBT_OWNERDRAW;
+ if (!uID) {
+ SendMessage(hwnd, SB_SETTEXT, (WPARAM)wParam, (LPARAM)L"");
+ } else {
+ WCHAR szText[MAX_PATH] = { L'\0' };
+ if (!GetLngString(uID, szText, COUNTOF(szText))) {
+ SendMessage(hwnd, SB_SETTEXT, (WPARAM)wParam, (LPARAM)L"");
+ } else {
+ SendMessage(hwnd, SB_SETTEXT, (WPARAM)wParam, (LPARAM)szText);
+ }
+ }
}
@@ -5639,61 +5639,61 @@ void StatusSetTextID(HWND hwnd, BYTE nPart, UINT uID)
//
int Toolbar_GetButtons(HANDLE hwnd, int cmdBase, LPWSTR lpszButtons, int cchButtons)
{
- WCHAR tchButtons[512] = { L'\0' };
- WCHAR tchItem[32] = { L'\0' };
+ WCHAR tchButtons[512] = { L'\0' };
+ WCHAR tchItem[32] = { L'\0' };
- StringCchCopy(tchButtons, COUNTOF(tchButtons), L"");
- int const cnt = min_i(50, (int)SendMessage(hwnd, TB_BUTTONCOUNT, 0, 0));
+ StringCchCopy(tchButtons, COUNTOF(tchButtons), L"");
+ int const cnt = min_i(50, (int)SendMessage(hwnd, TB_BUTTONCOUNT, 0, 0));
- for (int i = 0; i < cnt; i++) {
- TBBUTTON tbb = { 0 };
- SendMessage(hwnd, TB_GETBUTTON, (WPARAM)i, (LPARAM)&tbb);
- StringCchPrintf(tchItem, COUNTOF(tchItem), L"%i ",
- (tbb.idCommand == 0) ? 0 : tbb.idCommand - cmdBase + 1);
- StringCchCat(tchButtons, COUNTOF(tchButtons), tchItem);
- }
- TrimSpcW(tchButtons);
- StringCchCopyN(lpszButtons, cchButtons, tchButtons, COUNTOF(tchButtons));
- return cnt;
+ for (int i = 0; i < cnt; i++) {
+ TBBUTTON tbb = { 0 };
+ SendMessage(hwnd, TB_GETBUTTON, (WPARAM)i, (LPARAM)&tbb);
+ StringCchPrintf(tchItem, COUNTOF(tchItem), L"%i ",
+ (tbb.idCommand == 0) ? 0 : tbb.idCommand - cmdBase + 1);
+ StringCchCat(tchButtons, COUNTOF(tchButtons), tchItem);
+ }
+ TrimSpcW(tchButtons);
+ StringCchCopyN(lpszButtons, cchButtons, tchButtons, COUNTOF(tchButtons));
+ return cnt;
}
int Toolbar_SetButtons(HANDLE hwnd, int cmdBase, LPCWSTR lpszButtons, LPCTBBUTTON ptbb, int ctbb)
{
- WCHAR tchButtons[MIDSZ_BUFFER];
- ZeroMemory(tchButtons, COUNTOF(tchButtons) * sizeof(tchButtons[0]));
- StringCchCopyN(tchButtons, COUNTOF(tchButtons), lpszButtons, COUNTOF(tchButtons) - 2);
- TrimSpcW(tchButtons);
- WCHAR *p = StrStr(tchButtons, L" ");
- while (p) {
- MoveMemory((WCHAR*)p, (WCHAR*)p + 1, (StringCchLen(p,0) + 1) * sizeof(WCHAR));
- p = StrStr(tchButtons, L" "); // next
- }
- int const c = (int)SendMessage(hwnd, TB_BUTTONCOUNT, 0, 0);
- for (int i = 0; i < c; i++) {
- SendMessage(hwnd, TB_DELETEBUTTON, 0, 0);
- }
- for (int i = 0; i < COUNTOF(tchButtons); i++) {
- if (tchButtons[i] == L' ') {
- tchButtons[i] = 0;
- }
- }
- p = tchButtons;
- while (*p) {
- int iCmd;
- //if (swscanf_s(p, L"%i", &iCmd) == 1) {
- if (StrToIntEx(p, STIF_DEFAULT, &iCmd)) {
- iCmd = (iCmd == 0) ? 0 : iCmd + cmdBase - 1;
- for (int i = 0; i < ctbb; i++) {
- if (ptbb[i].idCommand == iCmd) {
- SendMessage(hwnd, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&ptbb[i]);
- break;
- }
- }
- }
- p = StrEnd(p,0) + 1;
- }
- return((int)SendMessage(hwnd, TB_BUTTONCOUNT, 0, 0));
+ WCHAR tchButtons[MIDSZ_BUFFER];
+ ZeroMemory(tchButtons, COUNTOF(tchButtons) * sizeof(tchButtons[0]));
+ StringCchCopyN(tchButtons, COUNTOF(tchButtons), lpszButtons, COUNTOF(tchButtons) - 2);
+ TrimSpcW(tchButtons);
+ WCHAR *p = StrStr(tchButtons, L" ");
+ while (p) {
+ MoveMemory((WCHAR*)p, (WCHAR*)p + 1, (StringCchLen(p,0) + 1) * sizeof(WCHAR));
+ p = StrStr(tchButtons, L" "); // next
+ }
+ int const c = (int)SendMessage(hwnd, TB_BUTTONCOUNT, 0, 0);
+ for (int i = 0; i < c; i++) {
+ SendMessage(hwnd, TB_DELETEBUTTON, 0, 0);
+ }
+ for (int i = 0; i < COUNTOF(tchButtons); i++) {
+ if (tchButtons[i] == L' ') {
+ tchButtons[i] = 0;
+ }
+ }
+ p = tchButtons;
+ while (*p) {
+ int iCmd;
+ //if (swscanf_s(p, L"%i", &iCmd) == 1) {
+ if (StrToIntEx(p, STIF_DEFAULT, &iCmd)) {
+ iCmd = (iCmd == 0) ? 0 : iCmd + cmdBase - 1;
+ for (int i = 0; i < ctbb; i++) {
+ if (ptbb[i].idCommand == iCmd) {
+ SendMessage(hwnd, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&ptbb[i]);
+ break;
+ }
+ }
+ }
+ p = StrEnd(p,0) + 1;
+ }
+ return((int)SendMessage(hwnd, TB_BUTTONCOUNT, 0, 0));
}
//=============================================================================
@@ -5702,12 +5702,12 @@ int Toolbar_SetButtons(HANDLE hwnd, int cmdBase, LPCWSTR lpszButtons, LPCTBBUTTO
// (font size) points per inch
//
UINT GetCurrentPPI(HWND hwnd) {
- HDC const hDC = GetDC(hwnd);
- UINT ppi = 0;
- //ppi.x = max_u(GetDeviceCaps(hDC, LOGPIXELSX), USER_DEFAULT_SCREEN_DPI);
- ppi = max_u(GetDeviceCaps(hDC, LOGPIXELSY), USER_DEFAULT_SCREEN_DPI);
- ReleaseDC(hwnd, hDC);
- return ppi;
+ HDC const hDC = GetDC(hwnd);
+ UINT ppi = 0;
+ //ppi.x = max_u(GetDeviceCaps(hDC, LOGPIXELSX), USER_DEFAULT_SCREEN_DPI);
+ ppi = max_u(GetDeviceCaps(hDC, LOGPIXELSY), USER_DEFAULT_SCREEN_DPI);
+ ReleaseDC(hwnd, hDC);
+ return ppi;
}
@@ -5720,221 +5720,221 @@ Based on code of MFC helper class CDialogTemplate
*/
static inline bool IsChineseTraditionalSubLang(LANGID subLang)
{
- return subLang == SUBLANG_CHINESE_TRADITIONAL || subLang == SUBLANG_CHINESE_HONGKONG || subLang == SUBLANG_CHINESE_MACAU;
+ return subLang == SUBLANG_CHINESE_TRADITIONAL || subLang == SUBLANG_CHINESE_HONGKONG || subLang == SUBLANG_CHINESE_MACAU;
}
bool GetLocaleDefaultUIFont(LANGID lang, LPWSTR lpFaceName, WORD* wSize)
{
- LPCWSTR font;
- LANGID const subLang = SUBLANGID(lang);
- switch (PRIMARYLANGID(lang)) {
- default:
- case LANG_ENGLISH:
- font = L"Segoe UI";
- *wSize = 9;
- break;
- case LANG_CHINESE:
- font = IsChineseTraditionalSubLang(subLang) ? L"Microsoft JhengHei UI" : L"Microsoft YaHei UI";
- *wSize = 9;
- break;
- case LANG_JAPANESE:
- font = L"Yu Gothic UI";
- *wSize = 9;
- break;
- case LANG_KOREAN:
- font = L"Malgun Gothic";
- *wSize = 9;
- break;
- }
- bool const isAvail = IsFontAvailable(font);
- if (isAvail) {
- StringCchCopy(lpFaceName, LF_FACESIZE, font);
- }
- return isAvail;
+ LPCWSTR font;
+ LANGID const subLang = SUBLANGID(lang);
+ switch (PRIMARYLANGID(lang)) {
+ default:
+ case LANG_ENGLISH:
+ font = L"Segoe UI";
+ *wSize = 9;
+ break;
+ case LANG_CHINESE:
+ font = IsChineseTraditionalSubLang(subLang) ? L"Microsoft JhengHei UI" : L"Microsoft YaHei UI";
+ *wSize = 9;
+ break;
+ case LANG_JAPANESE:
+ font = L"Yu Gothic UI";
+ *wSize = 9;
+ break;
+ case LANG_KOREAN:
+ font = L"Malgun Gothic";
+ *wSize = 9;
+ break;
+ }
+ bool const isAvail = IsFontAvailable(font);
+ if (isAvail) {
+ StringCchCopy(lpFaceName, LF_FACESIZE, font);
+ }
+ return isAvail;
}
bool GetThemedDialogFont(LPWSTR lpFaceName, WORD* wSize)
{
- // deprecated:
- LANGID const langID = GetLangIdByLocaleName(Globals.CurrentLngLocaleName);
- bool bSucceed = GetLocaleDefaultUIFont(langID, lpFaceName, wSize);
+ // deprecated:
+ LANGID const langID = GetLangIdByLocaleName(Globals.CurrentLngLocaleName);
+ bool bSucceed = GetLocaleDefaultUIFont(langID, lpFaceName, wSize);
- if (!bSucceed) {
- if (IsAppThemed()) {
- unsigned const iLogPixelsY = GetCurrentPPI(NULL) - DIALOG_FONT_SIZE_INCR;
+ if (!bSucceed) {
+ if (IsAppThemed()) {
+ unsigned const iLogPixelsY = GetCurrentPPI(NULL) - DIALOG_FONT_SIZE_INCR;
- HTHEME hTheme = OpenThemeData(NULL, L"WINDOWSTYLE;WINDOW");
- if (hTheme) {
- LOGFONT lf;
- if (S_OK == GetThemeSysFont(hTheme, TMT_MSGBOXFONT, &lf)) {
- if (lf.lfHeight < 0) {
- lf.lfHeight = -lf.lfHeight;
- }
- *wSize = (WORD)MulDiv(lf.lfHeight, 72, iLogPixelsY);
- if (*wSize < 9) {
- *wSize = 9;
- }
- StringCchCopy(lpFaceName, LF_FACESIZE, lf.lfFaceName);
- bSucceed = true;
- }
- CloseThemeData(hTheme);
- }
- }
+ HTHEME hTheme = OpenThemeData(NULL, L"WINDOWSTYLE;WINDOW");
+ if (hTheme) {
+ LOGFONT lf;
+ if (S_OK == GetThemeSysFont(hTheme, TMT_MSGBOXFONT, &lf)) {
+ if (lf.lfHeight < 0) {
+ lf.lfHeight = -lf.lfHeight;
+ }
+ *wSize = (WORD)MulDiv(lf.lfHeight, 72, iLogPixelsY);
+ if (*wSize < 9) {
+ *wSize = 9;
+ }
+ StringCchCopy(lpFaceName, LF_FACESIZE, lf.lfFaceName);
+ bSucceed = true;
+ }
+ CloseThemeData(hTheme);
+ }
+ }
- if (!bSucceed) {
- unsigned const iLogPixelsY = GetCurrentPPI(NULL) - DIALOG_FONT_SIZE_INCR;
+ if (!bSucceed) {
+ unsigned const iLogPixelsY = GetCurrentPPI(NULL) - DIALOG_FONT_SIZE_INCR;
- NONCLIENTMETRICS ncm = { 0 };
- ncm.cbSize = sizeof(NONCLIENTMETRICS) - sizeof(ncm.iPaddedBorderWidth);
- if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)) {
- if (ncm.lfMessageFont.lfHeight < 0) {
- ncm.lfMessageFont.lfHeight = -ncm.lfMessageFont.lfHeight;
- }
- *wSize = (WORD)MulDiv(ncm.lfMessageFont.lfHeight, 72, iLogPixelsY);
- if (*wSize < 9) {
- *wSize = 9;
- }
- StringCchCopy(lpFaceName, LF_FACESIZE, ncm.lfMessageFont.lfFaceName);
- bSucceed = true;
- }
- }
- }
+ NONCLIENTMETRICS ncm = { 0 };
+ ncm.cbSize = sizeof(NONCLIENTMETRICS) - sizeof(ncm.iPaddedBorderWidth);
+ if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)) {
+ if (ncm.lfMessageFont.lfHeight < 0) {
+ ncm.lfMessageFont.lfHeight = -ncm.lfMessageFont.lfHeight;
+ }
+ *wSize = (WORD)MulDiv(ncm.lfMessageFont.lfHeight, 72, iLogPixelsY);
+ if (*wSize < 9) {
+ *wSize = 9;
+ }
+ StringCchCopy(lpFaceName, LF_FACESIZE, ncm.lfMessageFont.lfFaceName);
+ bSucceed = true;
+ }
+ }
+ }
- return bSucceed;
+ return bSucceed;
}
static inline bool DialogTemplate_IsDialogEx(const DLGTEMPLATE* pTemplate)
{
- return ((DLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF;
+ return ((DLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF;
}
static inline bool DialogTemplate_HasFont(const DLGTEMPLATE* pTemplate)
{
- return (DS_SETFONT &
- (DialogTemplate_IsDialogEx(pTemplate) ? ((DLGTEMPLATEEX*)pTemplate)->style : pTemplate->style));
+ return (DS_SETFONT &
+ (DialogTemplate_IsDialogEx(pTemplate) ? ((DLGTEMPLATEEX*)pTemplate)->style : pTemplate->style));
}
static inline size_t DialogTemplate_FontAttrSize(bool bDialogEx)
{
- return (sizeof(WORD) * (bDialogEx ? 3 : 1));
+ return (sizeof(WORD) * (bDialogEx ? 3 : 1));
}
static inline BYTE* DialogTemplate_GetFontSizeField(const DLGTEMPLATE* pTemplate)
{
- bool bDialogEx = DialogTemplate_IsDialogEx(pTemplate);
- WORD* pw;
+ bool bDialogEx = DialogTemplate_IsDialogEx(pTemplate);
+ WORD* pw;
- if (bDialogEx) {
- pw = (WORD*)((DLGTEMPLATEEX*)pTemplate + 1);
- } else {
- pw = (WORD*)(pTemplate + 1);
- }
+ if (bDialogEx) {
+ pw = (WORD*)((DLGTEMPLATEEX*)pTemplate + 1);
+ } else {
+ pw = (WORD*)(pTemplate + 1);
+ }
- if (*pw == WORD_MAX) {
- pw += 2;
- } else
- while (*pw++) {}
+ if (*pw == WORD_MAX) {
+ pw += 2;
+ } else
+ while (*pw++) {}
- if (*pw == WORD_MAX) {
- pw += 2;
- } else
- while (*pw++) {}
+ if (*pw == WORD_MAX) {
+ pw += 2;
+ } else
+ while (*pw++) {}
- while (*pw++) {}
+ while (*pw++) {}
- return (BYTE*)pw;
+ return (BYTE*)pw;
}
DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR lpDialogTemplateID, HINSTANCE hInstance)
{
- HRSRC const hRsrc = FindResource(hInstance, lpDialogTemplateID, RT_DIALOG);
- if (!hRsrc) {
- return NULL;
- }
+ HRSRC const hRsrc = FindResource(hInstance, lpDialogTemplateID, RT_DIALOG);
+ if (!hRsrc) {
+ return NULL;
+ }
- HGLOBAL const hRsrcMem = LoadResource(hInstance, hRsrc);
- DLGTEMPLATE* const pRsrcMem = hRsrcMem ? (DLGTEMPLATE*) LockResource(hRsrcMem) : NULL;
- if (!pRsrcMem) {
- return NULL;
- }
+ HGLOBAL const hRsrcMem = LoadResource(hInstance, hRsrc);
+ DLGTEMPLATE* const pRsrcMem = hRsrcMem ? (DLGTEMPLATE*) LockResource(hRsrcMem) : NULL;
+ if (!pRsrcMem) {
+ return NULL;
+ }
- size_t const dwTemplateSize = (size_t)SizeofResource(hInstance, hRsrc);
- DLGTEMPLATE* const pTemplate = dwTemplateSize ? (DLGTEMPLATE*)AllocMem(dwTemplateSize + LF_FACESIZE * 2, HEAP_ZERO_MEMORY) : NULL;
+ size_t const dwTemplateSize = (size_t)SizeofResource(hInstance, hRsrc);
+ DLGTEMPLATE* const pTemplate = dwTemplateSize ? (DLGTEMPLATE*)AllocMem(dwTemplateSize + LF_FACESIZE * 2, HEAP_ZERO_MEMORY) : NULL;
- if (!pTemplate) {
- UnlockResource(hRsrcMem);
- FreeResource(hRsrcMem);
- return NULL;
- }
+ if (!pTemplate) {
+ UnlockResource(hRsrcMem);
+ FreeResource(hRsrcMem);
+ return NULL;
+ }
- CopyMemory((BYTE*)pTemplate, pRsrcMem, dwTemplateSize);
- UnlockResource(hRsrcMem);
- FreeResource(hRsrcMem);
+ CopyMemory((BYTE*)pTemplate, pRsrcMem, dwTemplateSize);
+ UnlockResource(hRsrcMem);
+ FreeResource(hRsrcMem);
- WCHAR wchFaceName[LF_FACESIZE] = {L'\0'};
- WORD wFontSize = 0;
- if (!GetThemedDialogFont(wchFaceName, &wFontSize)) {
- return (pTemplate);
- }
+ WCHAR wchFaceName[LF_FACESIZE] = {L'\0'};
+ WORD wFontSize = 0;
+ if (!GetThemedDialogFont(wchFaceName, &wFontSize)) {
+ return (pTemplate);
+ }
- bool const bDialogEx = DialogTemplate_IsDialogEx(pTemplate);
- bool const bHasFont = DialogTemplate_HasFont(pTemplate);
- size_t const cbFontAttr = DialogTemplate_FontAttrSize(bDialogEx);
+ bool const bDialogEx = DialogTemplate_IsDialogEx(pTemplate);
+ bool const bHasFont = DialogTemplate_HasFont(pTemplate);
+ size_t const cbFontAttr = DialogTemplate_FontAttrSize(bDialogEx);
- if (bDialogEx) {
- ((DLGTEMPLATEEX*)pTemplate)->style |= DS_SHELLFONT;
- } else {
- pTemplate->style |= DS_SHELLFONT;
- }
+ if (bDialogEx) {
+ ((DLGTEMPLATEEX*)pTemplate)->style |= DS_SHELLFONT;
+ } else {
+ pTemplate->style |= DS_SHELLFONT;
+ }
- size_t const cbNew = cbFontAttr + ((StringCchLenW(wchFaceName, COUNTOF(wchFaceName)) + 1) * sizeof(WCHAR));
- BYTE* const pbNew = (BYTE*)wchFaceName;
+ size_t const cbNew = cbFontAttr + ((StringCchLenW(wchFaceName, COUNTOF(wchFaceName)) + 1) * sizeof(WCHAR));
+ BYTE* const pbNew = (BYTE*)wchFaceName;
- BYTE* pb = DialogTemplate_GetFontSizeField(pTemplate);
- size_t const cbOld = (bHasFont ? cbFontAttr + 2 * (StringCchLen((WCHAR*)(pb + cbFontAttr), 0) + 1) : 0);
+ BYTE* pb = DialogTemplate_GetFontSizeField(pTemplate);
+ size_t const cbOld = (bHasFont ? cbFontAttr + 2 * (StringCchLen((WCHAR*)(pb + cbFontAttr), 0) + 1) : 0);
- BYTE* const pOldControls = (BYTE*)(((DWORD_PTR)pb + cbOld + 3) & ~(DWORD_PTR)3);
- BYTE* const pNewControls = (BYTE*)(((DWORD_PTR)pb + cbNew + 3) & ~(DWORD_PTR)3);
+ BYTE* const pOldControls = (BYTE*)(((DWORD_PTR)pb + cbOld + 3) & ~(DWORD_PTR)3);
+ BYTE* const pNewControls = (BYTE*)(((DWORD_PTR)pb + cbNew + 3) & ~(DWORD_PTR)3);
- WORD const nCtrl = (bDialogEx ? ((DLGTEMPLATEEX*)pTemplate)->cDlgItems : pTemplate->cdit);
+ WORD const nCtrl = (bDialogEx ? ((DLGTEMPLATEEX*)pTemplate)->cDlgItems : pTemplate->cdit);
- if (cbNew != cbOld && nCtrl > 0) {
- MoveMemory(pNewControls, pOldControls, (dwTemplateSize - (pOldControls - (BYTE*)pTemplate)));
- }
+ if (cbNew != cbOld && nCtrl > 0) {
+ MoveMemory(pNewControls, pOldControls, (dwTemplateSize - (pOldControls - (BYTE*)pTemplate)));
+ }
- *(WORD*)pb = wFontSize;
- MoveMemory(pb + cbFontAttr, pbNew, (size_t)(cbNew - cbFontAttr));
+ *(WORD*)pb = wFontSize;
+ MoveMemory(pb + cbFontAttr, pbNew, (size_t)(cbNew - cbFontAttr));
- return pTemplate;
+ return pTemplate;
}
INT_PTR ThemedDialogBoxParam(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent,
- DLGPROC lpDialogFunc, LPARAM dwInitParam)
+ DLGPROC lpDialogFunc, LPARAM dwInitParam)
{
- DLGTEMPLATE* const pDlgTemplate = LoadThemedDialogTemplate(lpTemplate, hInstance);
- INT_PTR const ret = DialogBoxIndirectParam(hInstance, pDlgTemplate, hWndParent, lpDialogFunc, dwInitParam);
- if (pDlgTemplate) {
- FreeMem(pDlgTemplate);
- }
- return ret;
+ DLGTEMPLATE* const pDlgTemplate = LoadThemedDialogTemplate(lpTemplate, hInstance);
+ INT_PTR const ret = DialogBoxIndirectParam(hInstance, pDlgTemplate, hWndParent, lpDialogFunc, dwInitParam);
+ if (pDlgTemplate) {
+ FreeMem(pDlgTemplate);
+ }
+ return ret;
}
HWND CreateThemedDialogParam(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent,
- DLGPROC lpDialogFunc, LPARAM dwInitParam)
+ DLGPROC lpDialogFunc, LPARAM dwInitParam)
{
- DLGTEMPLATE* const pDlgTemplate = LoadThemedDialogTemplate(lpTemplate, hInstance);
- HWND const hwnd = CreateDialogIndirectParam(hInstance, pDlgTemplate, hWndParent, lpDialogFunc, dwInitParam);
- if (pDlgTemplate) {
- FreeMem(pDlgTemplate);
- }
- return hwnd;
+ DLGTEMPLATE* const pDlgTemplate = LoadThemedDialogTemplate(lpTemplate, hInstance);
+ HWND const hwnd = CreateDialogIndirectParam(hInstance, pDlgTemplate, hWndParent, lpDialogFunc, dwInitParam);
+ if (pDlgTemplate) {
+ FreeMem(pDlgTemplate);
+ }
+ return hwnd;
}
@@ -5944,44 +5944,44 @@ HWND CreateThemedDialogParam(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndP
//
static void _GetIconInfo(HICON hIcon, int* width, int* height, WORD* bitsPerPix)
{
- ICONINFO info = {0};
- if (!GetIconInfo(hIcon, &info)) {
- return;
- }
- if (info.hbmColor) {
- BITMAP bmp = {0};
- if (GetObject(info.hbmColor, sizeof(bmp), &bmp) > 0) {
- if (width) {
- *width = (int)bmp.bmWidth;
- }
- if (height) {
- *height = (int)bmp.bmHeight;
- }
- if (bitsPerPix) {
- *bitsPerPix = bmp.bmBitsPixel;
- }
- }
- } else if (info.hbmMask) {
- // Icon has no color plane, image data stored in mask
- BITMAP bmp = {0};
- if (GetObject(info.hbmMask, sizeof(bmp), &bmp) > 0) {
- if (width) {
- *width = (int)bmp.bmWidth;
- }
- if (height) {
- *height = (int)(bmp.bmHeight > 1);
- }
- if (bitsPerPix) {
- *bitsPerPix = 1;
- }
- }
- }
- if (info.hbmColor) {
- DeleteObject(info.hbmColor);
- }
- if (info.hbmMask) {
- DeleteObject(info.hbmMask);
- }
+ ICONINFO info = {0};
+ if (!GetIconInfo(hIcon, &info)) {
+ return;
+ }
+ if (info.hbmColor) {
+ BITMAP bmp = {0};
+ if (GetObject(info.hbmColor, sizeof(bmp), &bmp) > 0) {
+ if (width) {
+ *width = (int)bmp.bmWidth;
+ }
+ if (height) {
+ *height = (int)bmp.bmHeight;
+ }
+ if (bitsPerPix) {
+ *bitsPerPix = bmp.bmBitsPixel;
+ }
+ }
+ } else if (info.hbmMask) {
+ // Icon has no color plane, image data stored in mask
+ BITMAP bmp = {0};
+ if (GetObject(info.hbmMask, sizeof(bmp), &bmp) > 0) {
+ if (width) {
+ *width = (int)bmp.bmWidth;
+ }
+ if (height) {
+ *height = (int)(bmp.bmHeight > 1);
+ }
+ if (bitsPerPix) {
+ *bitsPerPix = 1;
+ }
+ }
+ }
+ if (info.hbmColor) {
+ DeleteObject(info.hbmColor);
+ }
+ if (info.hbmMask) {
+ DeleteObject(info.hbmMask);
+ }
}
@@ -5992,26 +5992,26 @@ static void _GetIconInfo(HICON hIcon, int* width, int* height, WORD* bitsPerPix)
//
HBITMAP ConvertIconToBitmap(const HICON hIcon, int cx, int cy)
{
- int wdc = cx;
- int hdc = cy;
- if ((cx <= 0) || (cy <= 0)) {
- _GetIconInfo(hIcon, &wdc, &hdc, NULL);
- cx = cy = 0;
- }
+ int wdc = cx;
+ int hdc = cy;
+ if ((cx <= 0) || (cy <= 0)) {
+ _GetIconInfo(hIcon, &wdc, &hdc, NULL);
+ cx = cy = 0;
+ }
- HDC const hScreenDC = GetDC(NULL);
- HBITMAP const hbmpTmp = CreateCompatibleBitmap(hScreenDC, wdc, hdc);
- HDC const hMemDC = CreateCompatibleDC(hScreenDC);
- HBITMAP const hOldBmp = SelectObject(hMemDC, hbmpTmp); // assign
- DrawIconEx(hMemDC, 0, 0, hIcon, wdc, hdc, 0, NULL, DI_NORMAL /*&~DI_DEFAULTSIZE*/);
- SelectObject(hMemDC, hOldBmp); // restore
+ HDC const hScreenDC = GetDC(NULL);
+ HBITMAP const hbmpTmp = CreateCompatibleBitmap(hScreenDC, wdc, hdc);
+ HDC const hMemDC = CreateCompatibleDC(hScreenDC);
+ HBITMAP const hOldBmp = SelectObject(hMemDC, hbmpTmp); // assign
+ DrawIconEx(hMemDC, 0, 0, hIcon, wdc, hdc, 0, NULL, DI_NORMAL /*&~DI_DEFAULTSIZE*/);
+ SelectObject(hMemDC, hOldBmp); // restore
- UINT const copyFlags = LR_COPYDELETEORG | LR_COPYRETURNORG | LR_DEFAULTSIZE | LR_CREATEDIBSECTION;
- HBITMAP const hDibBmp = (HBITMAP)CopyImage((HANDLE)hbmpTmp, IMAGE_BITMAP, cx, cy, copyFlags);
+ UINT const copyFlags = LR_COPYDELETEORG | LR_COPYRETURNORG | LR_DEFAULTSIZE | LR_CREATEDIBSECTION;
+ HBITMAP const hDibBmp = (HBITMAP)CopyImage((HANDLE)hbmpTmp, IMAGE_BITMAP, cx, cy, copyFlags);
- DeleteDC(hMemDC);
- ReleaseDC(NULL, hScreenDC);
- return hDibBmp;
+ DeleteDC(hMemDC);
+ ReleaseDC(NULL, hScreenDC);
+ return hDibBmp;
}
//=============================================================================
@@ -6020,12 +6020,12 @@ HBITMAP ConvertIconToBitmap(const HICON hIcon, int cx, int cy)
//
HBITMAP ResampleIconToBitmap(HWND hwnd, HBITMAP hOldBmp, const HICON hIcon, const int cx, const int cy)
{
- if (hOldBmp) {
- DeleteObject(hOldBmp);
- }
- //~return ConvertIconToBitmap(hwnd, hIcon, cx, cy);
- HBITMAP const hBmp = ConvertIconToBitmap(hIcon, 0, 0);
- return ResampleImageBitmap(hwnd, hBmp, cx, cy);
+ if (hOldBmp) {
+ DeleteObject(hOldBmp);
+ }
+ //~return ConvertIconToBitmap(hwnd, hIcon, cx, cy);
+ HBITMAP const hBmp = ConvertIconToBitmap(hIcon, 0, 0);
+ return ResampleImageBitmap(hwnd, hBmp, cx, cy);
}
//=============================================================================
@@ -6034,31 +6034,31 @@ HBITMAP ResampleIconToBitmap(HWND hwnd, HBITMAP hOldBmp, const HICON hIcon, cons
//
void SetUACIcon(HWND hwnd, const HMENU hMenu, const UINT nItem)
{
- static UINT dpi = 0; // (!) initially, to force first calculation
- static MENUITEMINFO mii = { 0 };
+ static UINT dpi = 0; // (!) initially, to force first calculation
+ static MENUITEMINFO mii = { 0 };
- UINT const cur_dpi = Scintilla_GetWindowDPI(hwnd);
+ UINT const cur_dpi = Scintilla_GetWindowDPI(hwnd);
- if (dpi != cur_dpi) {
+ if (dpi != cur_dpi) {
- int const scx = Scintilla_GetSystemMetricsForDpi(SM_CXSMICON, cur_dpi);
- int const scy = Scintilla_GetSystemMetricsForDpi(SM_CYSMICON, cur_dpi);
+ int const scx = Scintilla_GetSystemMetricsForDpi(SM_CXSMICON, cur_dpi);
+ int const scy = Scintilla_GetSystemMetricsForDpi(SM_CYSMICON, cur_dpi);
- if (!mii.cbSize) {
- mii.cbSize = sizeof(MENUITEMINFO);
- }
- if (!mii.fMask) {
- mii.fMask = MIIM_BITMAP;
- }
- if (mii.hbmpItem) {
- DeleteObject(mii.hbmpItem);
- }
- mii.hbmpItem = ConvertIconToBitmap(Globals.hIconMsgShield, scx, scy);
+ if (!mii.cbSize) {
+ mii.cbSize = sizeof(MENUITEMINFO);
+ }
+ if (!mii.fMask) {
+ mii.fMask = MIIM_BITMAP;
+ }
+ if (mii.hbmpItem) {
+ DeleteObject(mii.hbmpItem);
+ }
+ mii.hbmpItem = ConvertIconToBitmap(Globals.hIconMsgShield, scx, scy);
- SetMenuItemInfo(hMenu, nItem, FALSE, &mii);
+ SetMenuItemInfo(hMenu, nItem, FALSE, &mii);
- dpi = cur_dpi;
- }
+ dpi = cur_dpi;
+ }
}
@@ -6068,20 +6068,20 @@ void SetUACIcon(HWND hwnd, const HMENU hMenu, const UINT nItem)
//
void UpdateWindowLayoutForDPI(HWND hwnd, const RECT *pNewRect, const UINT adpi) {
- UINT const uWndFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED; //~ SWP_NOMOVE | SWP_NOSIZE | SWP_NOREPOSITION
+ UINT const uWndFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED; //~ SWP_NOMOVE | SWP_NOSIZE | SWP_NOREPOSITION
- if (pNewRect) {
- SetWindowPos(hwnd, NULL, pNewRect->left, pNewRect->top,
- (pNewRect->right - pNewRect->left), (pNewRect->bottom - pNewRect->top), uWndFlags);
- } else {
- RECT rc = { 0 };
- GetWindowRect(hwnd, &rc);
- //~MapWindowPoints(NULL, hWnd, (LPPOINT)&rc, 2);
- UINT const dpi = adpi ? adpi : Scintilla_GetWindowDPI(hwnd);
- Scintilla_AdjustWindowRectForDpi((LPWRECT)&rc, uWndFlags, 0, dpi);
- SetWindowPos(hwnd, NULL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), uWndFlags);
- }
- RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_ERASE | RDW_INTERNALPAINT | RDW_ALLCHILDREN | RDW_UPDATENOW);
+ if (pNewRect) {
+ SetWindowPos(hwnd, NULL, pNewRect->left, pNewRect->top,
+ (pNewRect->right - pNewRect->left), (pNewRect->bottom - pNewRect->top), uWndFlags);
+ } else {
+ RECT rc = { 0 };
+ GetWindowRect(hwnd, &rc);
+ //~MapWindowPoints(NULL, hWnd, (LPPOINT)&rc, 2);
+ UINT const dpi = adpi ? adpi : Scintilla_GetWindowDPI(hwnd);
+ Scintilla_AdjustWindowRectForDpi((LPWRECT)&rc, uWndFlags, 0, dpi);
+ SetWindowPos(hwnd, NULL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), uWndFlags);
+ }
+ RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_ERASE | RDW_INTERNALPAINT | RDW_ALLCHILDREN | RDW_UPDATENOW);
}
@@ -6092,30 +6092,30 @@ void UpdateWindowLayoutForDPI(HWND hwnd, const RECT *pNewRect, const UINT adpi)
//
HBITMAP ResampleImageBitmap(HWND hwnd, HBITMAP hbmp, int width, int height)
{
- if (hbmp) {
- BITMAP bmp = { 0 };
- if (GetObject(hbmp, sizeof(BITMAP), &bmp)) {
- if ((width <= 0) || (height <= 0)) {
- UINT const dpi = Scintilla_GetWindowDPI(hwnd);
- width = ScaleIntByDPI(bmp.bmWidth, dpi);
- height = ScaleIntByDPI(bmp.bmHeight, dpi);
- }
- if (((LONG)width != bmp.bmWidth) || ((LONG)height != bmp.bmHeight)) {
+ if (hbmp) {
+ BITMAP bmp = { 0 };
+ if (GetObject(hbmp, sizeof(BITMAP), &bmp)) {
+ if ((width <= 0) || (height <= 0)) {
+ UINT const dpi = Scintilla_GetWindowDPI(hwnd);
+ width = ScaleIntByDPI(bmp.bmWidth, dpi);
+ height = ScaleIntByDPI(bmp.bmHeight, dpi);
+ }
+ if (((LONG)width != bmp.bmWidth) || ((LONG)height != bmp.bmHeight)) {
#if TRUE
- HDC const hdc = GetDC(hwnd);
- HBITMAP hCopy = CreateResampledBitmap(hdc, hbmp, width, height, BMP_RESAMPLE_FILTER);
- ReleaseDC(hwnd, hdc);
+ HDC const hdc = GetDC(hwnd);
+ HBITMAP hCopy = CreateResampledBitmap(hdc, hbmp, width, height, BMP_RESAMPLE_FILTER);
+ ReleaseDC(hwnd, hdc);
#else
- HBITMAP hCopy = CopyImage(hbmp, IMAGE_BITMAP, width, height, LR_CREATEDIBSECTION | LR_COPYRETURNORG | LR_COPYDELETEORG);
+ HBITMAP hCopy = CopyImage(hbmp, IMAGE_BITMAP, width, height, LR_CREATEDIBSECTION | LR_COPYRETURNORG | LR_COPYDELETEORG);
#endif
- if (hCopy && (hCopy != hbmp)) {
- DeleteObject(hbmp);
- hbmp = hCopy;
- }
- }
- }
- }
- return hbmp;
+ if (hCopy && (hCopy != hbmp)) {
+ DeleteObject(hbmp);
+ hbmp = hCopy;
+ }
+ }
+ }
+ }
+ return hbmp;
}
@@ -6125,12 +6125,12 @@ HBITMAP ResampleImageBitmap(HWND hwnd, HBITMAP hbmp, int width, int height)
//
LRESULT SendWMSize(HWND hwnd, RECT* rc)
{
- if (rc) {
- return SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(rc->right, rc->bottom));
- }
- RECT wndrc;
- GetClientRect(hwnd, &wndrc);
- return SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(wndrc.right, wndrc.bottom));
+ if (rc) {
+ return SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(rc->right, rc->bottom));
+ }
+ RECT wndrc;
+ GetClientRect(hwnd, &wndrc);
+ return SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(wndrc.right, wndrc.bottom));
}
@@ -6142,107 +6142,107 @@ LRESULT SendWMSize(HWND hwnd, RECT* rc)
WCHAR FontSelTitle[128];
INT_PTR CALLBACK FontDialogHookProc(
- HWND hdlg, // handle to the dialog box window
- UINT uiMsg, // message identifier
- WPARAM wParam, // message parameter
- LPARAM lParam // message parameter
+ HWND hdlg, // handle to the dialog box window
+ UINT uiMsg, // message identifier
+ WPARAM wParam, // message parameter
+ LPARAM lParam // message parameter
) {
- UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(wParam);
- static UINT dpi = USER_DEFAULT_SCREEN_DPI;
+ static UINT dpi = USER_DEFAULT_SCREEN_DPI;
- switch (uiMsg) {
+ switch (uiMsg) {
- case WM_INITDIALOG: {
+ case WM_INITDIALOG: {
- if (Globals.hDlgIconSmall) {
- SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIconSmall);
- }
+ if (Globals.hDlgIconSmall) {
+ SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIconSmall);
+ }
- InitWindowCommon(hdlg, true);
+ InitWindowCommon(hdlg, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hdlg, IDOK));
- SetExplorerTheme(GetDlgItem(hdlg, IDCANCEL));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { grp1, grp2, chx1, chx2, cmb1, cmb2, cmb3, cmb4, cmb5, stc1, stc2, stc3, stc4, stc5, stc6, stc7 };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hdlg, ctl[i]), L"", L""); // remove theme
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hdlg, IDOK));
+ SetExplorerTheme(GetDlgItem(hdlg, IDCANCEL));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { grp1, grp2, chx1, chx2, cmb1, cmb2, cmb3, cmb4, cmb5, stc1, stc2, stc3, stc4, stc5, stc6, stc7 };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hdlg, ctl[i]), L"", L""); // remove theme
+ }
+ }
#endif
- dpi = Scintilla_GetWindowDPI(hdlg);
+ dpi = Scintilla_GetWindowDPI(hdlg);
- const CHOOSEFONT *const pChooseFont = ((CHOOSEFONT *)lParam);
- if (pChooseFont) {
- SendMessage(hdlg, WM_CHOOSEFONT_SETFLAGS, 0, (LPARAM)pChooseFont->Flags);
- if (pChooseFont->lCustData) {
- SetWindowText(hdlg, (WCHAR *)pChooseFont->lCustData);
- }
- const LOGFONT *const pLogFont = ((LOGFONT *)pChooseFont->lpLogFont);
- if (pLogFont) {
- // fill font name selector
- SendMessage(hdlg, WM_CHOOSEFONT_SETLOGFONT, 0, (LPARAM)pLogFont);
- }
- }
- //~else {
- //~ // HACK: to get the full font name instead of font family name
- //~ // [see: ChooseFontDirectWrite() PostProcessing]
- //~ SendMessage(hdlg, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)pChooseFont->lpLogFont);
- //~ PostMessage(hdlg, WM_CLOSE, 0, 0);
- //~}
+ const CHOOSEFONT *const pChooseFont = ((CHOOSEFONT *)lParam);
+ if (pChooseFont) {
+ SendMessage(hdlg, WM_CHOOSEFONT_SETFLAGS, 0, (LPARAM)pChooseFont->Flags);
+ if (pChooseFont->lCustData) {
+ SetWindowText(hdlg, (WCHAR *)pChooseFont->lCustData);
+ }
+ const LOGFONT *const pLogFont = ((LOGFONT *)pChooseFont->lpLogFont);
+ if (pLogFont) {
+ // fill font name selector
+ SendMessage(hdlg, WM_CHOOSEFONT_SETLOGFONT, 0, (LPARAM)pLogFont);
+ }
+ }
+ //~else {
+ //~ // HACK: to get the full font name instead of font family name
+ //~ // [see: ChooseFontDirectWrite() PostProcessing]
+ //~ SendMessage(hdlg, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)pChooseFont->lpLogFont);
+ //~ PostMessage(hdlg, WM_CLOSE, 0, 0);
+ //~}
- CenterDlgInParent(hdlg, NULL);
+ CenterDlgInParent(hdlg, NULL);
- PostMessage(hdlg, WM_THEMECHANGED, 0, 0);
- } break;
+ PostMessage(hdlg, WM_THEMECHANGED, 0, 0);
+ } break;
#ifdef D_NP3_WIN10_DARK_MODE
- CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ CASE_WM_CTLCOLOR_SET:
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hdlg, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hdlg, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hdlg, darkModeEnabled);
- RefreshTitleBarThemeColor(hdlg);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hdlg, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- }
- UpdateWindowEx(hdlg);
- break;
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hdlg, darkModeEnabled);
+ RefreshTitleBarThemeColor(hdlg);
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hdlg, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ }
+ UpdateWindowEx(hdlg);
+ break;
#endif
- case WM_DPICHANGED:
- dpi = LOWORD(wParam);
- //dpi.y = HIWORD(wParam);
- UpdateWindowLayoutForDPI(hdlg, (RECT *)lParam, 0);
- int const ctl[] = { cmb1, cmb2, cmb3, cmb4, cmb5 };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0);
- SendMessage(GetDlgItem(hdlg, ctl[i]), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
- }
- return TRUE;
+ case WM_DPICHANGED:
+ dpi = LOWORD(wParam);
+ //dpi.y = HIWORD(wParam);
+ UpdateWindowLayoutForDPI(hdlg, (RECT *)lParam, 0);
+ int const ctl[] = { cmb1, cmb2, cmb3, cmb4, cmb5 };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0);
+ SendMessage(GetDlgItem(hdlg, ctl[i]), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
+ }
+ return TRUE;
- default:
- break;
- }
- return 0; // Allow the default handler a chance to process
+ default:
+ break;
+ }
+ return 0; // Allow the default handler a chance to process
}
@@ -6252,99 +6252,99 @@ INT_PTR CALLBACK FontDialogHookProc(
// ColorDialogHookProc()
//
INT_PTR CALLBACK ColorDialogHookProc(
- HWND hdlg, // handle to the dialog box window
- UINT uiMsg, // message identifier
- WPARAM wParam, // message parameter
- LPARAM lParam // message parameter
+ HWND hdlg, // handle to the dialog box window
+ UINT uiMsg, // message identifier
+ WPARAM wParam, // message parameter
+ LPARAM lParam // message parameter
) {
- UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(wParam);
- static UINT dpi = USER_DEFAULT_SCREEN_DPI;
+ static UINT dpi = USER_DEFAULT_SCREEN_DPI;
- switch (uiMsg) {
+ switch (uiMsg) {
- case WM_INITDIALOG: {
+ case WM_INITDIALOG: {
- if (Globals.hDlgIconSmall) {
- SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIconSmall);
- }
+ if (Globals.hDlgIconSmall) {
+ SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIconSmall);
+ }
- InitWindowCommon(hdlg, true);
+ InitWindowCommon(hdlg, true);
#ifdef D_NP3_WIN10_DARK_MODE
- if (UseDarkMode()) {
- SetExplorerTheme(GetDlgItem(hdlg, IDOK));
- SetExplorerTheme(GetDlgItem(hdlg, IDCANCEL));
- SetExplorerTheme(GetDlgItem(hdlg, COLOR_ADD));
- SetExplorerTheme(GetDlgItem(hdlg, COLOR_MIX));
- //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
- int const ctl[] = { COLOR_RAINBOW, COLOR_LUMSCROLL, COLOR_CURRENT, IDC_STATIC };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- SetWindowTheme(GetDlgItem(hdlg, ctl[i]), L"", L""); // remove theme
- }
- }
+ if (UseDarkMode()) {
+ SetExplorerTheme(GetDlgItem(hdlg, IDOK));
+ SetExplorerTheme(GetDlgItem(hdlg, IDCANCEL));
+ SetExplorerTheme(GetDlgItem(hdlg, COLOR_ADD));
+ SetExplorerTheme(GetDlgItem(hdlg, COLOR_MIX));
+ //SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
+ int const ctl[] = { COLOR_RAINBOW, COLOR_LUMSCROLL, COLOR_CURRENT, IDC_STATIC };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ SetWindowTheme(GetDlgItem(hdlg, ctl[i]), L"", L""); // remove theme
+ }
+ }
#endif
- dpi = Scintilla_GetWindowDPI(hdlg);
+ dpi = Scintilla_GetWindowDPI(hdlg);
- const CHOOSECOLOR *const pChooseColor = ((CHOOSECOLOR *)lParam);
- if (pChooseColor && pChooseColor->lCustData) {
- POINT const pt = *(POINT*)pChooseColor->lCustData;
- SetWindowPos(hdlg, NULL, pt.x, pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- SetForegroundWindow(hdlg);
- } else {
- CenterDlgInParent(hdlg, NULL);
- }
+ const CHOOSECOLOR *const pChooseColor = ((CHOOSECOLOR *)lParam);
+ if (pChooseColor && pChooseColor->lCustData) {
+ POINT const pt = *(POINT*)pChooseColor->lCustData;
+ SetWindowPos(hdlg, NULL, pt.x, pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ SetForegroundWindow(hdlg);
+ } else {
+ CenterDlgInParent(hdlg, NULL);
+ }
- PostMessage(hdlg, WM_THEMECHANGED, 0, 0);
- }
- break;
+ PostMessage(hdlg, WM_THEMECHANGED, 0, 0);
+ }
+ break;
#ifdef D_NP3_WIN10_DARK_MODE
- CASE_WM_CTLCOLOR_SET:
- return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
- break;
+ CASE_WM_CTLCOLOR_SET:
+ return SetDarkModeCtlColors((HDC)wParam, UseDarkMode());
+ break;
- case WM_SETTINGCHANGE:
- if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
- SendMessage(hdlg, WM_THEMECHANGED, 0, 0);
- }
- break;
+ case WM_SETTINGCHANGE:
+ if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
+ SendMessage(hdlg, WM_THEMECHANGED, 0, 0);
+ }
+ break;
- case WM_THEMECHANGED:
- if (IsDarkModeSupported()) {
- bool const darkModeEnabled = CheckDarkModeEnabled();
- AllowDarkModeForWindowEx(hdlg, darkModeEnabled);
- RefreshTitleBarThemeColor(hdlg);
- int const buttons[] = { IDOK, IDCANCEL };
- for (int id = 0; id < COUNTOF(buttons); ++id) {
- HWND const hBtn = GetDlgItem(hdlg, buttons[id]);
- AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
- SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
- }
- }
- UpdateWindowEx(hdlg);
- break;
+ case WM_THEMECHANGED:
+ if (IsDarkModeSupported()) {
+ bool const darkModeEnabled = CheckDarkModeEnabled();
+ AllowDarkModeForWindowEx(hdlg, darkModeEnabled);
+ RefreshTitleBarThemeColor(hdlg);
+ int const buttons[] = { IDOK, IDCANCEL };
+ for (int id = 0; id < COUNTOF(buttons); ++id) {
+ HWND const hBtn = GetDlgItem(hdlg, buttons[id]);
+ AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
+ SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
+ }
+ }
+ UpdateWindowEx(hdlg);
+ break;
#endif
- case WM_DPICHANGED:
- dpi = LOWORD(wParam);
- //dpi.y = HIWORD(wParam);
- UpdateWindowLayoutForDPI(hdlg, (RECT *)lParam, 0);
- int const ctl[] = { COLOR_ADD, COLOR_MIX, IDOK, IDCANCEL };
- for (int i = 0; i < COUNTOF(ctl); ++i) {
- HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0);
- SendMessage(GetDlgItem(hdlg, ctl[i]), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
- }
- return TRUE;
+ case WM_DPICHANGED:
+ dpi = LOWORD(wParam);
+ //dpi.y = HIWORD(wParam);
+ UpdateWindowLayoutForDPI(hdlg, (RECT *)lParam, 0);
+ int const ctl[] = { COLOR_ADD, COLOR_MIX, IDOK, IDCANCEL };
+ for (int i = 0; i < COUNTOF(ctl); ++i) {
+ HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0);
+ SendMessage(GetDlgItem(hdlg, ctl[i]), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
+ }
+ return TRUE;
- default:
- break;
- }
- return 0; // Allow the default handler a chance to process
+ default:
+ break;
+ }
+ return 0; // Allow the default handler a chance to process
}
@@ -6356,31 +6356,31 @@ INT_PTR CALLBACK ColorDialogHookProc(
//
HFONT CreateAndSetFontDlgItemDPI(HWND hdlg, const int idDlgItem, int fontSize, bool bold)
{
- NONCLIENTMETRICSW ncm = {0};
- ncm.cbSize = sizeof(NONCLIENTMETRICSW);
- if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncm, 0)) {
- HDC const hdcSys = GetDC(NULL);
- UINT const dpiSys = Scintilla_GetWindowDPI(NULL);
- UINT const dpiDlg = Scintilla_GetWindowDPI(hdlg);
- if (fontSize <= 0) {
- fontSize = (ncm.lfMessageFont.lfHeight < 0) ? -ncm.lfMessageFont.lfHeight : ncm.lfMessageFont.lfHeight;
- if (fontSize == 0) {
- fontSize = 9;
- }
- }
- fontSize <<= 10; // precision
- fontSize = MulDiv(fontSize, USER_DEFAULT_SCREEN_DPI, dpiSys.y); // correction
- fontSize = ScaleIntByDPI(fontSize, dpiDlg);
- ncm.lfMessageFont.lfHeight = -(MulDiv(fontSize, GetDeviceCaps(hdcSys, LOGPIXELSY), 72) >> 10);
- ncm.lfMessageFont.lfWeight = bold ? FW_BOLD : FW_REGULAR;
- HFONT const hFont = CreateFontIndirectW(&ncm.lfMessageFont);
- if (idDlgItem > 0) {
- SendDlgItemMessageW(hdlg, idDlgItem, WM_SETFONT, (WPARAM)hFont, true);
- }
- ReleaseDC(hdlg, hdcSys);
- return hFont;
- }
- return NULL;
+ NONCLIENTMETRICSW ncm = {0};
+ ncm.cbSize = sizeof(NONCLIENTMETRICSW);
+ if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncm, 0)) {
+ HDC const hdcSys = GetDC(NULL);
+ UINT const dpiSys = Scintilla_GetWindowDPI(NULL);
+ UINT const dpiDlg = Scintilla_GetWindowDPI(hdlg);
+ if (fontSize <= 0) {
+ fontSize = (ncm.lfMessageFont.lfHeight < 0) ? -ncm.lfMessageFont.lfHeight : ncm.lfMessageFont.lfHeight;
+ if (fontSize == 0) {
+ fontSize = 9;
+ }
+ }
+ fontSize <<= 10; // precision
+ fontSize = MulDiv(fontSize, USER_DEFAULT_SCREEN_DPI, dpiSys.y); // correction
+ fontSize = ScaleIntByDPI(fontSize, dpiDlg);
+ ncm.lfMessageFont.lfHeight = -(MulDiv(fontSize, GetDeviceCaps(hdcSys, LOGPIXELSY), 72) >> 10);
+ ncm.lfMessageFont.lfWeight = bold ? FW_BOLD : FW_REGULAR;
+ HFONT const hFont = CreateFontIndirectW(&ncm.lfMessageFont);
+ if (idDlgItem > 0) {
+ SendDlgItemMessageW(hdlg, idDlgItem, WM_SETFONT, (WPARAM)hFont, true);
+ }
+ ReleaseDC(hdlg, hdcSys);
+ return hFont;
+ }
+ return NULL;
}
#endif
@@ -6390,81 +6390,81 @@ HFONT CreateAndSetFontDlgItemDPI(HWND hdlg, const int idDlgItem, int fontSize, b
#if FALSE
void Handle_WM_PAINT(HWND hwnd)
{
- static HFONT hVersionFont = NULL;
+ static HFONT hVersionFont = NULL;
- PAINTSTRUCT ps;
+ 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);
+ // 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);
+ RECT rect;
+ GetClientRect(hwnd, &rect);
- UINT cx = (rect.right - rect.left);
- UINT cy = (rect.bottom - rect.top);
+ 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 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);
+ // 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);
+ // 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);
+ // 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);
+ 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);
+ // 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, 0);
+ // 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, 0);
- // Cleanup.
- SelectObject(memDC, oldBitmap);
- DeleteObject(memBitmap);
- DeleteDC(memDC);
+ // 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.
+ // 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);
+ EndPaint(hwnd, &ps);
}
#endif
diff --git a/src/Dialogs.h b/src/Dialogs.h
index 9c90902b1..f03b2b328 100644
--- a/src/Dialogs.h
+++ b/src/Dialogs.h
@@ -92,7 +92,7 @@ void SetWindowReadingRTL(HWND hwnd, bool bRTL);
UINT ComboBox_GetTextLengthEx(HWND hDlg, int nIDDlgItem);
UINT ComboBox_GetCurSelEx(HWND hDlg, int nIDDlgItem);
-UINT ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount);
+int ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, size_t cch);
void ComboBox_SetTextMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString);
//void ComboBox_AddStringMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString);
diff --git a/src/Edit.c b/src/Edit.c
index e9f030e5b..93de3f7d3 100644
--- a/src/Edit.c
+++ b/src/Edit.c
@@ -30,6 +30,7 @@
#include "crypto/crypto.h"
#include "uthash/utarray.h"
#include "uthash/utlist.h"
+#include "uthash/utstring.h"
#include "tinyexpr/tinyexpr.h"
#include "Encoding.h"
#include "MuiLanguage.h"
@@ -2064,23 +2065,31 @@ void EditEscapeCChars(HWND hwnd) {
}
EDITFINDREPLACE efr = INIT_EFR_DATA;
+ utstring_new(efr.chFindPattern);
+ utstring_new(efr.chReplaceTemplate);
efr.hwnd = hwnd;
UndoTransActionBegin();
- StringCchCopyA(efr.chFindPattern, COUNTOF(efr.chFindPattern), "\\");
- StringCchCopyA(efr.chReplaceTemplate, COUNTOF(efr.chReplaceTemplate), "\\\\");
+ utstring_bincpy(efr.chFindPattern, "\\", strlen("\\"));
+ utstring_bincpy(efr.chReplaceTemplate, "\\\\", strlen("\\\\"));
EditReplaceAllInSelection(hwnd, &efr, false);
- StringCchCopyA(efr.chFindPattern, COUNTOF(efr.chFindPattern), "\"");
- StringCchCopyA(efr.chReplaceTemplate, COUNTOF(efr.chReplaceTemplate), "\\\"");
+ utstring_clear(efr.chFindPattern);
+ utstring_bincpy(efr.chFindPattern, "\"", strlen("\""));
+ utstring_clear(efr.chReplaceTemplate);
+ utstring_bincpy(efr.chReplaceTemplate, "\\\"", strlen("\\\""));
EditReplaceAllInSelection(hwnd, &efr, false);
- StringCchCopyA(efr.chFindPattern, COUNTOF(efr.chFindPattern), "\'");
- StringCchCopyA(efr.chReplaceTemplate, COUNTOF(efr.chReplaceTemplate), "\\\'");
+ utstring_clear(efr.chFindPattern);
+ utstring_bincpy(efr.chFindPattern, "\'", strlen("\'"));
+ utstring_clear(efr.chReplaceTemplate);
+ utstring_bincpy(efr.chReplaceTemplate, "\\\'", strlen("\\\'"));
EditReplaceAllInSelection(hwnd, &efr, false);
EndUndoTransAction();
+
+ ReleaseEFR(&efr);
}
@@ -2099,23 +2108,31 @@ void EditUnescapeCChars(HWND hwnd) {
}
EDITFINDREPLACE efr = INIT_EFR_DATA;
+ utstring_new(efr.chFindPattern);
+ utstring_new(efr.chReplaceTemplate);
efr.hwnd = hwnd;
UndoTransActionBegin();
- StringCchCopyA(efr.chFindPattern, FNDRPL_BUFFER, "\\\\");
- StringCchCopyA(efr.chReplaceTemplate, FNDRPL_BUFFER, "\\");
+ utstring_bincpy(efr.chFindPattern, "\\\\", strlen("\\\\"));
+ utstring_bincpy(efr.chReplaceTemplate, "\\", strlen("\\"));
EditReplaceAllInSelection(hwnd, &efr, false);
- StringCchCopyA(efr.chFindPattern, FNDRPL_BUFFER, "\\\"");
- StringCchCopyA(efr.chReplaceTemplate, FNDRPL_BUFFER, "\"");
+ utstring_clear(efr.chFindPattern);
+ utstring_bincpy(efr.chFindPattern, "\\\"", strlen("\\\""));
+ utstring_clear(efr.chReplaceTemplate);
+ utstring_bincpy(efr.chReplaceTemplate, "\"", strlen("\""));
EditReplaceAllInSelection(hwnd, &efr, false);
- StringCchCopyA(efr.chFindPattern, FNDRPL_BUFFER, "\\\'");
- StringCchCopyA(efr.chReplaceTemplate, FNDRPL_BUFFER, "\'");
+ utstring_clear(efr.chFindPattern);
+ utstring_bincpy(efr.chFindPattern, "\\\'", strlen("\\\'"));
+ utstring_clear(efr.chReplaceTemplate);
+ utstring_bincpy(efr.chReplaceTemplate, "\'", strlen("\'"));
EditReplaceAllInSelection(hwnd, &efr, false);
EndUndoTransAction();
+
+ ReleaseEFR(&efr);
}
@@ -2478,16 +2495,21 @@ void EditUpdateTimestamps()
_GetCurrentTimeStamp(wchReplaceStrg, COUNTOF(wchReplaceStrg), true); // DateTimeFormat
EDITFINDREPLACE efrTS_L = INIT_EFR_DATA;
+ utstring_new(efrTS_L.chFindPattern);
+ utstring_new(efrTS_L.chReplaceTemplate);
efrTS_L.hwnd = Globals.hwndEdit;
efrTS_L.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX);
- WideCharToMultiByte(Encoding_SciCP, 0, Settings2.TimeStampRegEx, -1, efrTS_L.chFindPattern, COUNTOF(efrTS_L.chFindPattern), NULL, NULL);
- WideCharToMultiByte(Encoding_SciCP, 0, wchReplaceStrg, -1, efrTS_L.chReplaceTemplate, COUNTOF(efrTS_L.chReplaceTemplate), NULL, NULL);
+
+ utstring_setw(efrTS_L.chFindPattern, Settings2.TimeStampRegEx);
+ utstring_setw(efrTS_L.chReplaceTemplate, wchReplaceStrg);
if (!SciCall_IsSelectionEmpty()) {
EditReplaceAllInSelection(Globals.hwndEdit, &efrTS_L, true);
} else {
EditReplaceAll(Globals.hwndEdit, &efrTS_L, true);
}
+
+ ReleaseEFR(&efrTS_L);
}
@@ -5434,14 +5456,16 @@ static void _SetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr)
bool bIsFindDlg = (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE) == NULL);
ComboBox_GetTextW2MB(hwnd, IDC_FINDTEXT, szBuf, COUNTOF(szBuf));
- if (StringCchCompareXA(szBuf, lpefr->chFindPattern) != 0) {
- StringCchCopyA(lpefr->chFindPattern, COUNTOF(lpefr->chFindPattern), szBuf);
+ if (StringCchCompareXA(szBuf, utstring_body(lpefr->chFindPattern)) != 0) {
+ utstring_clear(lpefr->chFindPattern);
+ utstring_bincpy(lpefr->chFindPattern, szBuf, strlen(szBuf));
lpefr->bStateChanged = true;
}
ComboBox_GetTextW2MB(hwnd, IDC_REPLACETEXT, szBuf, COUNTOF(szBuf));
- if (StringCchCompareXA(szBuf, lpefr->chReplaceTemplate) != 0) {
- StringCchCopyA(lpefr->chReplaceTemplate, COUNTOF(lpefr->chReplaceTemplate), szBuf);
+ if (StringCchCompareXA(szBuf, utstring_body(lpefr->chReplaceTemplate)) != 0) {
+ utstring_clear(lpefr->chReplaceTemplate);
+ utstring_bincpy(lpefr->chReplaceTemplate, szBuf, strlen(szBuf));
lpefr->bStateChanged = true;
}
@@ -5671,8 +5695,8 @@ static size_t _EditGetFindStrg(HWND hwnd, LPEDITFINDREPLACE lpefr, LPSTR szFind,
if (!lpefr) {
return 0;
}
- if (!StrIsEmptyA(lpefr->chFindPattern)) {
- StringCchCopyA(szFind, cchCnt, lpefr->chFindPattern);
+ if (!utstring_is_empty(lpefr->chFindPattern)) {
+ StringCchCopyA(szFind, cchCnt, utstring_body(lpefr->chFindPattern));
} else {
CopyFindPatternMB(szFind, cchCnt);
}
@@ -5697,7 +5721,8 @@ static size_t _EditGetFindStrg(HWND hwnd, LPEDITFINDREPLACE lpefr, LPSTR szFind,
}
// ensure to F/R-dialog data structure consistency
- StringCchCopyA(lpefr->chFindPattern, COUNTOF(lpefr->chFindPattern), szFind);
+ utstring_clear(lpefr->chFindPattern);
+ utstring_bincpy(lpefr->chFindPattern, szFind, strlen(szFind));
if (!StrIsEmptyA(szFind) && lpefr->bWildcardSearch) {
_EscapeWildcards(szFind, cchCnt, lpefr);
@@ -5905,8 +5930,8 @@ extern int g_flagMatchText;
static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
- static EDITFINDREPLACE s_efrSave = INIT_EFR_DATA;
- static LPEDITFINDREPLACE s_pEfrDataDlg = NULL;
+ static LPEDITFINDREPLACE s_pEfrData = NULL;
+
static bool s_bIsReplaceDlg = false;
static UINT_PTR pTimerIdentifier = 0;
@@ -5939,9 +5964,9 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
// clear cmd line stuff
g_flagMatchText = 0;
- s_pEfrDataDlg = NULL;
+ s_pEfrData = NULL;
- // the global static Find/Replace data structure
+ // the global static Find/Replace data structure (main)
SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
SetDialogIconNP3(hwnd);
@@ -5973,7 +5998,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
EditSetCaretToSelectionStart(); // avoid search text selection jumps to next match (before ResizeDlg_InitX())
- s_pEfrDataDlg = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd, DWLP_USER);
+ s_pEfrData = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd, DWLP_USER);
Globals.iReplacedOccurrences = 0;
Globals.FindReplaceMatchFoundState = FND_NOP;
@@ -6002,8 +6027,8 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
}
if (!GetWindowTextLengthW(GetDlgItem(hwnd, IDC_FINDTEXT))) {
- if (!StrIsEmptyA(s_pEfrDataDlg->chFindPattern)) {
- ComboBox_SetTextMB2W(hwnd, IDC_FINDTEXT, s_pEfrDataDlg->chFindPattern);
+ if (!utstring_is_empty(s_pEfrData->chFindPattern)) {
+ ComboBox_SetTextMB2W(hwnd, IDC_FINDTEXT, utstring_body(s_pEfrData->chFindPattern));
}
}
@@ -6025,66 +6050,60 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
SHAutoComplete(cbInfoR.hwndItem, SHACF_FILESYS_ONLY | SHACF_AUTOAPPEND_FORCE_OFF | SHACF_AUTOSUGGEST_FORCE_OFF);
}
- if (!StrIsEmptyA(s_pEfrDataDlg->chReplaceTemplate)) {
- ComboBox_SetTextMB2W(hwnd, IDC_REPLACETEXT, s_pEfrDataDlg->chReplaceTemplate);
+ if (!utstring_is_empty(s_pEfrData->chReplaceTemplate)) {
+ ComboBox_SetTextMB2W(hwnd, IDC_REPLACETEXT, utstring_body(s_pEfrData->chReplaceTemplate));
}
}
- CheckDlgButton(hwnd, IDC_FINDREGEXP, SetBtn(s_pEfrDataDlg->bRegExprSearch));
+ CheckDlgButton(hwnd, IDC_FINDREGEXP, SetBtn(s_pEfrData->bRegExprSearch));
- bool const bDotMatchAll = (s_pEfrDataDlg->fuFlags & SCFIND_DOT_MATCH_ALL) != 0;
- CheckDlgButton(hwnd, IDC_DOT_MATCH_ALL, SetBtn(s_pEfrDataDlg->bRegExprSearch && bDotMatchAll));
- DialogEnableControl(hwnd, IDC_DOT_MATCH_ALL, s_pEfrDataDlg->bRegExprSearch);
+ bool const bDotMatchAll = (s_pEfrData->fuFlags & SCFIND_DOT_MATCH_ALL) != 0;
+ CheckDlgButton(hwnd, IDC_DOT_MATCH_ALL, SetBtn(s_pEfrData->bRegExprSearch && bDotMatchAll));
+ DialogEnableControl(hwnd, IDC_DOT_MATCH_ALL, s_pEfrData->bRegExprSearch);
- if (s_pEfrDataDlg->bRegExprSearch) {
- s_pEfrDataDlg->bWildcardSearch = false;
+ if (s_pEfrData->bRegExprSearch) {
+ s_pEfrData->bWildcardSearch = false;
}
- if (s_pEfrDataDlg->bWildcardSearch) {
+ if (s_pEfrData->bWildcardSearch) {
CheckDlgButton(hwnd, IDC_WILDCARDSEARCH, BST_CHECKED);
CheckDlgButton(hwnd, IDC_FINDREGEXP, BST_UNCHECKED);
}
// transform BS handled by regex (wildcard search based on):
- CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, SetBtn(s_pEfrDataDlg->bTransformBS || s_pEfrDataDlg->bRegExprSearch || s_pEfrDataDlg->bWildcardSearch));
- DialogEnableControl(hwnd, IDC_FINDTRANSFORMBS, !(s_pEfrDataDlg->bRegExprSearch || s_pEfrDataDlg->bWildcardSearch));
+ CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, SetBtn(s_pEfrData->bTransformBS || s_pEfrData->bRegExprSearch || s_pEfrData->bWildcardSearch));
+ DialogEnableControl(hwnd, IDC_FINDTRANSFORMBS, !(s_pEfrData->bRegExprSearch || s_pEfrData->bWildcardSearch));
- CheckDlgButton(hwnd, IDC_ALL_OCCURRENCES, SetBtn(s_pEfrDataDlg->bMarkOccurences));
- if (!s_pEfrDataDlg->bMarkOccurences) {
- EditClearAllOccurrenceMarkers(s_pEfrDataDlg->hwnd);
+ CheckDlgButton(hwnd, IDC_ALL_OCCURRENCES, SetBtn(s_pEfrData->bMarkOccurences));
+ if (!s_pEfrData->bMarkOccurences) {
+ EditClearAllOccurrenceMarkers(s_pEfrData->hwnd);
Globals.iMarkOccurrencesCount = 0;
}
- CheckDlgButton(hwnd, IDC_FINDCASE, SetBtn(s_pEfrDataDlg->fuFlags & SCFIND_MATCHCASE));
- CheckDlgButton(hwnd, IDC_FINDWORD, SetBtn(s_pEfrDataDlg->fuFlags & SCFIND_WHOLEWORD));
- CheckDlgButton(hwnd, IDC_FINDSTART, SetBtn(s_pEfrDataDlg->fuFlags & SCFIND_WORDSTART));
- CheckDlgButton(hwnd, IDC_NOWRAP, SetBtn(s_pEfrDataDlg->bNoFindWrap));
+ CheckDlgButton(hwnd, IDC_FINDCASE, SetBtn(s_pEfrData->fuFlags & SCFIND_MATCHCASE));
+ CheckDlgButton(hwnd, IDC_FINDWORD, SetBtn(s_pEfrData->fuFlags & SCFIND_WHOLEWORD));
+ CheckDlgButton(hwnd, IDC_FINDSTART, SetBtn(s_pEfrData->fuFlags & SCFIND_WORDSTART));
+ CheckDlgButton(hwnd, IDC_NOWRAP, SetBtn(s_pEfrData->bNoFindWrap));
if (s_bIsReplaceDlg) {
- if (s_bSwitchedFindReplace) {
- CheckDlgButton(hwnd, IDC_FINDCLOSE, SetBtn(s_pEfrDataDlg->bFindClose));
- } else {
- CheckDlgButton(hwnd, IDC_FINDCLOSE, SetBtn(s_pEfrDataDlg->bReplaceClose));
- }
+ CheckDlgButton(hwnd, IDC_FINDCLOSE, SetBtn(s_pEfrData->bReplaceClose));
} else {
- if (s_bSwitchedFindReplace) {
- CheckDlgButton(hwnd, IDC_FINDCLOSE, SetBtn(s_pEfrDataDlg->bReplaceClose));
- } else {
- CheckDlgButton(hwnd, IDC_FINDCLOSE, SetBtn(s_pEfrDataDlg->bFindClose));
- }
+ CheckDlgButton(hwnd, IDC_FINDCLOSE, SetBtn(s_pEfrData->bFindClose));
}
CheckDlgButton(hwnd, IDC_TRANSPARENT, SetBtn(Settings.FindReplaceTransparentMode));
- if (!s_bSwitchedFindReplace) {
- if (Settings.FindReplaceDlgPosX == CW_USEDEFAULT || Settings.FindReplaceDlgPosY == CW_USEDEFAULT) {
- CenterDlgInParent(hwnd, NULL);
- } else {
- SetDlgPos(hwnd, Settings.FindReplaceDlgPosX, Settings.FindReplaceDlgPosY);
- }
- } else {
+ if (s_bSwitchedFindReplace) {
+ // restore from prev Dlg
SetDlgPos(hwnd, s_xFindReplaceDlgSave, s_yFindReplaceDlgSave);
s_bSwitchedFindReplace = false;
- CopyMemory(s_pEfrDataDlg, &s_efrSave, sizeof(EDITFINDREPLACE));
+ }
+ else {
+ if (Settings.FindReplaceDlgPosX == CW_USEDEFAULT || Settings.FindReplaceDlgPosY == CW_USEDEFAULT) {
+ CenterDlgInParent(hwnd, NULL);
+ }
+ else {
+ SetDlgPos(hwnd, Settings.FindReplaceDlgPosX, Settings.FindReplaceDlgPosY);
+ }
}
WCHAR wchMenuBuf[80] = {L'\0'};
@@ -6108,10 +6127,10 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
s_anyMatch = NO_MATCH;
- _SetSearchFlags(hwnd, s_pEfrDataDlg); // sync
- s_pEfrDataDlg->bStateChanged = true; // force update
+ _SetSearchFlags(hwnd, s_pEfrData); // sync
+ s_pEfrData->bStateChanged = true; // force update
- DialogEnableControl(hwnd, IDC_TOGGLE_VISIBILITY, s_pEfrDataDlg->bMarkOccurences);
+ DialogEnableControl(hwnd, IDC_TOGGLE_VISIBILITY, s_pEfrData->bMarkOccurences);
_DelayMarkAll(_MQ_STD);
@@ -6129,13 +6148,13 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
KillTimer(hwnd, pTimerIdentifier);
pTimerIdentifier = 0;
- _SetSearchFlags(hwnd, s_pEfrDataDlg); // sync
- CopyMemory(&(Settings.EFR_Data), s_pEfrDataDlg, sizeof(EDITFINDREPLACE)); // remember options
+ _SetSearchFlags(hwnd, s_pEfrData); // sync
+ DuplicateEFR(&(Settings.EFR_Data), s_pEfrData);
if (!s_bSwitchedFindReplace) {
if (s_anyMatch == MATCH) {
// Save MRUs
- if (!StrIsEmptyA(s_pEfrDataDlg->chFindPattern)) {
+ if (!utstring_is_empty(s_pEfrData->chFindPattern)) {
if (GetDlgItemText(hwnd, IDC_FINDTEXT, s_tchBuf, COUNTOF(s_tchBuf))) {
MRU_Add(Globals.pMRUfind, s_tchBuf, 0, -1, -1, NULL);
SetFindPattern(s_tchBuf);
@@ -6151,13 +6170,13 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, true);
if (FocusedView.HideNonMatchedLines) {
- EditToggleView(s_pEfrDataDlg->hwnd);
+ EditToggleView(s_pEfrData->hwnd);
}
if (IsMarkOccurrencesEnabled()) {
MarkAllOccurrences(_MQ_STD, true);
} else {
- EditClearAllOccurrenceMarkers(s_pEfrDataDlg->hwnd);
+ EditClearAllOccurrenceMarkers(s_pEfrData->hwnd);
Globals.iMarkOccurrencesCount = 0;
}
@@ -6183,7 +6202,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
DeleteObject(hBrushRed);
DeleteObject(hBrushGreen);
DeleteObject(hBrushBlue);
- s_pEfrDataDlg = NULL;
+ s_pEfrData = NULL;
Globals.hwndDlgFindReplace = NULL;
}
return FALSE;
@@ -6233,7 +6252,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX: {
- if (!s_pEfrDataDlg) {
+ if (!s_pEfrData) {
return false;
}
HWND hCheck = (HWND)lParam;
@@ -6276,7 +6295,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case WM_ACTIVATE: {
- if (!s_pEfrDataDlg) {
+ if (!s_pEfrData) {
return false;
}
@@ -6298,8 +6317,8 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
s_InitialCaretPos = SciCall_GetCurrentPos();
s_InitialTopLine = SciCall_GetFirstVisibleLine();
s_InitialSearchStart = s_InitialCaretPos;
- if (s_pEfrDataDlg) {
- s_pEfrDataDlg->bStateChanged = true;
+ if (s_pEfrData) {
+ s_pEfrData->bStateChanged = true;
}
}
@@ -6322,7 +6341,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case WM_COMMAND: {
- if (!s_pEfrDataDlg) {
+ if (!s_pEfrData) {
return FALSE;
}
@@ -6331,7 +6350,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case IDC_DOC_MODIFIED:
s_InitialSearchStart = SciCall_GetSelectionStart();
s_InitialTopLine = -1; // reset
- s_pEfrDataDlg->bStateChanged = true;
+ s_pEfrData->bStateChanged = true;
_DelayMarkAll(_MQ_STD);
break;
@@ -6339,7 +6358,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case IDC_FINDTEXT:
case IDC_REPLACETEXT: {
- bool bFndPatternChanged = s_pEfrDataDlg->bStateChanged;
+ bool bFndPatternChanged = s_pEfrData->bStateChanged;
switch (HIWORD(wParam)) {
@@ -6367,10 +6386,11 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case CBN_SELENDOK:
case CBN_EDITCHANGE:
bFndPatternChanged = (LOWORD(wParam) == IDC_FINDTEXT);
- LPSTR const buffer = bFndPatternChanged ? s_pEfrDataDlg->chFindPattern : s_pEfrDataDlg->chReplaceTemplate;
- ComboBox_GetTextW2MB(hwnd, LOWORD(wParam), buffer, FNDRPL_BUFFER);
+ UT_string* const buffer = bFndPatternChanged ? s_pEfrData->chFindPattern : s_pEfrData->chReplaceTemplate;
+ utstring_reserve(buffer, FNDRPL_BUFFER);
+ ComboBox_GetTextW2MB(hwnd, LOWORD(wParam), utstring_body(buffer), (int)utstring_alloc_len(buffer));
if (bFndPatternChanged) {
- SetFindPatternMB(s_pEfrDataDlg->chFindPattern);
+ SetFindPatternMB(utstring_body(s_pEfrData->chFindPattern));
}
break;
@@ -6393,7 +6413,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
// if first time you bring up find/replace dialog,
// use most recent search pattern to find box
// in case of no history: paste clipboard
- _EditGetFindStrg(Globals.hwndEdit, s_pEfrDataDlg, lpszSelection, SizeOfMem(lpszSelection));
+ _EditGetFindStrg(Globals.hwndEdit, s_pEfrData, lpszSelection, SizeOfMem(lpszSelection));
}
}
if (lpszSelection) {
@@ -6413,15 +6433,16 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
break; // return
}
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
- SetFindPatternMB(s_pEfrDataDlg->chFindPattern);
+ _SetSearchFlags(hwnd, s_pEfrData);
+ SetFindPatternMB(utstring_body(s_pEfrData->chFindPattern));
- if (s_pEfrDataDlg->bWildcardSearch) {
- _EscapeWildcards(s_pEfrDataDlg->chFindPattern, COUNTOF(s_pEfrDataDlg->chFindPattern), s_pEfrDataDlg);
+ if (s_pEfrData->bWildcardSearch) {
+ _EscapeWildcards(utstring_body(s_pEfrData->chFindPattern), utstring_alloc_len(s_pEfrData->chFindPattern), s_pEfrData);
+ utstring_sanitize(s_pEfrData->chFindPattern);
}
- bool const bIsRegex = (s_pEfrDataDlg->fuFlags & SCFIND_REGEXP);
- if (s_pEfrDataDlg->bTransformBS || bIsRegex) {
- TransformBackslashes(s_pEfrDataDlg->chFindPattern, bIsRegex, Encoding_SciCP, NULL);
+ bool const bIsRegex = (s_pEfrData->fuFlags & SCFIND_REGEXP);
+ if (s_pEfrData->bTransformBS || bIsRegex) {
+ TransformBackslashes(utstring_body(s_pEfrData->chFindPattern), bIsRegex, Encoding_SciCP, NULL);
}
// ------------------------
@@ -6432,8 +6453,8 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
DocPos start = s_InitialSearchStart;
DocPos end = Sci_GetDocEndPosition();
- DocPos const slen = StringCchLenA(s_pEfrDataDlg->chFindPattern, COUNTOF(s_pEfrDataDlg->chFindPattern));
- DocPos const iPos = _FindInTarget(s_pEfrDataDlg->chFindPattern, slen, (int)(s_pEfrDataDlg->fuFlags), &start, &end, false, FRMOD_NORM);
+ DocPos const slen = utstring_len(s_pEfrData->chFindPattern);
+ DocPos const iPos = _FindInTarget(utstring_body(s_pEfrData->chFindPattern), slen, (int)(s_pEfrData->fuFlags), &start, &end, false, FRMOD_NORM);
if (iPos >= 0) {
if (s_bIsReplaceDlg) {
SciCall_ScrollRange(end, iPos);
@@ -6457,30 +6478,30 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case IDT_TIMER_CALLBACK_MRKALL: {
//DocPos const startPos = (DocPos)lParam;
- s_anyMatch = _FindHasMatch(s_pEfrDataDlg->hwnd, s_pEfrDataDlg, 0, false);
+ s_anyMatch = _FindHasMatch(s_pEfrData->hwnd, s_pEfrData, 0, false);
InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, TRUE); // coloring
- if (s_pEfrDataDlg->bMarkOccurences) {
+ if (s_pEfrData->bMarkOccurences) {
static char s_lastFind[FNDRPL_BUFFER] = { L'\0' };
- if (s_pEfrDataDlg->bStateChanged || (StringCchCompareXA(s_lastFind, s_pEfrDataDlg->chFindPattern) != 0)) {
- StringCchCopyA(s_lastFind, COUNTOF(s_lastFind), s_pEfrDataDlg->chFindPattern);
- _FindHasMatch(s_pEfrDataDlg->hwnd, s_pEfrDataDlg, 0, s_pEfrDataDlg->bMarkOccurences);
+ if (s_pEfrData->bStateChanged || (StringCchCompareXA(s_lastFind, utstring_body(s_pEfrData->chFindPattern)) != 0)) {
+ StringCchCopyA(s_lastFind, COUNTOF(s_lastFind), utstring_body(s_pEfrData->chFindPattern));
+ _FindHasMatch(s_pEfrData->hwnd, s_pEfrData, 0, s_pEfrData->bMarkOccurences);
if (FocusedView.HideNonMatchedLines) {
- EditToggleView(s_pEfrDataDlg->hwnd);
+ EditToggleView(s_pEfrData->hwnd);
}
}
- } else if (s_pEfrDataDlg->bStateChanged) {
+ } else if (s_pEfrData->bStateChanged) {
if (FocusedView.HideNonMatchedLines) {
SendWMCommand(hwnd, IDC_TOGGLE_VISIBILITY);
} else {
- EditClearAllOccurrenceMarkers(s_pEfrDataDlg->hwnd);
+ EditClearAllOccurrenceMarkers(s_pEfrData->hwnd);
}
}
- s_pEfrDataDlg->bStateChanged = false;
+ s_pEfrData->bStateChanged = false;
}
break;
case IDC_ALL_OCCURRENCES: {
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
if (IsButtonChecked(hwnd, IDC_ALL_OCCURRENCES)) {
DialogEnableControl(hwnd, IDC_TOGGLE_VISIBILITY, true);
@@ -6488,9 +6509,9 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
} else { // switched OFF
DialogEnableControl(hwnd, IDC_TOGGLE_VISIBILITY, false);
if (FocusedView.HideNonMatchedLines) {
- EditToggleView(s_pEfrDataDlg->hwnd);
+ EditToggleView(s_pEfrData->hwnd);
}
- EditClearAllOccurrenceMarkers(s_pEfrDataDlg->hwnd);
+ EditClearAllOccurrenceMarkers(s_pEfrData->hwnd);
Globals.iMarkOccurrencesCount = 0;
InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, TRUE);
}
@@ -6498,12 +6519,12 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
break;
case IDC_TOGGLE_VISIBILITY:
- if (s_pEfrDataDlg) {
- EditToggleView(s_pEfrDataDlg->hwnd);
+ if (s_pEfrData) {
+ EditToggleView(s_pEfrData->hwnd);
if (!FocusedView.HideNonMatchedLines) {
- s_pEfrDataDlg->bStateChanged = true;
+ s_pEfrData->bStateChanged = true;
s_InitialTopLine = -1; // reset
- EditClearAllOccurrenceMarkers(s_pEfrDataDlg->hwnd);
+ EditClearAllOccurrenceMarkers(s_pEfrData->hwnd);
_DelayMarkAll(_MQ_STD);
}
}
@@ -6520,14 +6541,14 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
} else { // unchecked
DialogEnableControl(hwnd, IDC_DOT_MATCH_ALL, false);
DialogEnableControl(hwnd, IDC_FINDTRANSFORMBS, true);
- CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, SetBtn(s_pEfrDataDlg->bTransformBS));
+ CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, SetBtn(s_pEfrData->bTransformBS));
}
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
_DelayMarkAll(_MQ_STD);
break;
case IDC_DOT_MATCH_ALL:
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
_DelayMarkAll(_MQ_STD);
break;
@@ -6541,31 +6562,31 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
DialogEnableControl(hwnd, IDC_FINDTRANSFORMBS, false);
} else { // unchecked
DialogEnableControl(hwnd, IDC_FINDTRANSFORMBS, true);
- CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, SetBtn(s_pEfrDataDlg->bTransformBS));
+ CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, SetBtn(s_pEfrData->bTransformBS));
}
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
_DelayMarkAll(_MQ_STD);
}
break;
case IDC_FINDTRANSFORMBS: {
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
_DelayMarkAll(_MQ_STD);
}
break;
case IDC_FINDCASE:
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
_DelayMarkAll(_MQ_STD);
break;
case IDC_FINDWORD:
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
_DelayMarkAll(_MQ_STD);
break;
case IDC_FINDSTART:
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
_DelayMarkAll(_MQ_STD);
break;
@@ -6588,24 +6609,23 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
(s_bIsReplaceDlg && LOWORD(wParam) == IDMSG_SWITCHTOFIND)) {
GetDlgPos(hwnd, &s_xFindReplaceDlgSave, &s_yFindReplaceDlgSave);
s_bSwitchedFindReplace = true;
- CopyMemory(&s_efrSave, s_pEfrDataDlg, sizeof(EDITFINDREPLACE));
}
if (!s_bSwitchedFindReplace && !_EnableFRDlgCtrls(hwnd)) {
return true;
}
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
if (!s_bSwitchedFindReplace) {
// Save MRUs
- if (!StrIsEmptyA(s_pEfrDataDlg->chFindPattern)) {
- MultiByteToWideChar(Encoding_SciCP, 0, s_pEfrDataDlg->chFindPattern, -1, s_tchBuf, (int)COUNTOF(s_tchBuf));
+ if (!utstring_is_empty(s_pEfrData->chFindPattern)) {
+ utstring_getw(s_pEfrData->chFindPattern, s_tchBuf, COUNTOF(s_tchBuf));
MRU_Add(Globals.pMRUfind, s_tchBuf, 0, -1, -1, NULL);
SetFindPattern(s_tchBuf);
}
- if (!StrIsEmptyA(s_pEfrDataDlg->chReplaceTemplate)) {
- MultiByteToWideChar(Encoding_SciCP, 0, s_pEfrDataDlg->chReplaceTemplate, -1, s_tchBuf, (int)COUNTOF(s_tchBuf));
+ if (!utstring_is_empty(s_pEfrData->chReplaceTemplate)) {
+ utstring_getw(s_pEfrData->chReplaceTemplate, s_tchBuf, COUNTOF(s_tchBuf));
MRU_Add(Globals.pMRUreplace, s_tchBuf, 0, -1, -1, NULL);
}
}
@@ -6623,20 +6643,22 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
SendDlgItemMessage(hwnd, IDC_REPLACETEXT, CB_ADDSTRING, 0, (LPARAM)s_tchBuf);
}
- ComboBox_SetTextMB2W(hwnd, IDC_FINDTEXT, s_pEfrDataDlg->chFindPattern);
- ComboBox_SetTextMB2W(hwnd, IDC_REPLACETEXT, s_pEfrDataDlg->chReplaceTemplate);
+ ComboBox_SetTextMB2W(hwnd, IDC_FINDTEXT, utstring_body(s_pEfrData->chFindPattern));
+ ComboBox_SetTextMB2W(hwnd, IDC_REPLACETEXT, utstring_body(s_pEfrData->chReplaceTemplate));
if (!s_bSwitchedFindReplace) {
SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetFocus()), 1);
}
+ bool bFound = false;
+
switch (LOWORD(wParam)) {
case IDOK: // find next
case IDACC_SELTONEXT:
if (s_bIsReplaceDlg) {
Globals.bReplaceInitialized = true;
}
- EditFindNext(s_pEfrDataDlg->hwnd, s_pEfrDataDlg, (LOWORD(wParam) == IDACC_SELTONEXT), IsKeyDown(VK_F3));
+ bFound = EditFindNext(s_pEfrData->hwnd, s_pEfrData, (LOWORD(wParam) == IDACC_SELTONEXT), IsKeyDown(VK_F3));
SET_INITIAL_ANCHORS()
break;
@@ -6645,33 +6667,34 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
if (s_bIsReplaceDlg) {
Globals.bReplaceInitialized = true;
}
- EditFindPrev(s_pEfrDataDlg->hwnd, s_pEfrDataDlg, (LOWORD(wParam) == IDACC_SELTOPREV), IsKeyDown(VK_F3));
+ bFound = EditFindPrev(s_pEfrData->hwnd, s_pEfrData, (LOWORD(wParam) == IDACC_SELTOPREV), IsKeyDown(VK_F3));
SET_INITIAL_ANCHORS()
break;
case IDC_REPLACE: {
Globals.bReplaceInitialized = true;
- EditReplace(s_pEfrDataDlg->hwnd, s_pEfrDataDlg);
+ bFound = EditReplace(s_pEfrData->hwnd, s_pEfrData);
}
break;
case IDC_REPLACEALL:
Globals.bReplaceInitialized = true;
- EditReplaceAll(s_pEfrDataDlg->hwnd, s_pEfrDataDlg, true);
+ bFound = EditReplaceAll(s_pEfrData->hwnd, s_pEfrData, true);
break;
case IDC_REPLACEINSEL:
if (!SciCall_IsSelectionEmpty()) {
Globals.bReplaceInitialized = true;
- EditReplaceAllInSelection(s_pEfrDataDlg->hwnd, s_pEfrDataDlg, true);
+ bFound = EditReplaceAllInSelection(s_pEfrData->hwnd, s_pEfrData, true);
}
break;
}
- if (!s_bIsReplaceDlg && (s_pEfrDataDlg->bFindClose)) {
+ if (bFound && !s_bIsReplaceDlg && (s_pEfrData->bFindClose)) {
//~EndDialog(hwnd, LOWORD(wParam)); ~ (!) not running on own message loop
DestroyWindow(hwnd);
- } else if ((LOWORD(wParam) != IDOK) && s_pEfrDataDlg->bReplaceClose) {
+ }
+ else if (bFound && s_bIsReplaceDlg && s_pEfrData->bReplaceClose) {
//~EndDialog(hwnd, LOWORD(wParam)); ~ (!) not running on own message loop
DestroyWindow(hwnd);
}
@@ -6705,7 +6728,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
SetDlgItemTextW(hwnd, IDC_FINDTEXT, wszRepl);
SetDlgItemTextW(hwnd, IDC_REPLACETEXT, wszFind);
Globals.FindReplaceMatchFoundState = FND_NOP;
- _SetSearchFlags(hwnd, s_pEfrDataDlg);
+ _SetSearchFlags(hwnd, s_pEfrData);
_DelayMarkAll(_MQ_STD);
}
break;
@@ -6732,8 +6755,8 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
if (Globals.bCanSaveIniFile) {
MRU_Save(Globals.pMRUfind);
}
- if (s_pEfrDataDlg) {
- s_pEfrDataDlg->chFindPattern[0] = '\0';
+ if (s_pEfrData) {
+ utstring_clear(s_pEfrData->chFindPattern);
}
SetFindPattern(NULL);
while ((int)SendDlgItemMessage(hwnd, IDC_FINDTEXT, CB_DELETESTRING, 0, 0) > 0) {};
@@ -6745,8 +6768,8 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
if (Globals.bCanSaveIniFile) {
MRU_Save(Globals.pMRUreplace);
}
- if (s_pEfrDataDlg) {
- s_pEfrDataDlg->chReplaceTemplate[0] = '\0';
+ if (s_pEfrData) {
+ utstring_clear(s_pEfrData->chReplaceTemplate);
}
while ((int)SendDlgItemMessage(hwnd, IDC_REPLACETEXT, CB_DELETESTRING, 0, 0) > 0) {};
SetDlgItemText(hwnd, IDC_REPLACETEXT, L"");
@@ -6769,7 +6792,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case IDACC_SAVEFIND:
Globals.FindReplaceMatchFoundState = FND_NOP;
SendWMCommand(Globals.hwndMain, IDM_EDIT_SAVEFIND);
- ComboBox_SetTextMB2W(hwnd, IDC_FINDTEXT, s_pEfrDataDlg->chFindPattern);
+ ComboBox_SetTextMB2W(hwnd, IDC_FINDTEXT, utstring_body(s_pEfrData->chFindPattern));
CheckDlgButton(hwnd, IDC_FINDREGEXP, BST_UNCHECKED);
CheckDlgButton(hwnd, IDC_DOT_MATCH_ALL, BST_UNCHECKED);
CheckDlgButton(hwnd, IDC_WILDCARDSEARCH, BST_UNCHECKED);
@@ -7109,7 +7132,7 @@ void EditSelectionMultiSelectAll()
void EditSelectionMultiSelectAllEx(CLPCEDITFINDREPLACE edFndRpl)
{
EDITFINDREPLACE efr;
- CopyMemory(&efr, edFndRpl, sizeof(EDITFINDREPLACE));
+ DuplicateEFR(&efr, edFndRpl);
if (IsWindow(Globals.hwndDlgFindReplace)) {
_SetSearchFlags(Globals.hwndDlgFindReplace, &efr);
@@ -7118,8 +7141,10 @@ void EditSelectionMultiSelectAllEx(CLPCEDITFINDREPLACE edFndRpl)
}
DocChangeTransactionBegin();
- EditMarkAll(efr.chFindPattern, efr.fuFlags, 0, Sci_GetDocEndPosition(), true);
+ EditMarkAll(utstring_body(efr.chFindPattern), efr.fuFlags, 0, Sci_GetDocEndPosition(), true);
EndDocChangeTransaction();
+
+ ReleaseEFR(&efr);
}
@@ -7130,14 +7155,14 @@ void EditSelectionMultiSelectAllEx(CLPCEDITFINDREPLACE edFndRpl)
static char* _GetReplaceString(HWND hwnd, CLPCEDITFINDREPLACE lpefr, int* iReplaceMsg)
{
char* pszReplace = NULL; // replace text of arbitrary size
- if (StringCchCompareNIA(lpefr->chReplaceTemplate, COUNTOF(lpefr->chReplaceTemplate), "^c", 2) == 0) {
+ if (utstring_find(lpefr->chReplaceTemplate, 0, "^c", 2) == 0) {
*iReplaceMsg = SCI_REPLACETARGET;
pszReplace = EditGetClipboardText(hwnd, true, NULL, NULL);
} else {
- size_t const cch = StringCchLenA(lpefr->chReplaceTemplate, COUNTOF(lpefr->chReplaceTemplate));
+ size_t const cch = utstring_len(lpefr->chReplaceTemplate);
pszReplace = (char*)AllocMem(cch + 1, HEAP_ZERO_MEMORY);
if (pszReplace) {
- StringCchCopyA(pszReplace, SizeOfMem(pszReplace), lpefr->chReplaceTemplate);
+ StringCchCopyA(pszReplace, SizeOfMem(pszReplace), utstring_body(lpefr->chReplaceTemplate));
bool const bIsRegEx = (lpefr->fuFlags & SCFIND_REGEXP);
if (lpefr->bTransformBS || bIsRegEx) {
TransformBackslashes(pszReplace, bIsRegEx, Encoding_SciCP, iReplaceMsg);
diff --git a/src/Notepad3.c b/src/Notepad3.c
index 87c2609b4..ca029c32e 100644
--- a/src/Notepad3.c
+++ b/src/Notepad3.c
@@ -35,6 +35,7 @@
#include "crypto/crypto.h"
#include "uthash/utarray.h"
#include "uthash/utlist.h"
+#include "uthash/utstring.h"
#include "tinyexpr/tinyexpr.h"
#include "Encoding.h"
#include "VersionEx.h"
@@ -221,6 +222,10 @@ const WCHAR* const TBBUTTON_DEFAULT_IDS_V2 = L"1 2 4 3 28 0 5 6 0 7 8 9 0 10 11
//=============================================================================
// static method declarations
+// current find pattern
+static UT_string* s_utCurrentFindPattern = NULL;
+
+
// undo / redo selections
static UT_icd UndoRedoSelElement_icd = { sizeof(DocPos), NULL, NULL, NULL };
@@ -749,6 +754,11 @@ static void _InitGlobals()
Flags.bSettingsFileSoftLocked = DefaultFlags.bSettingsFileSoftLocked = false;
+ utstring_new(Settings.EFR_Data.chFindPattern);
+ utstring_new(Settings.EFR_Data.chReplaceTemplate);
+ utstring_new(Defaults.EFR_Data.chFindPattern);
+ utstring_new(Defaults.EFR_Data.chReplaceTemplate);
+
FocusedView.HideNonMatchedLines = false;
FocusedView.CodeFoldingAvailable = false;
FocusedView.ShowCodeFolding = true;
@@ -774,8 +784,10 @@ static void _InitGlobals()
// --- static locals ---
ThemesItems_Init();
+ utstring_new(s_utCurrentFindPattern);
s_pthArgFilePath = Path_Allocate(NULL);
+
}
@@ -852,6 +864,9 @@ static void _CleanUpResources(const HWND hwnd, bool bIsInitialized)
// --- free allocated memory ---
+ ReleaseEFR(&(Defaults.EFR_Data));
+ ReleaseEFR(&(Settings.EFR_Data));
+
Path_Release(Paths.CurrentFile);
Path_Release(Paths.ModuleDirectory);
Path_Release(Paths.WorkingDirectory);
@@ -864,6 +879,8 @@ static void _CleanUpResources(const HWND hwnd, bool bIsInitialized)
Path_Release(s_pthArgFilePath);
+ utstring_free(s_utCurrentFindPattern);
+
ThemesItems_Release();
}
@@ -1282,11 +1299,19 @@ static SIZE _StatusCalcTextSize(HWND hwnd, LPCWSTR lpsz)
//
// Set/Get FindPattern()
//
-static WCHAR sCurrentFindPattern[FNDRPL_BUFFER] = { L'\0' };
bool IsFindPatternEmpty()
{
- return StrIsEmpty(sCurrentFindPattern);
+ return utstring_is_empty(s_utCurrentFindPattern);
+}
+
+//=============================================================================
+//
+// GetFindPatternMB()
+//
+LPCSTR GetFindPatternMB()
+{
+ return utstring_body(s_utCurrentFindPattern);
}
//=============================================================================
@@ -1295,7 +1320,7 @@ bool IsFindPatternEmpty()
//
void SetFindPattern(LPCWSTR wchFindPattern)
{
- StringCchCopy(sCurrentFindPattern, COUNTOF(sCurrentFindPattern), (wchFindPattern ? wchFindPattern : L""));
+ utstring_setw(s_utCurrentFindPattern, wchFindPattern);
}
//=============================================================================
@@ -1304,27 +1329,26 @@ void SetFindPattern(LPCWSTR wchFindPattern)
//
void SetFindPatternMB(LPCSTR chFindPattern)
{
- MultiByteToWideChar(Encoding_SciCP, 0, chFindPattern, -1, sCurrentFindPattern, (int)COUNTOF(sCurrentFindPattern));
+ utstring_clear(s_utCurrentFindPattern);
+ utstring_bincpy(s_utCurrentFindPattern, chFindPattern, strlen(chFindPattern));
}
-
//=============================================================================
//
// LengthOfFindPattern()
//
size_t LengthOfFindPattern()
{
- return StringCchLen(sCurrentFindPattern, 0);
+ return utstring_getw(s_utCurrentFindPattern, NULL, 0) - 1;
}
-
//=============================================================================
//
-// GetFindPattern()
+// LengthOfFindPatternMB()
//
-LPCWSTR GetFindPattern()
+size_t LengthOfFindPatternMB()
{
- return sCurrentFindPattern;
+ return utstring_len(s_utCurrentFindPattern);
}
@@ -1334,7 +1358,7 @@ LPCWSTR GetFindPattern()
//
void CopyFindPattern(LPWSTR wchFindPattern, size_t bufferCount)
{
- StringCchCopy(wchFindPattern, bufferCount, sCurrentFindPattern);
+ utstring_getw(s_utCurrentFindPattern, wchFindPattern, bufferCount);
}
//=============================================================================
@@ -1343,22 +1367,26 @@ void CopyFindPattern(LPWSTR wchFindPattern, size_t bufferCount)
//
void CopyFindPatternMB(LPSTR chFindPattern, size_t bufferCount)
{
- WideCharToMultiByte(Encoding_SciCP, 0, sCurrentFindPattern, -1, chFindPattern, (int)bufferCount, NULL, NULL);
+ StringCchCopyA(chFindPattern, bufferCount, utstring_body(s_utCurrentFindPattern));
}
+// ----------------------------------------------------------------------------
+
static EDITFINDREPLACE s_FindReplaceData = INIT_EFR_DATA;
+
//=============================================================================
//
// SetFindReplaceData()
//
static void SetFindReplaceData()
{
- s_FindReplaceData = Settings.EFR_Data; // reset
+ // reset
+ DuplicateEFR(&s_FindReplaceData, &(Settings.EFR_Data));
if (!IsFindPatternEmpty()) {
- CopyFindPatternMB(s_FindReplaceData.chFindPattern, COUNTOF(s_FindReplaceData.chFindPattern));
- CopyFindPatternMB(Settings.EFR_Data.chFindPattern, COUNTOF(Settings.EFR_Data.chFindPattern));
+ utstring_clear(Settings.EFR_Data.chFindPattern);
+ utstring_bincpy(Settings.EFR_Data.chFindPattern, utstring_body(s_utCurrentFindPattern), utstring_len(s_utCurrentFindPattern));
}
if (g_flagMatchText) { // cmd line
@@ -5262,7 +5290,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
SetFindReplaceData(); // s_FindReplaceData
- if (IsFindPatternEmpty() && !StrIsEmptyA(s_FindReplaceData.chFindPattern)) {
+ if (IsFindPatternEmpty() && !utstring_is_empty(s_FindReplaceData.chFindPattern)) {
if (iLoWParam != IDM_EDIT_REPLACENEXT) {
SendWMCommand(hwnd, IDM_EDIT_FIND);
} else {
@@ -5314,9 +5342,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case CMD_FINDPREVSEL:
case IDM_EDIT_SAVEFIND: {
if (SetCurrentSelAsFindReplaceData()) {
-
- MRU_Add(Globals.pMRUfind, GetFindPattern(), 0, -1, -1, NULL);
-
+ WCHAR buf[8192];
+ CopyFindPattern(buf, COUNTOF(buf));
+ MRU_Add(Globals.pMRUfind, buf, 0, -1, -1, NULL);
s_FindReplaceData.fuFlags &= (~(SCFIND_REGEXP | SCFIND_POSIX));
s_FindReplaceData.bTransformBS = false;
@@ -10955,7 +10983,7 @@ bool ActivatePrevInst()
params->flagMatchText = g_flagMatchText;
if (!IsFindPatternEmpty()) {
- StringCchCopy(StrEnd(¶ms->wchData, 0) + 1, (LengthOfFindPattern() + 1), GetFindPattern());
+ CopyFindPattern(StrEnd(¶ms->wchData, 0) + 1, (LengthOfFindPattern() + 1));
}
cds.dwData = DATA_NOTEPAD3_PARAMS;
@@ -11044,7 +11072,7 @@ bool ActivatePrevInst()
params->flagMatchText = g_flagMatchText;
if (!IsFindPatternEmpty()) {
- StringCchCopy(StrEnd(¶ms->wchData, 0) + 1, (LengthOfFindPattern() + 1), GetFindPattern());
+ CopyFindPattern(StrEnd(¶ms->wchData, 0) + 1, (LengthOfFindPattern() + 1));
}
cds.dwData = DATA_NOTEPAD3_PARAMS;
diff --git a/src/Notepad3.h b/src/Notepad3.h
index 53e89975b..4fd67f607 100644
--- a/src/Notepad3.h
+++ b/src/Notepad3.h
@@ -143,13 +143,14 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid);
bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operation);
void HandleColorDefClicked(HWND hwnd, const DocPos position);
-bool IsFindPatternEmpty();
-void SetFindPattern(LPCWSTR wchFindPattern);
-void SetFindPatternMB(LPCSTR chFindPattern);
+bool IsFindPatternEmpty();
+LPCSTR GetFindPatternMB();
+void SetFindPattern(LPCWSTR wchFindPattern);
+void SetFindPatternMB(LPCSTR chFindPattern);
size_t LengthOfFindPattern();
-LPCWSTR GetFindPattern();
-void CopyFindPattern(LPWSTR wchFindPattern, size_t bufferCount);
-void CopyFindPatternMB(LPSTR chFindPattern, size_t bufferCount);
+size_t LengthOfFindPatternMB();
+void CopyFindPattern(LPWSTR wchFindPattern, size_t bufferCount);
+void CopyFindPatternMB(LPSTR chFindPattern, size_t bufferCount);
bool ConsistentIndentationCheck(EditFileIOStatus* status);
diff --git a/src/TypeDefs.h b/src/TypeDefs.h
index 8c0cf2e30..0902c9097 100644
--- a/src/TypeDefs.h
+++ b/src/TypeDefs.h
@@ -43,6 +43,8 @@
#include
#endif
+#include "uthash/utstring.h"
+
#include "Sci_Position.h"
#include "Scintilla.h"
@@ -241,26 +243,51 @@ typedef struct _editfindreplace
bool bHideNonMatchedLines;
bool bStateChanged;
HWND hwnd;
- char chFindPattern[FNDRPL_BUFFER];
- char chReplaceTemplate[FNDRPL_BUFFER];
+ UT_string* chFindPattern; //[FNDRPL_BUFFER];
+ UT_string* chReplaceTemplate; //[FNDRPL_BUFFER];
} EDITFINDREPLACE, *LPEDITFINDREPLACE;
-//typedef const EDITFINDREPLACE* CLPEDITFINDREPLACE;
typedef const EDITFINDREPLACE* const CLPCEDITFINDREPLACE;
-#define INIT_EFR_DATA { 0, false, false, false, false, false, false, false, false, true, NULL, "", "" }
+#define INIT_EFR_DATA { 0, false, false, false, false, false, false, false, false, true, NULL, NULL, NULL }
#define IDMSG_SWITCHTOFIND 300
#define IDMSG_SWITCHTOREPLACE 301
+inline static void DuplicateEFR(LPEDITFINDREPLACE dst, CLPCEDITFINDREPLACE src)
+{
+ dst->fuFlags = src->fuFlags;
+ dst->bTransformBS = src->bTransformBS;
+ dst->bFindClose = src->bFindClose;
+ dst->bReplaceClose = src->bReplaceClose;
+ dst->bNoFindWrap = src->bNoFindWrap;
+ dst->bRegExprSearch = src->bRegExprSearch;
+ dst->bWildcardSearch = src->bWildcardSearch;
+ dst->bMarkOccurences = src->bMarkOccurences;
+ dst->bHideNonMatchedLines = src->bHideNonMatchedLines;
+ dst->bStateChanged = src->bStateChanged;
+ dst->hwnd = src->hwnd;
+ utstring_renew(dst->chFindPattern);
+ utstring_bincpy(dst->chFindPattern, utstring_body(src->chFindPattern), utstring_len(src->chFindPattern));
+ utstring_renew(dst->chReplaceTemplate);
+ utstring_bincpy(dst->chReplaceTemplate, utstring_body(src->chReplaceTemplate), utstring_len(src->chReplaceTemplate));
+}
+
+inline static void ReleaseEFR(LPEDITFINDREPLACE efr)
+{
+ utstring_free(efr->chFindPattern);
+ efr->chFindPattern = NULL;
+ utstring_free(efr->chReplaceTemplate);
+ efr->chReplaceTemplate = NULL;
+}
// --------------------------------------------------------------------------
#define MRU_MAXITEMS 32
#define MRU_ITEMSFILE 32
#define MRU_ITEMSFNDRPL 16
-#define MRU_NOCASE 1
-#define MRU_UTF8 2
-#define MRU_BMRK_SIZE 512
+#define MRU_NOCASE 1
+#define MRU_UTF8 2
+#define MRU_BMRK_SIZE 512
typedef struct _mrulist
{
diff --git a/src/uthash/utstring.h b/src/uthash/utstring.h
index 1fee9b54e..0dce59c85 100644
--- a/src/uthash/utstring.h
+++ b/src/uthash/utstring.h
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2008-2021, Troy D. Hanson http://troydhanson.github.com/uthash/
All rights reserved.
@@ -32,11 +32,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#include
#include
+#include
#ifdef __GNUC__
#define UTSTRING_UNUSED __attribute__((__unused__))
#else
-#define UTSTRING_UNUSED
+#define UTSTRING_UNUSED inline
#endif
#ifdef oom
@@ -67,17 +68,22 @@ do { \
} \
} while(0)
-#define utstring_init(s) \
+#define utstring_sanitize(s) \
do { \
- (s)->n = 0; (s)->i = 0; (s)->d = NULL; \
- utstring_reserve(s,100); \
- (s)->d[0] = '\0'; \
+ (s)->i = strlen((s)->d); \
} while(0)
#define utstring_done(s) \
do { \
if ((s)->d != NULL) free((s)->d); \
- (s)->n = 0; \
+ (s)->d = NULL; (s)->n = 0; (s)->i = 0; \
+} while(0)
+
+#define utstring_init(s) \
+do { \
+ utstring_done(s); \
+ utstring_reserve(s,128); \
+ (s)->d[0] = '\0'; \
} while(0)
#define utstring_free(s) \
@@ -92,9 +98,16 @@ do { \
if (!(s)) { \
utstring_oom(); \
} \
+ (s)->d = NULL; \
utstring_init(s); \
} while(0)
+#define utstring_clear(s) \
+do { \
+ (s)->d[0] = '\0'; \
+ (s)->i = 0; \
+} while(0)
+
#define utstring_renew(s) \
do { \
if (s) { \
@@ -104,34 +117,33 @@ do { \
} \
} while(0)
-#define utstring_clear(s) \
-do { \
- (s)->i = 0; \
- (s)->d[0] = '\0'; \
-} while(0)
-
#define utstring_bincpy(s,b,l) \
do { \
utstring_reserve((s),(l)+1); \
- if (l) memcpy(&(s)->d[(s)->i], b, l); \
+ if (l) memcpy(&((s)->d[(s)->i]), b, l); \
(s)->i += (l); \
(s)->d[(s)->i]='\0'; \
} while(0)
-#define utstring_concat(dst,src) \
-do { \
- utstring_reserve((dst),((src)->i)+1); \
- if ((src)->i) memcpy(&(dst)->d[(dst)->i], (src)->d, (src)->i); \
- (dst)->i += (src)->i; \
- (dst)->d[(dst)->i]='\0'; \
+#define utstring_concat(dst,src) \
+do { \
+ utstring_reserve((dst),((src)->i)+1); \
+ if ((src)->i) memcpy(&((dst)->d[(dst)->i]), (src)->d, (src)->i); \
+ (dst)->i += (src)->i; \
+ (dst)->d[(dst)->i]='\0'; \
} while(0)
+#define utstring_is_empty(s) (!((s)->d) || ((s)->d[0] == '\0'))
+
#define utstring_len(s) ((s)->i)
#define utstring_body(s) ((s)->d)
+#define utstring_alloc_len(s) ((s)->n)
+
+
UTSTRING_UNUSED static void utstring_printf_va(UT_string *s, const char *fmt, va_list ap) {
- int n;
+ ptrdiff_t n;
va_list cp;
for (;;) {
#ifdef _WIN32
@@ -139,10 +151,10 @@ UTSTRING_UNUSED static void utstring_printf_va(UT_string *s, const char *fmt, va
#else
va_copy(cp, ap);
#endif
- n = vsnprintf (&s->d[s->i], s->n-s->i, fmt, cp);
+ n = (ptrdiff_t)vsnprintf(&s->d[s->i], s->n - s->i, fmt, cp);
va_end(cp);
- if ((n > -1) && ((size_t) n < (s->n-s->i))) {
+ if ((n > -1) && (n < (ptrdiff_t)(s->n - s->i))) {
s->i += n;
return;
}
@@ -171,14 +183,14 @@ UTSTRING_UNUSED static void utstring_printf(UT_string *s, const char *fmt, ...)
UTSTRING_UNUSED static void _utstring_BuildTable(
const char *P_Needle,
size_t P_NeedleLen,
- long *P_KMP_Table)
+ ptrdiff_t* P_KMP_Table)
{
- long i, j;
+ ptrdiff_t i, j;
i = 0;
j = i - 1;
P_KMP_Table[i] = j;
- while (i < (long) P_NeedleLen)
+ while (i < (ptrdiff_t)P_NeedleLen)
{
while ( (j > -1) && (P_Needle[i] != P_Needle[j]) )
{
@@ -186,7 +198,7 @@ UTSTRING_UNUSED static void _utstring_BuildTable(
}
i++;
j++;
- if (i < (long) P_NeedleLen)
+ if (i < (ptrdiff_t)P_NeedleLen)
{
if (P_Needle[i] == P_Needle[j])
{
@@ -211,16 +223,16 @@ UTSTRING_UNUSED static void _utstring_BuildTable(
UTSTRING_UNUSED static void _utstring_BuildTableR(
const char *P_Needle,
size_t P_NeedleLen,
- long *P_KMP_Table)
+ ptrdiff_t* P_KMP_Table)
{
- long i, j;
+ ptrdiff_t i, j;
i = P_NeedleLen - 1;
j = i + 1;
P_KMP_Table[i + 1] = j;
while (i >= 0)
{
- while ( (j < (long) P_NeedleLen) && (P_Needle[i] != P_Needle[j]) )
+ while ((j < (ptrdiff_t)P_NeedleLen) && (P_Needle[i] != P_Needle[j]))
{
j = P_KMP_Table[j + 1];
}
@@ -248,19 +260,19 @@ UTSTRING_UNUSED static void _utstring_BuildTableR(
/* Search data from left to right. ( Multiple search mode. ) */
-UTSTRING_UNUSED static long _utstring_find(
+UTSTRING_UNUSED static ptrdiff_t _utstring_find(
const char *P_Haystack,
size_t P_HaystackLen,
const char *P_Needle,
size_t P_NeedleLen,
- long *P_KMP_Table)
+ ptrdiff_t* P_KMP_Table)
{
- long i, j;
- long V_FindPosition = -1;
+ ptrdiff_t i, j;
+ ptrdiff_t V_FindPosition = -1;
/* Search from left to right. */
i = j = 0;
- while ( (j < (int)P_HaystackLen) && (((P_HaystackLen - j) + i) >= P_NeedleLen) )
+ while ((j < (ptrdiff_t)P_HaystackLen) && (((P_HaystackLen - j) + i) >= P_NeedleLen))
{
while ( (i > -1) && (P_Needle[i] != P_Haystack[j]) )
{
@@ -268,7 +280,7 @@ UTSTRING_UNUSED static long _utstring_find(
}
i++;
j++;
- if (i >= (int)P_NeedleLen)
+ if (i >= (ptrdiff_t)P_NeedleLen)
{
/* Found. */
V_FindPosition = j - i;
@@ -281,22 +293,22 @@ UTSTRING_UNUSED static long _utstring_find(
/* Search data from right to left. ( Multiple search mode. ) */
-UTSTRING_UNUSED static long _utstring_findR(
+UTSTRING_UNUSED static ptrdiff_t _utstring_findR(
const char *P_Haystack,
size_t P_HaystackLen,
const char *P_Needle,
size_t P_NeedleLen,
- long *P_KMP_Table)
+ ptrdiff_t* P_KMP_Table)
{
- long i, j;
- long V_FindPosition = -1;
+ ptrdiff_t i, j;
+ ptrdiff_t V_FindPosition = -1;
/* Search from right to left. */
j = (P_HaystackLen - 1);
i = (P_NeedleLen - 1);
while ( (j >= 0) && (j >= i) )
{
- while ( (i < (int)P_NeedleLen) && (P_Needle[i] != P_Haystack[j]) )
+ while ((i < (ptrdiff_t)P_NeedleLen) && (P_Needle[i] != P_Haystack[j]))
{
i = P_KMP_Table[i + 1];
}
@@ -315,16 +327,16 @@ UTSTRING_UNUSED static long _utstring_findR(
/* Search data from left to right. ( One time search mode. ) */
-UTSTRING_UNUSED static long utstring_find(
+UTSTRING_UNUSED static ptrdiff_t utstring_find(
UT_string *s,
- long P_StartPosition, /* Start from 0. -1 means last position. */
+ ptrdiff_t P_StartPosition, /* Start from 0. -1 means last position. */
const char *P_Needle,
size_t P_NeedleLen)
{
- long V_StartPosition;
- long V_HaystackLen;
- long *V_KMP_Table;
- long V_FindPosition = -1;
+ ptrdiff_t V_StartPosition;
+ ptrdiff_t V_HaystackLen;
+ ptrdiff_t* V_KMP_Table;
+ ptrdiff_t V_FindPosition = -1;
if (P_StartPosition < 0)
{
@@ -335,9 +347,9 @@ UTSTRING_UNUSED static long utstring_find(
V_StartPosition = P_StartPosition;
}
V_HaystackLen = s->i - V_StartPosition;
- if ( (V_HaystackLen >= (long) P_NeedleLen) && (P_NeedleLen > 0) )
+ if ((V_HaystackLen >= (ptrdiff_t)P_NeedleLen) && (P_NeedleLen > 0))
{
- V_KMP_Table = (long *)malloc(sizeof(long) * (P_NeedleLen + 1));
+ V_KMP_Table = (ptrdiff_t*)malloc(sizeof(ptrdiff_t) * (P_NeedleLen + 1));
if (V_KMP_Table != NULL)
{
_utstring_BuildTable(P_Needle, P_NeedleLen, V_KMP_Table);
@@ -361,16 +373,16 @@ UTSTRING_UNUSED static long utstring_find(
/* Search data from right to left. ( One time search mode. ) */
-UTSTRING_UNUSED static long utstring_findR(
+UTSTRING_UNUSED static ptrdiff_t utstring_findR(
UT_string *s,
- long P_StartPosition, /* Start from 0. -1 means last position. */
+ ptrdiff_t P_StartPosition, /* Start from 0. -1 means last position. */
const char *P_Needle,
size_t P_NeedleLen)
{
- long V_StartPosition;
- long V_HaystackLen;
- long *V_KMP_Table;
- long V_FindPosition = -1;
+ ptrdiff_t V_StartPosition;
+ ptrdiff_t V_HaystackLen;
+ ptrdiff_t* V_KMP_Table;
+ ptrdiff_t V_FindPosition = -1;
if (P_StartPosition < 0)
{
@@ -381,9 +393,9 @@ UTSTRING_UNUSED static long utstring_findR(
V_StartPosition = P_StartPosition;
}
V_HaystackLen = V_StartPosition + 1;
- if ( (V_HaystackLen >= (long) P_NeedleLen) && (P_NeedleLen > 0) )
+ if ((V_HaystackLen >= (ptrdiff_t)P_NeedleLen) && (P_NeedleLen > 0))
{
- V_KMP_Table = (long *)malloc(sizeof(long) * (P_NeedleLen + 1));
+ V_KMP_Table = (ptrdiff_t*)malloc(sizeof(ptrdiff_t) * (P_NeedleLen + 1));
if (V_KMP_Table != NULL)
{
_utstring_BuildTableR(P_Needle, P_NeedleLen, V_KMP_Table);
@@ -404,4 +416,21 @@ UTSTRING_UNUSED static long utstring_findR(
* end substring search functions *
******************************************************************************/
+
+UTSTRING_UNUSED static void utstring_setw(UT_string* s, const wchar_t* wch)
+{
+ int const len = WideCharToMultiByte(CP_UTF8, 0, wch, -1, NULL, 0, NULL, NULL);
+ utstring_clear(s);
+ if ((s)->n < len) { utstring_reserve(s, len - (s)->n); }
+ WideCharToMultiByte(CP_UTF8, 0, wch, -1, (s)->d, len, NULL, NULL);
+ (s)->i = strlen((s)->d);
+}
+
+
+UTSTRING_UNUSED static size_t utstring_getw(UT_string* s, wchar_t* wch, size_t count)
+{
+ return (size_t) MultiByteToWideChar(CP_UTF8, 0, utstring_body(s), -1, wch, (int)count);
+}
+
+
#endif /* UTSTRING_H */