diff --git a/Build/Changes.txt b/Build/Changes.txt index 07a167f6a..d8413af62 100644 --- a/Build/Changes.txt +++ b/Build/Changes.txt @@ -57,7 +57,7 @@ NEW: - Add CED reliability option (NLS: dialogs) - Indentation consistency check on file open (NLS: dialogs) - End-of-Line (EOL) consistency check on file open (NLS: dialogs) -- Checkbox for transparent Find/Replace Dialogbox on loosing focus +- Checkbox for transparent Find/Replace Dialogbox on losing focus -------------------------------------------------- CHANGES: @@ -681,7 +681,7 @@ FIXES: - Update view on style change in "Customize schemes..." - Bug regarding "Reset" button in "Customizing Schemes..." dialog. - Bug in detect and style Hyperlink Hotspot. -- Loosing state of "Transform Backslashes" while switching regex/wildcard search. +- Losing state of "Transform Backslashes" while switching regex/wildcard search. - Block "mark occurrences" event on transaction pair: (SCI_TARGETFROMSELECTIO, SCI_REPLACETARGET). - protect SCI target transactions by a guard to break recursion of diff --git a/crypto/crypto.c b/crypto/crypto.c index da3134c71..e6161a5b5 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -124,11 +124,10 @@ INT_PTR CALLBACK SetKeysDlgProc(HWND hDlg, UINT umsg, WPARAM wParam, LPARAM lPar SetDialogFocus(hDlg, GetDlgItem(hDlg, IDC_PWD_EDIT1)); } return true; - break; case WM_DPICHANGED: UpdateWindowLayoutForDPI(hDlg, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: @@ -252,11 +251,10 @@ INT_PTR CALLBACK GetKeysDlgProc(HWND hDlg, UINT umsg, WPARAM wParam, LPARAM lPar SetDialogFocus(hDlg, GetDlgItem(hDlg, IDC_PWD_EDIT3)); } return true; - break; case WM_DPICHANGED: UpdateWindowLayoutForDPI(hDlg, 0, 0, 0, 0); - break; + return true;; case WM_COMMAND: @@ -425,7 +423,7 @@ int ReadAndDecryptFile(HWND hwnd, HANDLE hFile, DWORD size, void** result, DWORD *resultlen = (DWORD)nb; } else { - bRetryPassPhrase = (MsgBoxLng(MBRETRYCANCEL, IDS_MUI_PASS_FAILURE) == IDRETRY); + bRetryPassPhrase = (MessageBoxLng(MB_RETRYCANCEL, IDS_MUI_PASS_FAILURE) == IDRETRY); if (!bRetryPassPhrase) { // enable raw encryption read *resultlen = readsize; diff --git a/language/np3_de_de/dialogs_de_de.rc b/language/np3_de_de/dialogs_de_de.rc index c77fe902c..e5965c19c 100644 --- a/language/np3_de_de/dialogs_de_de.rc +++ b/language/np3_de_de/dialogs_de_de.rc @@ -217,21 +217,21 @@ END IDD_MUI_WARNLINEENDS DIALOGEX 0, 0, 196, 100 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Inconsistent Line Endings" +CAPTION "Inkonsistente Zeilenumbrüche" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - LTEXT "Inconsistent line endings found in file:",IDC_STATIC,7,7,180,8 + LTEXT "Inkonsistente Zeilenumbrüche gefunden:",IDC_STATIC,7,7,180,8 LTEXT "CR+LF:",IDC_STATIC,10,18,34,8,SS_RIGHT LTEXT "CR:",IDC_STATIC,10,28,34,8,SS_RIGHT LTEXT "LF:",IDC_STATIC,10,38,34,8,SS_RIGHT - LTEXT "%s line(s).",IDC_EOL_SUM_CRLF,48,18,136,8 - LTEXT "%s line(s).",IDC_EOL_SUM_CR,48,28,136,8 - LTEXT "%s line(s).",IDC_EOL_SUM_LF,48,38,136,8 - LTEXT "&Do you want to normalize the line endings?",IDC_STATIC,7,52,180,8 + LTEXT "%s Zeile(n).",IDC_EOL_SUM_CRLF,48,18,136,8 + LTEXT "%s Zeile(n).",IDC_EOL_SUM_CR,48,28,136,8 + LTEXT "%s Zeile(n).",IDC_EOL_SUM_LF,48,38,136,8 + LTEXT "&Zeilenumbrüche angleichen?",IDC_STATIC,7,52,180,8 COMBOBOX IDC_EOLMODELIST,7,64,118,81,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "&Ja",IDOK,138,63,50,14 PUSHBUTTON "&Nein",IDCANCEL,138,80,50,14 - CONTROL "&Always show this dialog.", IDC_WARN_INCONSISTENT_EOLS, + CONTROL "&Diesen Dialog wieder anzeigen.", IDC_WARN_INCONSISTENT_EOLS, "Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,7,82,118,10 END @@ -319,7 +319,7 @@ BEGIN EDITTEXT IDC_STYLEEDIT_HELP,197,50,252,74,ES_MULTILINE | ES_READONLY | NOT WS_BORDER END -IDD_MUI_TABSETTINGS DIALOGEX 0, 0, 174, 114 +IDD_MUI_TABSETTINGS DIALOGEX 0, 0, 184, 114 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Tabulator Einstellungen" FONT 8, "MS Shell Dlg", 0, 0, 0x0 @@ -328,16 +328,16 @@ BEGIN EDITTEXT IDC_TAB_WIDTH,67,7,30,14,ES_AUTOHSCROLL LTEXT "&Einrückung Tiefe:",IDC_STATIC,7,30,60,8 EDITTEXT IDC_INDENT_DEPTH,67,27,30,14,ES_AUTOHSCROLL - CONTROL "Tabulatoren als &Leerzeichenfolge einfügen.",IDC_TAB_AS_SPC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,47,150,10 - CONTROL "Tab-Taste formatiert die Einrückung.",IDC_TAB_INDENTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,59,150,10 + CONTROL "Tabulatoren als &Leerzeichenfolge einfügen.",IDC_TAB_AS_SPC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,47,160,10 + CONTROL "Tab-Taste formatiert die Einrückung.",IDC_TAB_INDENTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,59,160,10 CONTROL "&Rück-Taste formatiert die Einrückung.",IDC_BACKTAB_INDENTS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,71,150,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,71,160,10 CONTROL "&Warnung bei inkonsistenten Einrückungen.",IDC_WARN_INCONSISTENT_INDENTS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,83,150,10 - CONTROL "&Autodetect Tab or Space Indentation.",IDC_AUTO_DETECT_INDENTS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,95,150,10 - DEFPUSHBUTTON "OK",IDOK,117,7,50,14 - PUSHBUTTON "Abbrechen",IDCANCEL,117,27,50,14 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,83,160,10 + CONTROL "&Auto-Erkennung von Tab/Leerzeichen Einrückungen.",IDC_AUTO_DETECT_INDENTS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,95,160,10 + DEFPUSHBUTTON "OK",IDOK,127,7,50,14 + PUSHBUTTON "Abbrechen",IDCANCEL,127,27,50,14 END IDD_MUI_WARNINDENTATION DIALOGEX 0, 0, 196, 138 @@ -781,7 +781,7 @@ BEGIN IDD_MUI_TABSETTINGS, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 167 + RIGHTMARGIN, 177 TOPMARGIN, 7 BOTTOMMARGIN, 107 END diff --git a/language/np3_de_de/strings_de_de.rc b/language/np3_de_de/strings_de_de.rc index ba8fcb536..00f5f4ba4 100644 --- a/language/np3_de_de/strings_de_de.rc +++ b/language/np3_de_de/strings_de_de.rc @@ -157,7 +157,7 @@ STRINGTABLE BEGIN IDS_MUI_SELRECT "Diese Operation kann nicht mit einer Rechteck-Selektion durchgeführt werden." IDS_MUI_BUFFERTOOSMALL "Diese Operation kann nicht durchgeführt werden (die Zeilen sind zu lang)." - IDS_MUI_FIND_WRAPFW "Das Ende des Dokumentes wurde erreicht, Vorwärtssuche Anfang her weiter führen." + IDS_MUI_FIND_WRAPFW "Das Ende des Dokumentes wurde erreicht, Vorwärtssuche vom Anfang her weiter führen." IDS_MUI_FIND_WRAPRE "Der Anfang des Dokumentes wurde erreicht, Rückwärtssuche vom Ende her weiter führen." IDS_MUI_NOTFOUND "Der gegebene Suchbegriff wurde nicht gefunden." IDS_MUI_REPLCOUNT "%i Fundstellen des gegebenen Suchbegriffs wurden ersetzt." @@ -231,9 +231,9 @@ END STRINGTABLE BEGIN IDS_MUI_MENU_LANGUAGE "Sprache" - IDS_MUI_MENU_THEMES "Farben" - IDM_THEMES_DEFAULT "Factory Default" - IDM_THEMES_FILE_ITEM "Standard Settings" + IDS_MUI_MENU_THEMES "Farbschema" + IDM_THEMES_DEFAULT "Fabrik-Vorgaben" + IDM_THEMES_FILE_ITEM "Standard Einstellungen" END STRINGTABLE diff --git a/minipath/src/Helpers.c b/minipath/src/Helpers.c index aa34a53f1..37db16868 100644 --- a/minipath/src/Helpers.c +++ b/minipath/src/Helpers.c @@ -215,7 +215,7 @@ DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID) wsprintf((LPWSTR)lpDisplayBuf, L"Error: '%s' failed with error id %d:\n%s.\n", lpszFunction, dwErrID, (LPWSTR)lpMsgBuf); - MessageBox(NULL, (LPCWSTR)lpDisplayBuf, L"Notepad3 - ERROR", MB_OK | MB_ICONEXCLAMATION); + MessageBoxEx(NULL, (LPCWSTR)lpDisplayBuf, L"MiniPath - ERROR", MB_OK | MB_ICONEXCLAMATION, g_iPrefLANGID); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); diff --git a/minipath/src/minipath.c b/minipath/src/minipath.c index 14e6a9ef6..8d4c9dbe5 100644 --- a/minipath/src/minipath.c +++ b/minipath/src/minipath.c @@ -3603,6 +3603,7 @@ BOOL DisplayPath(LPCWSTR lpPath,UINT uIdError) lstrcpy(szTmp,szPath); SHFILEINFO shfi; + ZeroMemory(&shfi, sizeof(SHFILEINFO)); SHGetFileInfo(szPath,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); WCHAR *p = StrRChr(szPath, NULL, L'\\'); @@ -3926,7 +3927,7 @@ void LoadTargetParamsOnce(void) return; pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - cbIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + cbIniSection = pIniSection ? (int)LocalSize(pIniSection)/sizeof(WCHAR) : 0; LoadIniSection(L"Target Application",pIniSection,cbIniSection); diff --git a/src/Dialogs.c b/src/Dialogs.c index c4200537f..92f2348bb 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -15,12 +15,12 @@ #include "Helpers.h" #include -#include #include #include #include #include #include + #include #pragma warning( push ) @@ -44,7 +44,7 @@ // // MsgBoxLng() // -static HHOOK hhkMsgBox = NULL; +static HHOOK s_hhkMsgBox = NULL; static LRESULT CALLBACK _MsgBoxProc(INT nCode, WPARAM wParam, LPARAM lParam) { @@ -65,26 +65,77 @@ static LRESULT CALLBACK _MsgBoxProc(INT nCode, WPARAM wParam, LPARAM lParam) PostMessage(hChildWnd, WM_SETFOCUS, 0, 0); // exit _MsgBoxProc hook - UnhookWindowsHookEx(hhkMsgBox); + UnhookWindowsHookEx(s_hhkMsgBox); } else // otherwise, continue with any possible chained hooks { - CallNextHookEx(hhkMsgBox, nCode, wParam, lParam); + CallNextHookEx(s_hhkMsgBox, nCode, wParam, lParam); } return 0; } // ----------------------------------------------------------------------------- -int MsgBoxLng(int iType, UINT uIdMsg, ...) +//============================================================================= +// +// GetLastErrorToMsgBox() +// +DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID) { - WCHAR szText[HUGE_BUFFER] = { L'\0' }; - WCHAR szFormat[HUGE_BUFFER] = { L'\0' }; - WCHAR szErr[HUGE_BUFFER] = { L'\0' }; - WCHAR szTitle[64] = { L'\0' }; + // Retrieve the system error message for the last-error code + if (!dwErrID) { + dwErrID = GetLastError(); + } - if (!GetLngString(uIdMsg, szFormat, COUNTOF(szFormat))) { return 0; } - const PUINT_PTR argp = (PUINT_PTR)&uIdMsg + 1; + LPVOID lpMsgBuf = NULL; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dwErrID, + Globals.iPrefLANGID, + (LPTSTR)& lpMsgBuf, + 0, NULL); + + if (lpMsgBuf) { + // Display the error message and exit the process + size_t const len = StringCchLenW((LPCWSTR)lpMsgBuf, 0) + StringCchLenW((LPCWSTR)lpszFunction, 0) + 80; + LPWSTR lpDisplayBuf = (LPWSTR)AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY); + + if (lpDisplayBuf) { + StringCchPrintf(lpDisplayBuf, len, L"Error: '%s' failed with error id %d:\n%s.\n", + lpszFunction, dwErrID, (LPCWSTR)lpMsgBuf); + + // center message box to main + HWND focus = GetFocus(); + HWND hwnd = focus ? focus : Globals.hwndMain; + s_hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId()); + + MessageBoxEx(hwnd, lpDisplayBuf, L"Notepad3 - ERROR", MB_ICONERROR, Globals.iPrefLANGID); + + FreeMem(lpDisplayBuf); + } + LocalFree(lpMsgBuf); // LocalAlloc() + } + return dwErrID; +} + + +//============================================================================= +// +// MessageBoxLng() +// +int MessageBoxLng(UINT uType, UINT uidMsg, ...) +{ + WCHAR szFormat[HUGE_BUFFER] = { L'\0' }; + if (!GetLngString(uidMsg, szFormat, COUNTOF(szFormat))) { return -1; } + + WCHAR szTitle[64] = { L'\0' }; + GetLngString(IDS_MUI_APPTITLE, szTitle, COUNTOF(szTitle)); + + WCHAR szText[HUGE_BUFFER] = { L'\0' }; + const PUINT_PTR argp = (PUINT_PTR)&uidMsg + 1; if (argp && *argp) { StringCchVPrintfW(szText, COUNTOF(szText), szFormat, (LPVOID)argp); } @@ -92,32 +143,11 @@ int MsgBoxLng(int iType, UINT uIdMsg, ...) StringCchCopy(szText, COUNTOF(szText), szFormat); } - if (uIdMsg == IDS_MUI_ERR_LOADFILE || uIdMsg == IDS_MUI_ERR_SAVEFILE || - uIdMsg == IDS_MUI_CREATEINI_FAIL || uIdMsg == IDS_MUI_WRITEINI_FAIL || - uIdMsg == IDS_MUI_EXPORT_FAIL || uIdMsg == IDS_MUI_ERR_ELEVATED_RIGHTS) { - WCHAR wcht; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - Globals.dwLastError, - Globals.iPrefLANGID, - szErr, COUNTOF(szErr), - NULL); - - if (StrIsNotEmpty(szErr)) { - StrTrim(szErr, L" \a\b\f\n\r\t\v"); - StringCchCat(szText, COUNTOF(szText), L"\n"); - StringCchCat(szText, COUNTOF(szText), szErr); - } - wcht = *CharPrev(szText, StrEnd(szText, COUNTOF(szText))); - if (IsCharAlphaNumeric(wcht) || wcht == '"' || wcht == '\'') - StringCchCat(szText, COUNTOF(szText), L"."); - } - - GetLngString(IDS_MUI_APPTITLE, szTitle, COUNTOF(szTitle)); +#if 0 int iIcon = MB_ICONHAND; switch (iType) { + case MBINFO: iIcon = MB_ICONINFORMATION | MB_OK; break; case MBWARN: iIcon = MB_ICONWARNING | MB_OK; break; case MBYESNO: iIcon = MB_ICONQUESTION | MB_YESNO; break; @@ -127,75 +157,107 @@ int MsgBoxLng(int iType, UINT uIdMsg, ...) case MBRETRYCANCEL: iIcon = MB_ICONQUESTION | MB_RETRYCANCEL; break; default: iIcon = MB_ICONSTOP | MB_OK; break; } - iIcon |= (MB_TOPMOST | MB_SETFOREGROUND); +#endif + + uType |= (MB_TOPMOST | MB_SETFOREGROUND); // center message box to main HWND focus = GetFocus(); HWND hwnd = focus ? focus : Globals.hwndMain; - hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId()); + s_hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId()); - DWORD volume = 0; - if (Settings.MuteMessageBeep) { - waveOutGetVolume(NULL, &volume); - waveOutSetVolume(NULL, 0); - } - - int const res = MessageBoxEx(hwnd, szText, szTitle, iIcon, Globals.iPrefLANGID); - - if (Settings.MuteMessageBeep) { - waveOutSetVolume(NULL, volume); - } - - return res; + return MessageBoxEx(hwnd, szText, szTitle, uType, Globals.iPrefLANGID); } //============================================================================= // -// InfoBoxDlgProc() +// _InfoBoxLngDlgProc() // // -typedef struct _infobox { + +typedef struct _infbox { + UINT uType; LPWSTR lpstrMessage; LPWSTR lpstrSetting; bool bDisableCheckBox; -} INFOBOX, *LPINFOBOX; +} INFOBOXLNG, *LPINFOBOXLNG; -static INT_PTR CALLBACK InfoBoxDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) + +static INT_PTR CALLBACK _InfoBoxLngDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { - LPINFOBOX lpib; + LPINFOBOXLNG lpMsgBox = NULL; switch (umsg) { case WM_INITDIALOG: + { + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } + + SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam); + lpMsgBox = (LPINFOBOXLNG)lParam; + + switch (lpMsgBox->uType & MB_ICONMASK) { - if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } - SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam); - lpib = (LPINFOBOX)lParam; + case MB_ICONINFORMATION: // = MB_ICONASTERISK SendDlgItemMessage(hwnd, IDC_INFOBOXICON, STM_SETICON, (WPARAM)LoadIcon(NULL, IDI_INFORMATION), 0); - SetDlgItemText(hwnd, IDC_INFOBOXTEXT, lpib->lpstrMessage); - if (lpib->bDisableCheckBox) { DialogEnableWindow(hwnd, IDC_INFOBOXCHECK, false); } - FreeMem(lpib->lpstrMessage); - CenterDlgInParent(hwnd); + break; + case MB_ICONQUESTION: + SendDlgItemMessage(hwnd, IDC_INFOBOXICON, STM_SETICON, (WPARAM)LoadIcon(NULL, IDI_QUESTION), 0); + break; + case MB_ICONWARNING: // = MB_ICONEXCLAMATION + SendDlgItemMessage(hwnd, IDC_INFOBOXICON, STM_SETICON, (WPARAM)LoadIcon(NULL, IDI_WARNING), 0); + break; + case MB_ICONERROR: // = MB_ICONSTOP, MB_ICONHAND + SendDlgItemMessage(hwnd, IDC_INFOBOXICON, STM_SETICON, (WPARAM)LoadIcon(NULL, IDI_ERROR), 0); + break; + case MB_USERICON: + default: + SendDlgItemMessage(hwnd, IDC_INFOBOXICON, STM_SETICON, (WPARAM)LoadIcon(NULL, IDI_APPLICATION), 0); + break; } - return true; + + SetDlgItemText(hwnd, IDC_INFOBOXTEXT, lpMsgBox->lpstrMessage); + + if (lpMsgBox->bDisableCheckBox) { + DialogEnableWindow(hwnd, IDC_INFOBOXCHECK, false); + DialogHideWindow(hwnd, IDC_INFOBOXCHECK, true); + } + + CenterDlgInParent(hwnd); + AttentionBeep(lpMsgBox->uType); + + FreeMem(lpMsgBox->lpstrMessage); + } + return true; + case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; + case WM_COMMAND: + lpMsgBox = (LPINFOBOXLNG)GetWindowLongPtr(hwnd, DWLP_USER); switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: case IDYES: case IDNO: - lpib = (LPINFOBOX)GetWindowLongPtr(hwnd, DWLP_USER); - if (IsButtonChecked(hwnd, IDC_INFOBOXCHECK)) { - IniSetInt(L"Suppressed Messages", lpib->lpstrSetting, 1); + if (IsButtonChecked(hwnd, IDC_INFOBOXCHECK) && StrIsNotEmpty(lpMsgBox->lpstrSetting)) { + IniSetInt(L"Suppressed Messages", lpMsgBox->lpstrSetting, LOWORD(wParam)); } + case IDABORT: + case IDRETRY: + case IDIGNORE: + case IDCLOSE: + case IDTRYAGAIN: + case IDCONTINUE: EndDialog(hwnd, LOWORD(wParam)); + return true; + + default: break; } return true; @@ -209,45 +271,79 @@ static INT_PTR CALLBACK InfoBoxDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR // InfoBoxLng() // // - -INT_PTR InfoBoxLng(int iType, LPCWSTR lpstrSetting, int uidMessage, ...) +INT_PTR InfoBoxLng(UINT uType, LPCWSTR lpstrSetting, UINT uidMsg, ...) { - int iMode = IniGetInt(L"Suppressed Messages", lpstrSetting, 0); + int const iMode = StrIsEmpty(lpstrSetting) ? 0 : IniGetInt(L"Suppressed Messages", lpstrSetting, 0); + if (iMode) { return iMode; } - if (StrIsNotEmpty(lpstrSetting) && iMode == 1) { - return (iType == MBYESNO) ? IDYES : IDOK; - } - WCHAR wchFormat[LARGE_BUFFER]; - if (!GetLngString(uidMessage, wchFormat, COUNTOF(wchFormat))) - return(-1); + WCHAR wchMessage[LARGE_BUFFER]; + if (!GetLngString(uidMsg, wchMessage, COUNTOF(wchMessage))) { return -1LL; } - INFOBOX ib; - ib.lpstrMessage = AllocMem(HUGE_BUFFER * sizeof(WCHAR), HEAP_ZERO_MEMORY); - if (ib.lpstrMessage) { - StringCchVPrintfW(ib.lpstrMessage, HUGE_BUFFER, wchFormat, (LPVOID)((PUINT_PTR)&uidMessage + 1)); + INFOBOXLNG msgBox; + 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); } - ib.lpstrSetting = (LPWSTR)lpstrSetting; - ib.bDisableCheckBox = (StrIsEmpty(Globals.IniFile) || StrIsEmpty(lpstrSetting) || iMode == 2) ? true : false; + else { + StringCchCopy(msgBox.lpstrMessage, COUNTOF(wchMessage), wchMessage); + } + + if (uidMsg == IDS_MUI_ERR_LOADFILE || uidMsg == IDS_MUI_ERR_SAVEFILE || + uidMsg == IDS_MUI_CREATEINI_FAIL || uidMsg == IDS_MUI_WRITEINI_FAIL || + uidMsg == IDS_MUI_EXPORT_FAIL || uidMsg == IDS_MUI_ERR_ELEVATED_RIGHTS) + { + WCHAR wchErr[MIDSZ_BUFFER] = { L'\0' }; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + Globals.dwLastError, + Globals.iPrefLANGID, + wchErr, COUNTOF(wchErr), + NULL); + + if (StrIsNotEmpty(wchErr)) { + StrTrim(wchErr, L" \a\b\f\n\r\t\v"); + StringCchCat(msgBox.lpstrMessage, COUNTOF(wchMessage), L"\n\n"); + StringCchCat(msgBox.lpstrMessage, COUNTOF(wchMessage), wchErr); + } + 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 = (StrIsEmpty(Globals.IniFile) || StrIsEmpty(lpstrSetting)) ? true : false; + int idDlg; - switch (iType) { - case MBYESNO: + switch (uType & MB_TYPEMASK) { + + case MB_YESNO: // contains two push buttons : Yes and No. idDlg = IDD_MUI_INFOBOX2; break; - case MBOKCANCEL: + + case MB_OKCANCEL: // contains two push buttons : OK and Cancel. idDlg = IDD_MUI_INFOBOX3; break; + + case MB_RETRYCANCEL: // contains two push buttons : Retry and Cancel. + 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_YESNOCANCEL: // contains three push buttons : Yes, No, and Cancel. + + case MB_OK: // one push button : OK. This is the default. default: idDlg = IDD_MUI_INFOBOX; break; } - AttentionBeep(MB_ICONINFORMATION); - HWND focus = GetFocus(); HWND hwnd = focus ? focus : Globals.hwndMain; - return ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(idDlg), hwnd, InfoBoxDlgProc, (LPARAM)&ib); + return ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(idDlg), hwnd, _InfoBoxLngDlgProc, (LPARAM)&msgBox); } @@ -292,19 +388,16 @@ static INT_PTR CALLBACK CmdLineHelpProc(HWND hwnd, UINT umsg, WPARAM wParam, LPA case WM_INITDIALOG: { if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } - //WCHAR szTitle[80] = { L'\0' }; - //GetLngString(IDS_MUI_APPTITLE, szTitle, COUNTOF(szTitle)); - //SetWindowText(hwnd, szTitle); WCHAR szText[4096] = { L'\0' }; GetLngString(IDS_MUI_CMDLINEHELP, szText, COUNTOF(szText)); SetDlgItemText(hwnd, IDC_CMDLINEHELP, szText); CenterDlgInParent(hwnd); } - break; + return true; case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -661,7 +754,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_PAINT: @@ -672,7 +765,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam DrawIconEx(hdc, 16, 32, Globals.hIcon128, 128, 128, 0, NULL, DI_NORMAL); ReleaseDC(hwnd, hdc); } - return 0; + return false; case WM_NOTIFY: @@ -783,7 +876,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPar case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: @@ -964,7 +1057,7 @@ static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: @@ -1062,7 +1155,7 @@ static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM if (lpdli->ntype != DLE_NONE) EndDialog(hwnd,IDOK); else - AttentionBeep(0); + SimpleBeep(); } break; @@ -1162,7 +1255,7 @@ static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: @@ -1259,7 +1352,7 @@ static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA if (lpdli->ntype != DLE_NONE) EndDialog(hwnd,IDOK); else - AttentionBeep(0); + SimpleBeep(); } break; @@ -1374,10 +1467,10 @@ bool AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget) if (iResult == IDOK) { if (!PathCreateFavLnk(pszName,lpszTarget,Settings.FavoritesDir)) { - MsgBoxLng(MBWARN,IDS_MUI_FAV_FAILURE); + InfoBoxLng(MB_ICONWARNING,NULL,IDS_MUI_FAV_FAILURE); return false; } - MsgBoxLng(MBINFO,IDS_MUI_FAV_SUCCESS); + InfoBoxLng(MB_ICONINFORMATION, NULL, IDS_MUI_FAV_SUCCESS); return true; } return false; @@ -1541,7 +1634,7 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: @@ -1785,7 +1878,7 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM } // Ask... - int answ = (LOWORD(wParam) == IDOK) ? MsgBoxLng(MBYESNOWARN, IDS_MUI_ERR_MRUDLG) + int answ = (LOWORD(wParam) == IDOK) ? (int)InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_ERR_MRUDLG) : ((iCur == lvi.iItem) ? IDNO : IDYES); if (IDYES == answ) { @@ -1873,7 +1966,7 @@ static INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -1948,7 +2041,7 @@ static INT_PTR CALLBACK ColumnWrapDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, L case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: @@ -2050,7 +2143,7 @@ static INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wPa case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: @@ -2147,7 +2240,7 @@ static INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wPa case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: @@ -2244,7 +2337,7 @@ static INT_PTR CALLBACK TabSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPA case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: @@ -2377,7 +2470,7 @@ static INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd, UINT umsg, WPARAM wP case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: @@ -2441,7 +2534,7 @@ static INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd, UINT umsg, WPARAM wP PENCODEDLG pdd = (PENCODEDLG)GetWindowLongPtr(hwnd, DWLP_USER); if (Encoding_GetFromComboboxEx(GetDlgItem(hwnd, IDC_ENCODINGLIST), &pdd->idEncoding)) { if (pdd->idEncoding < 0) { - MsgBoxLng(MBWARN, IDS_MUI_ERR_ENCODINGNA); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_ENCODINGNA); EndDialog(hwnd, IDCANCEL); } else { @@ -2548,7 +2641,7 @@ static INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam, case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: @@ -2611,7 +2704,7 @@ static INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam, PENCODEDLG pdd = (PENCODEDLG)GetWindowLongPtr(hwnd, DWLP_USER); if (Encoding_GetFromListView(hwndLV, &pdd->idEncoding)) { if (pdd->idEncoding < 0) { - MsgBoxLng(MBWARN, IDS_MUI_ERR_ENCODINGNA); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_ENCODINGNA); EndDialog(hwnd, IDCANCEL); } else { @@ -2706,10 +2799,6 @@ bool RecodeDlg(HWND hwnd, cpi_enc_t* pidREncoding) } - - - - //============================================================================= // // SelectDefLineEndingDlgProc() @@ -2747,7 +2836,7 @@ static INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wP case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: @@ -3266,9 +3355,9 @@ void DialogFileBrowse(HWND hwnd) sei.nShow = SW_SHOWNORMAL; ShellExecuteEx(&sei); - if ((INT_PTR)sei.hInstApp < 32) - MsgBoxLng(MBWARN, IDS_MUI_ERR_BROWSE); - + if ((INT_PTR)sei.hInstApp < 32) { + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BROWSE); + } } @@ -3308,7 +3397,7 @@ void DialogAdminExe(HWND hwnd, bool bExecInstaller) ShellExecuteEx(&sei); if ((INT_PTR)sei.hInstApp < 32) { - if (IDOK == InfoBoxLng(MBOKCANCEL, L"NoAdminTool", IDS_MUI_ERR_ADMINEXE)) + if (IDOK == InfoBoxLng(MB_OKCANCEL, L"NoAdminTool", IDS_MUI_ERR_ADMINEXE)) { sei.lpFile = VERSION_UPDATE_CHECK; ShellExecuteEx(&sei); diff --git a/src/Dialogs.h b/src/Dialogs.h index a2d6763d1..93c45d55d 100644 --- a/src/Dialogs.h +++ b/src/Dialogs.h @@ -18,7 +18,6 @@ #include "TypeDefs.h" -int MsgBoxLng(int iType, UINT uIdMsg, ...); INT_PTR DisplayCmdLineHelp(HWND hwnd); bool GetDirectory(HWND hwndParent,int uiTitle,LPWSTR pszFolder,LPCWSTR pszBase,bool); INT_PTR CALLBACK AboutDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam); @@ -48,7 +47,10 @@ WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo); void DialogNewWindow(HWND hwnd,bool,bool); void DialogFileBrowse(HWND hwnd); void DialogAdminExe(HWND hwnd,bool); -INT_PTR InfoBoxLng(int iType, LPCWSTR lpstrSetting, int uidMessage, ...); + +int MessageBoxLng(UINT uType, UINT uIdMsg, ...); +INT_PTR InfoBoxLng(UINT uType, LPCWSTR lpstrSetting, UINT uidMessage, ...); +DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID); bool SetWindowTitle(HWND hwnd, UINT uIDAppName, bool, UINT uIDUntitled, LPCWSTR lpszFile, int iFormat, bool, UINT uIDReadOnly, bool, LPCWSTR lpszExcerpt); void SetAdditionalTitleInfo(LPCWSTR lpszAddTitleInfo); @@ -76,8 +78,20 @@ int Toolbar_SetButtons(HWND, int, LPCWSTR, void*, int); LRESULT SendWMSize(HWND hwnd, RECT* rc); +// ---------------------------------------------------------------------------- + +inline void SimpleBeep() { if (!Settings.MuteMessageBeep) { MessageBeep(0xFFFFFFFF); } } +inline void AttentionBeep(UINT uType) { if (!Settings.MuteMessageBeep) { MessageBeep(uType & MB_ICONMASK); } } + +#define DialogEnableWindow(hdlg, id, b) { HWND hctrl = GetDlgItem((hdlg),(id)); if (!(b)) { \ + if (GetFocus() == hctrl) { SendMessage((hdlg), WM_NEXTDLGCTL, 0, false); } }; EnableWindow(hctrl, (b)); } + +#define DialogHideWindow(hdlg, id, b) { HWND hctrl = GetDlgItem((hdlg),(id)); if (!(b)) { \ + if (GetFocus() == hctrl) { SendMessage((hdlg), WM_NEXTDLGCTL, 0, false); } }; ShowWindow(hctrl, (b)?SW_HIDE:SW_SHOW); } + + +// --- Themed Dialogs --------------------------------------------------------- -//==== Themed Dialogs ========================================================= #ifndef DLGTEMPLATEEX #pragma pack(push, 1) typedef struct { @@ -97,10 +111,10 @@ typedef struct { bool GetThemedDialogFont(LPWSTR lpFaceName, WORD* wSize); DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR lpDialogTemplateID, HINSTANCE hInstance); -#define ThemedDialogBox(hInstance,lpTemplate,hWndParent,lpDialogFunc) \ - ThemedDialogBoxParam(hInstance,lpTemplate,hWndParent,lpDialogFunc,0) +#define ThemedDialogBox(hInstance,lpTemplate,hWndParent,lpDialogFunc) ThemedDialogBoxParam(hInstance,lpTemplate,hWndParent,lpDialogFunc,0) INT_PTR ThemedDialogBoxParam(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); HWND CreateThemedDialogParam(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); +// ---------------------------------------------------------------------------- #endif //_NP3_DIALOGS_H_ diff --git a/src/Edit.c b/src/Edit.c index f5f6827ec..68cf17a9f 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -456,7 +456,7 @@ bool EditSetNewEncoding(HWND hwnd, cpi_enc_t iNewEncoding, bool bNoUI, bool bSet bool doNewEncoding = (!bIsEmptyUndoHistory && !bNoUI) ? - (InfoBoxLng(MBYESNO, L"MsgConv2", IDS_MUI_ASK_ENCODING2) == IDYES) : true; + (InfoBoxLng(MB_YESNO, L"MsgConv2", IDS_MUI_ASK_ENCODING2) == IDYES) : true; if (doNewEncoding) { return EditConvertText(hwnd,iCurrentEncoding,iNewEncoding,bSetSavePoint); @@ -464,7 +464,7 @@ bool EditSetNewEncoding(HWND hwnd, cpi_enc_t iNewEncoding, bool bNoUI, bool bSet } else { - bool doNewEncoding = (!bNoUI) ? (InfoBoxLng(MBYESNO, L"MsgConv1", IDS_MUI_ASK_ENCODING) == IDYES) : true; + bool doNewEncoding = (!bNoUI) ? (InfoBoxLng(MB_YESNO, L"MsgConv1", IDS_MUI_ASK_ENCODING) == IDYES) : true; if (doNewEncoding) { return EditConvertText(hwnd,iCurrentEncoding,iNewEncoding,false); @@ -749,7 +749,7 @@ bool EditCopyAppend(HWND hwnd, bool bAppend) if (iSelStart != iSelEnd) { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return res; } length = (iSelEnd - iSelStart); @@ -997,7 +997,7 @@ bool EditLoadFile( // check for unknown extension LPCWSTR lpszExt = PathFindExtension(pszFile); if (lpszExt && !Style_HasLexerForExt(lpszExt)) { - if (InfoBoxLng(MBYESNO, L"MsgFileUnknownExt", IDS_MUI_WARN_UNKNOWN_EXT, lpszExt) != IDYES) { + if (InfoBoxLng(MB_YESNO, L"MsgFileUnknownExt", IDS_MUI_WARN_UNKNOWN_EXT, lpszExt) != IDYES) { CloseHandle(hFile); status->bUnknownExt = true; Encoding_SrcCmdLn(CPI_NONE); @@ -1009,7 +1009,7 @@ bool EditLoadFile( // Check if a warning message should be displayed for large files DWORD dwFileSizeLimit = Settings2.FileLoadWarningMB; if ((dwFileSizeLimit != 0) && ((dwFileSizeLimit * 1024 * 1024) < dwFileSize)) { - if (InfoBoxLng(MBYESNO, L"MsgFileSizeWarning", IDS_MUI_WARN_LOAD_BIG_FILE) != IDYES) { + if (InfoBoxLng(MB_YESNO, L"MsgFileSizeWarning", IDS_MUI_WARN_LOAD_BIG_FILE) != IDYES) { CloseHandle(hFile); status->bFileTooBig = true; Encoding_SrcCmdLn(CPI_NONE); @@ -1039,7 +1039,7 @@ bool EditLoadFile( // ((readFlag == DECRYPT_SUCCESS) || (readFlag & DECRYPT_NO_ENCRYPTION)) => true; if ((readFlag & DECRYPT_CANCELED_NO_PASS) || (readFlag & DECRYPT_WRONG_PASS)) { - bReadSuccess = (InfoBoxLng(MBOKCANCEL, L"MsgNoOrWrongPassphrase", IDS_MUI_NOPASS) == IDOK); + bReadSuccess = (InfoBoxLng(MB_OKCANCEL, L"MsgNoOrWrongPassphrase", IDS_MUI_NOPASS) == IDOK); if (!bReadSuccess) { FreeMem(lpData); return true; @@ -1387,7 +1387,7 @@ bool EditSaveFile( bEncodingMismatch = false; } if (bEncodingMismatch) { - InfoBoxLng(0,L"MsgEncodingMismatch",IDS_MUI_ENCODINGMISMATCH, + InfoBoxLng(MB_OK,L"MsgEncodingMismatch",IDS_MUI_ENCODINGMISMATCH, g_Encodings[iAltEncoding].wchLabel, g_Encodings[iEncoding].wchLabel); } @@ -1463,7 +1463,7 @@ bool EditSaveFile( } FreeMem(lpDataWide); - if (!bCancelDataLoss || InfoBoxLng(MBOKCANCEL,L"MsgConv3",IDS_MUI_ERR_UNICODE2) == IDOK) { + if (!bCancelDataLoss || InfoBoxLng(MB_OKCANCEL,L"MsgConv3",IDS_MUI_ERR_UNICODE2) == IDOK) { SetEndOfFile(hFile); bWriteSuccess = EncryptAndWriteFile(hwnd, hFile, (BYTE*)lpData, cbData, &dwBytesWritten); Globals.dwLastError = GetLastError(); @@ -1549,7 +1549,7 @@ void EditInvertCase(HWND hwnd) FreeMem(pszTextW); } else - MsgBoxLng(MBWARN,IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL,IDS_MUI_SELRECT); } } @@ -1611,7 +1611,7 @@ void EditTitleCase(HWND hwnd) FreeMem(pszTextW); } else - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); } } @@ -1684,8 +1684,9 @@ void EditSentenceCase(HWND hwnd) FreeMem(pszText); FreeMem(pszTextW); } - else - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + else { + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); + } } } @@ -1699,7 +1700,7 @@ void EditURLEncode(HWND hwnd) if (SciCall_IsSelectionEmpty()) { return; } if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -1767,7 +1768,7 @@ void EditURLDecode(HWND hwnd) if (SciCall_IsSelectionEmpty()) { return; } if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -1836,7 +1837,7 @@ void EditEscapeCChars(HWND hwnd) { { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -1868,7 +1869,7 @@ void EditUnescapeCChars(HWND hwnd) { { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -1897,7 +1898,7 @@ void EditUnescapeCChars(HWND hwnd) { void EditChar2Hex(HWND hwnd) { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -1955,7 +1956,7 @@ void EditHex2Char(HWND hwnd) if (SciCall_IsSelectionEmpty()) { return; } if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -2081,7 +2082,7 @@ void EditSelectToMatchingBrace(HWND hwnd) void EditModifyNumber(HWND hwnd,bool bIncrease) { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -2153,7 +2154,7 @@ void EditTabsToSpaces(HWND hwnd,int nTabWidth,bool bOnlyIndentingWS) if (SciCall_IsSelectionEmpty()) { return; } // no selection if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -2248,7 +2249,7 @@ void EditSpacesToTabs(HWND hwnd,int nTabWidth,bool bOnlyIndentingWS) if (SciCall_IsSelectionEmpty()) { return; } // no selection if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -2361,7 +2362,7 @@ void EditSpacesToTabs(HWND hwnd,int nTabWidth,bool bOnlyIndentingWS) static void _EditMoveLines(bool bMoveUp) { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); } else { @@ -2698,8 +2699,9 @@ void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend) EditSetSelectionEx(hwnd, iAnchorPos, iCurPos, -1, -1); } } - else - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + else { + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); + } } @@ -2813,7 +2815,7 @@ void EditAlignText(HWND hwnd, int nMode) DocPos const iAnchorCol = SciCall_GetColumn(iAnchorPos); if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } if (iLineEnd <= iLineStart) { return; } @@ -3008,7 +3010,7 @@ void EditAlignText(HWND hwnd, int nMode) FreeMem(chNewLineBuf); } else { - MsgBoxLng(MBINFO, IDS_MUI_BUFFERTOOSMALL); + InfoBoxLng(MB_ICONERROR, NULL, IDS_MUI_BUFFERTOOSMALL); } if (iAnchorPos > iCurPos) { @@ -3032,7 +3034,7 @@ void EditAlignText(HWND hwnd, int nMode) void EditEncloseSelection(HWND hwnd, LPCWSTR pwszOpen, LPCWSTR pwszClose) { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -3092,7 +3094,7 @@ void EditToggleLineComments(HWND hwnd, LPCWSTR pwszComment, bool bInsertAtStart) if (cchComment == 0) { return; } if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -3707,7 +3709,7 @@ void EditRemoveBlankLines(HWND hwnd, bool bMerge, bool bRemoveWhiteSpace) UNUSED(hwnd); if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -3779,7 +3781,7 @@ void EditRemoveDuplicateLines(HWND hwnd, bool bRemoveEmptyLines) UNUSED(hwnd); if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -3849,7 +3851,7 @@ void EditRemoveDuplicateLines(HWND hwnd, bool bRemoveEmptyLines) void EditWrapToColumn(HWND hwnd,DocPos nColumn/*,int nTabWidth*/) { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -4030,7 +4032,7 @@ void EditJoinLinesEx(HWND hwnd, bool bPreserveParagraphs, bool bCRLF2Space) return; if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return; } @@ -5228,7 +5230,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: @@ -5269,7 +5271,9 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara if (s_fwrdMatch == NO_MATCH) { EditSetSelectionEx(Globals.hwndEdit, s_InitialAnchorPos, s_InitialCaretPos, -1, -1); } - EditEnsureSelectionVisible(Globals.hwndEdit); + else { + EditEnsureSelectionVisible(Globals.hwndEdit); + } } CmdMessageQueue_t* pmqc = NULL; @@ -5303,7 +5307,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara // mouse click activation case WA_ACTIVE: SetWindowTransparentMode(hwnd, false, 100); - default: + s_fwrdMatch = NO_MATCH; s_InitialSearchStart = SciCall_GetSelectionStart(); @@ -5313,11 +5317,15 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara s_InitialTopLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); } - EditEnsureSelectionVisible(Globals.hwndEdit); + if (!SciCall_IsSelectionEmpty()) { + EditEnsureSelectionVisible(Globals.hwndEdit); + } bool const bEnableReplInSel = !(SciCall_IsSelectionEmpty() || SciCall_IsSelectionRectangle()); DialogEnableWindow(hwnd, IDC_REPLACEINSEL, bEnableReplInSel); + break; + default: break; } } @@ -5466,7 +5474,6 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara } else { EditSetSelectionEx(Globals.hwndEdit, s_InitialAnchorPos, s_InitialCaretPos, -1, -1); - EditEnsureSelectionVisible(Globals.hwndEdit); } } if (EditToggleView(Globals.hwndEdit, false)) { EditHideNotMarkedLineRange(Globals.hwndEdit, -1, -1, true); } @@ -5832,13 +5839,13 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara } // Display help messages in the find/replace windows else if (pnmhdr->idFrom == IDC_BACKSLASHHELP) { - MsgBoxLng(MBINFO, IDS_MUI_BACKSLASHHELP); + MessageBoxLng(MB_ICONINFORMATION, IDS_MUI_BACKSLASHHELP); } else if (pnmhdr->idFrom == IDC_REGEXPHELP) { - MsgBoxLng(MBINFO, IDS_MUI_REGEXPHELP); + MessageBoxLng(MB_ICONINFORMATION, IDS_MUI_REGEXPHELP); } else if (pnmhdr->idFrom == IDC_WILDCARDHELP) { - MsgBoxLng(MBINFO, IDS_MUI_WILDCARDHELP); + MessageBoxLng(MB_ICONINFORMATION, IDS_MUI_WILDCARDHELP); } break; @@ -5942,7 +5949,7 @@ bool EditFindNext(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo DocPos end = iTextLength; if (start >= end) { - if (IDOK == InfoBoxLng(MBOKCANCEL, L"MsgFindWrap1", IDS_MUI_FIND_WRAPFW)) { + if (IDOK == InfoBoxLng(MB_OKCANCEL, L"MsgFindWrap1", IDS_MUI_FIND_WRAPFW)) { end = min_p(start, iTextLength); start = 0; } else @@ -5954,20 +5961,20 @@ bool EditFindNext(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo DocPos iPos = _FindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, true, FRMOD_NORM); if ((iPos < -1) && (lpefr->fuFlags & SCFIND_REGEXP)) { - InfoBoxLng(MBWARN, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID); + InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID); bSuppressNotFound = true; } else if ((iPos < 0) && (start > 0) && !bExtendSelection) { UpdateStatusbar(false); if (!lpefr->bNoFindWrap && !bSuppressNotFound) { - if (IDOK == InfoBoxLng(MBOKCANCEL, L"MsgFindWrap2", IDS_MUI_FIND_WRAPFW)) { + if (IDOK == InfoBoxLng(MB_OKCANCEL, L"MsgFindWrap2", IDS_MUI_FIND_WRAPFW)) { end = min_p(start, iTextLength); start = 0; iPos = _FindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, false, FRMOD_WRAPED); if ((iPos < -1) && (lpefr->fuFlags & SCFIND_REGEXP)) { - InfoBoxLng(MBWARN, L"MsgInvalidRegex2", IDS_MUI_REGEX_INVALID); + InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex2", IDS_MUI_REGEX_INVALID); bSuppressNotFound = true; } } @@ -5977,8 +5984,9 @@ bool EditFindNext(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo } if (iPos < 0) { - if (!bSuppressNotFound) - InfoBoxLng(0, L"MsgNotFound", IDS_MUI_NOTFOUND); + if (!bSuppressNotFound) { + InfoBoxLng(MB_OK, L"MsgNotFound", IDS_MUI_NOTFOUND); + } return false; } @@ -6021,7 +6029,7 @@ bool EditFindPrev(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo DocPos end = 0; if (start <= end) { - if (IDOK == InfoBoxLng(MBOKCANCEL, L"MsgFindWrap1", IDS_MUI_FIND_WRAPFW)) { + if (IDOK == InfoBoxLng(MB_OKCANCEL, L"MsgFindWrap1", IDS_MUI_FIND_WRAPFW)) { end = start; start = iTextLength; } else @@ -6034,7 +6042,7 @@ bool EditFindPrev(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo if ((iPos < -1) && (lpefr->fuFlags & SCFIND_REGEXP)) { - InfoBoxLng(MBWARN, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID); + InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID); bSuppressNotFound = true; } else if ((iPos < 0) && (start <= iTextLength) && !bExtendSelection) @@ -6042,13 +6050,13 @@ bool EditFindPrev(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo UpdateStatusbar(false); if (!lpefr->bNoFindWrap && !bSuppressNotFound) { - if (IDOK == InfoBoxLng(MBOKCANCEL, L"MsgFindWrap2", IDS_MUI_FIND_WRAPRE)) { + if (IDOK == InfoBoxLng(MB_OKCANCEL, L"MsgFindWrap2", IDS_MUI_FIND_WRAPRE)) { end = start; start = iTextLength; iPos = _FindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, false, FRMOD_WRAPED); if ((iPos < -1) && (lpefr->fuFlags & SCFIND_REGEXP)) { - InfoBoxLng(MBWARN, L"MsgInvalidRegex2", IDS_MUI_REGEX_INVALID); + InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex2", IDS_MUI_REGEX_INVALID); bSuppressNotFound = true; } } @@ -6058,8 +6066,9 @@ bool EditFindPrev(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo } if (iPos < 0) { - if (!bSuppressNotFound) - InfoBoxLng(0, L"MsgNotFound", IDS_MUI_NOTFOUND); + if (!bSuppressNotFound) { + InfoBoxLng(MB_OK, L"MsgNotFound", IDS_MUI_NOTFOUND); + } return false; } @@ -6125,28 +6134,16 @@ void EditMarkAllOccurrences(HWND hwnd, bool bForceClear) } -static void _GetVisibleRange(DocPos* piPosStart, DocPos* piPosEnd) -{ - DocLn const iFirstVisibleLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); - - DocLn const iStartLine = max_ln(0, (iFirstVisibleLine - SciCall_LinesOnScreen())); - DocLn const iEndLine = min_ln((iFirstVisibleLine + (SciCall_LinesOnScreen() << 1)), (SciCall_GetLineCount() - 1)); - - *piPosStart = SciCall_PositionFromLine(iStartLine); - *piPosEnd = SciCall_GetLineEndPosition(iEndLine); -} - //============================================================================= // // EditApplyVisibleLexerStyle() // void EditApplyVisibleLexerStyle(HWND hwnd) { - DocPos iPosStart = 0; - DocPos iPosEnd = -1; - _GetVisibleRange(&iPosStart, &iPosEnd); + DocLn const iStartLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); + DocLn const iEndLine = min_ln((iStartLine + SciCall_LinesOnScreen()), (SciCall_GetLineCount() - 1)); - EditApplyLexerStyle(hwnd, iPosStart, iPosEnd); + EditApplyLexerStyle(hwnd, SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine)); } //============================================================================= @@ -6159,14 +6156,13 @@ void EditUpdateVisibleUrlHotspot(bool bEnabled) { if (_IsInTargetTransaction()) { return; } // do not block, next event occurs for sure - DocPos iPosStart = 0; - DocPos iPosEnd = -1; - _GetVisibleRange(&iPosStart, &iPosEnd); + DocLn const iStartLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); + DocLn const iEndLine = min_ln((iStartLine + SciCall_LinesOnScreen()), (SciCall_GetLineCount() - 1)); _IGNORE_NOTIFY_CHANGE_; _ENTER_TARGET_TRANSACTION_; - EditUpdateUrlHotspots(Globals.hwndEdit, iPosStart, iPosEnd, bEnabled); + EditUpdateUrlHotspots(Globals.hwndEdit, SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine), bEnabled); _LEAVE_TARGET_TRANSACTION_; _OBSERVE_NOTIFY_CHANGE_; @@ -6301,7 +6297,7 @@ int EditReplaceAllInRange(HWND hwnd, LPCEDITFINDREPLACE lpefr, DocPos iStartPos, DocPos iPos = _FindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, false, FRMOD_NORM); if ((iPos < -1) && (lpefr->fuFlags & SCFIND_REGEXP)) { - InfoBoxLng(MBWARN, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID); + InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID); } // === build array of matches for later replacements === @@ -6386,10 +6382,12 @@ bool EditReplaceAll(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bShowInfo) EndWaitCursor(); if (bShowInfo) { - if (Globals.iReplacedOccurrences > 0) - InfoBoxLng(0, L"MsgReplaceCount", IDS_MUI_REPLCOUNT, Globals.iReplacedOccurrences); - else - InfoBoxLng(0, L"MsgNotFound", IDS_MUI_NOTFOUND); + if (Globals.iReplacedOccurrences > 0) { + InfoBoxLng(MB_OK, L"MsgReplaceCount", IDS_MUI_REPLCOUNT, Globals.iReplacedOccurrences); + } + else { + InfoBoxLng(MB_OK, L"MsgNotFound", IDS_MUI_NOTFOUND); + } } return (Globals.iReplacedOccurrences > 0) ? true : false; @@ -6403,7 +6401,7 @@ bool EditReplaceAll(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bShowInfo) bool EditReplaceAllInSelection(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bShowInfo) { if (SciCall_IsSelectionRectangle()) { - MsgBoxLng(MBWARN, IDS_MUI_SELRECT); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECT); return false; } @@ -6428,10 +6426,12 @@ bool EditReplaceAllInSelection(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bShowIn SciCall_SetSel(anchorPos, currPos + enlargement); if (bShowInfo) { - if (Globals.iReplacedOccurrences > 0) - InfoBoxLng(0, L"MsgReplaceCount", IDS_MUI_REPLCOUNT, Globals.iReplacedOccurrences); - else - InfoBoxLng(0, L"MsgNotFound", IDS_MUI_NOTFOUND); + if (Globals.iReplacedOccurrences > 0) { + InfoBoxLng(MB_OK, L"MsgReplaceCount", IDS_MUI_REPLCOUNT, Globals.iReplacedOccurrences); + } + else { + InfoBoxLng(MB_OK, L"MsgNotFound", IDS_MUI_NOTFOUND); + } } } _END_UNDO_ACTION_; @@ -7115,7 +7115,7 @@ static INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPA case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: @@ -7260,7 +7260,7 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: DeleteObject(hFontHover); @@ -7444,7 +7444,7 @@ static INT_PTR CALLBACK EditAlignDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: switch(LOWORD(wParam)) @@ -7528,7 +7528,7 @@ static INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd,UINT umsg,WPARAM w case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: switch(LOWORD(wParam)) @@ -7606,7 +7606,7 @@ static INT_PTR CALLBACK EditInsertTagDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,L case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: switch(LOWORD(wParam)) @@ -7781,7 +7781,7 @@ static INT_PTR CALLBACK EditSortDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: switch(LOWORD(wParam)) diff --git a/src/Helpers.c b/src/Helpers.c index 95b3b0a81..a0682a889 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -17,7 +17,6 @@ #include "Helpers.h" -//#include #include #include //#include @@ -265,48 +264,6 @@ bool IniSectionSetString(LPWSTR lpCachedIniSection,LPCWSTR lpName,LPCWSTR lpStri } -//============================================================================= -// -// GetLastErrorToMsgBox() -// -DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID) -{ - // 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, - Globals.iPrefLANGID, - (LPTSTR)&lpMsgBuf, - 0, NULL); - - if (lpMsgBuf) { - // Display the error message and exit the process - size_t const len = StringCchLenW((LPCWSTR)lpMsgBuf, 0) + StringCchLenW((LPCWSTR)lpszFunction, 0) + 80; - LPWSTR lpDisplayBuf = (LPWSTR)AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY); - - if (lpDisplayBuf) { - StringCchPrintf(lpDisplayBuf, len, L"Error: '%s' failed with error id %d:\n%s.\n", - lpszFunction, dwErrID, (LPCWSTR)lpMsgBuf); - - MessageBox(NULL, lpDisplayBuf, L"Notepad3 - ERROR", MB_OK | MB_ICONEXCLAMATION); - - FreeMem(lpDisplayBuf); - } - LocalFree(lpMsgBuf); // LocalAlloc() - } - return dwErrID; -} - - - //============================================================================= // // GetCurrentDPI() diff --git a/src/Helpers.h b/src/Helpers.h index 3373b254f..1bc53bdc4 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -179,11 +179,6 @@ inline COLORREF GetBackgroundColor(HWND hwnd) { return GetBkColor(GetDC(hwnd)); // ---------------------------------------------------------------------------- -inline void AttentionBeep(UINT uType) { if (!Settings.MuteMessageBeep) { MessageBeep(uType); } } -DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID); - -// ---------------------------------------------------------------------------- - //#define Is2k() (g_uWinVer >= 0x0500) #define IsXP() IsWindowsXPOrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP version. #define IsXP1() IsWindowsXPSP1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP with Service Pack 1 (SP1)version. @@ -283,10 +278,6 @@ inline bool IsButtonUnchecked(HWND hwnd, int iButtonID) { return (IsDlgButtonChe #define CheckCmdPos(hmenu,pos,b) CheckMenuItem((hmenu),(pos),(b)?MF_BYPOSITION|MF_CHECKED:MF_BYPOSITION|MF_UNCHECKED) -#define DialogEnableWindow(hdlg, id, b) { HWND hctrl = GetDlgItem((hdlg),(id)); if (!(b)) { \ - if (GetFocus() == hctrl) { SendMessage((hdlg), WM_NEXTDLGCTL, 0, false); } }; EnableWindow(hctrl, (b)); } - - bool GetKnownFolderPath(REFKNOWNFOLDERID, LPWSTR lpOutPath, size_t cchCount); void PathRelativeToApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,bool,bool,bool); void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,bool); diff --git a/src/MuiLanguage.c b/src/MuiLanguage.c index 049720063..dffb6d778 100644 --- a/src/MuiLanguage.c +++ b/src/MuiLanguage.c @@ -17,6 +17,7 @@ #include #include "resource.h" +#include "Dialogs.h" #include "Encoding.h" #include "MuiLanguage.h" diff --git a/src/Notepad3.c b/src/Notepad3.c index 545a4ed14..61ea1aabf 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -757,7 +757,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, SetTimer(hwnd, IDT_TIMER_MRKALL, USER_TIMER_MINIMUM, (TIMERPROC)MQ_ExecuteNext); if (Globals.bPrefLngNotAvail) { - InfoBoxLng(MBWARN, L"MsgPrefLanguageNotAvailable", IDS_WARN_PREF_LNG_NOT_AVAIL, Settings2.PreferredLanguageLocaleName); + InfoBoxLng(MB_ICONWARNING, L"MsgPrefLanguageNotAvailable", IDS_WARN_PREF_LNG_NOT_AVAIL, Settings2.PreferredLanguageLocaleName); } MSG msg; @@ -1219,7 +1219,7 @@ HWND InitInstance(HINSTANCE hInstance,LPCWSTR pszCmdLine,int nCmdShow) GetLngString(IDS_MUI_PRINT_PAGENUM, tchPageFmt, COUNTOF(tchPageFmt)); if (!EditPrint(Globals.hwndEdit, pszTitle, tchPageFmt)) { - MsgBoxLng(MBWARN, IDS_MUI_PRINT_ERROR, pszTitle); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_PRINT_ERROR, pszTitle); } } @@ -1915,7 +1915,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) bool const dimOk = (bmp.bmWidth >= (bmp.bmHeight * NUMTOOLBITMAPS)); if (!dimOk) { - MsgBoxLng(MBWARN, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmap, + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmap, (bmp.bmHeight * NUMTOOLBITMAPS), bmp.bmHeight, NUMTOOLBITMAPS); StringCchCopy(s_tchToolbarBitmap, COUNTOF(s_tchToolbarBitmap), L""); DeleteObject(hbmp); @@ -1968,7 +1968,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) bool const dimOk = (bmp.bmWidth >= (bmp.bmHeight * NUMTOOLBITMAPS)); if (!dimOk) { - MsgBoxLng(MBWARN, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmapHot, + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmapHot, (bmp.bmHeight * NUMTOOLBITMAPS), bmp.bmHeight, NUMTOOLBITMAPS); StringCchCopy(s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), L""); DeleteObject(hbmp); @@ -2014,7 +2014,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) bool const dimOk = (bmp.bmWidth >= (bmp.bmHeight * NUMTOOLBITMAPS)); if (!dimOk) { - MsgBoxLng(MBWARN, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmapDisabled, + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmapDisabled, (bmp.bmHeight * NUMTOOLBITMAPS), bmp.bmHeight, NUMTOOLBITMAPS); StringCchCopy(s_tchToolbarBitmapDisabled, COUNTOF(s_tchToolbarBitmapDisabled), L""); DeleteObject(hbmp); @@ -2459,13 +2459,13 @@ LRESULT MsgDropFiles(HWND hwnd, WPARAM wParam, LPARAM lParam) else { #ifndef _EXTRA_DRAG_N_DROP_HANDLER_ // Windows Bug: wParam (HDROP) pointer is corrupted if dropped from 32-bit App - MsgBoxLng(MBWARN, IDS_MUI_DROP_NO_FILE); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_DROP_NO_FILE); #endif // delegated to SCN_URIDROPPED } if (DragQueryFile(hDrop, (UINT)(-1), NULL, 0) > 1) - MsgBoxLng(MBWARN, IDS_MUI_ERR_DROP); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_DROP); DragFinish(hDrop); @@ -2504,7 +2504,7 @@ static DWORD DropFilesProc(CLIPFORMAT cf, HGLOBAL hData, HWND hWnd, DWORD dwKeyS FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false, szBuf); if (DragQueryFile(hDrop, (UINT)(-1), NULL, 0) > 1) - MsgBoxLng(MBWARN, IDS_MUI_ERR_DROP); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_DROP); dwEffect = DROPEFFECT_COPY; } @@ -2702,7 +2702,7 @@ LRESULT MsgChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) if (PathFileExists(Globals.CurrentFile)) { if ((Settings.FileWatchingMode == 2 && !IsSaveNeeded(ISN_GET)) || - MsgBoxLng(MBYESNOWARN,IDS_MUI_FILECHANGENOTIFY) == IDYES) + InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_FILECHANGENOTIFY) == IDYES) { FileRevert(Globals.CurrentFile, Encoding_HasChanged(CPI_GET)); @@ -2715,7 +2715,7 @@ LRESULT MsgChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) } } else { - if (MsgBoxLng(MBYESNOWARN, IDS_MUI_FILECHANGENOTIFY2) == IDYES) { + if (InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_FILECHANGENOTIFY2) == IDYES) { FileSave(true, false, false, false); } } @@ -3267,7 +3267,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_FILE_REVERT: - if (IsSaveNeeded(ISN_GET) && MsgBoxLng(MBYESNO,IDS_MUI_ASK_REVERT) != IDYES) { + if (IsSaveNeeded(ISN_GET) && InfoBoxLng(MB_YESNO | MB_ICONQUESTION, NULL, IDS_MUI_ASK_REVERT) != IDYES) { break; } FileRevert(Globals.CurrentFile, Encoding_HasChanged(CPI_GET)); @@ -3299,11 +3299,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) else dwFileAttributes |= FILE_ATTRIBUTE_READONLY; if (!SetFileAttributes(Globals.CurrentFile,dwFileAttributes)) - MsgBoxLng(MBWARN,IDS_MUI_READONLY_MODIFY,Globals.CurrentFile); + InfoBoxLng(MB_ICONWARNING, NULL,IDS_MUI_READONLY_MODIFY,Globals.CurrentFile); + } + else { + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_READONLY_MODIFY, Globals.CurrentFile); } - else - MsgBoxLng(MBWARN,IDS_MUI_READONLY_MODIFY,Globals.CurrentFile); - dwFileAttributes = GetFileAttributes(Globals.CurrentFile); if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) s_bFileReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY); @@ -3363,7 +3363,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) PostMessage(Globals.hwndMain, WM_CLOSE, 0, 0); } else { - MsgBoxLng(MBWARN, IDS_MUI_ERR_ELEVATED_RIGHTS, NULL); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_ELEVATED_RIGHTS); } } break; @@ -3412,7 +3412,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) GetLngString(IDS_MUI_PRINT_PAGENUM,tchPageFmt,COUNTOF(tchPageFmt)); if (!EditPrint(Globals.hwndEdit,pszTitle,tchPageFmt)) - MsgBoxLng(MBWARN,IDS_MUI_PRINT_ERROR,pszTitle); + InfoBoxLng(MB_ICONWARNING, NULL,IDS_MUI_PRINT_ERROR,pszTitle); } break; @@ -3440,7 +3440,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; if (!PathCreateDeskLnk(Globals.CurrentFile)) - MsgBoxLng(MBWARN,IDS_MUI_ERR_CREATELINK); + InfoBoxLng(MB_ICONWARNING, NULL,IDS_MUI_ERR_CREATELINK); } break; @@ -3563,7 +3563,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { cpi_enc_t iNewEncoding = Encoding_MapUnicode(Encoding_Current(CPI_GET)); - if (IsSaveNeeded(ISN_GET) && MsgBoxLng(MBYESNO, IDS_MUI_ASK_RECODE) != IDYES) { + if (IsSaveNeeded(ISN_GET) && InfoBoxLng(MB_YESNO | MB_ICONQUESTION, NULL, IDS_MUI_ASK_RECODE) != IDYES) { break; } if (RecodeDlg(hwnd,&iNewEncoding)) @@ -3888,7 +3888,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) EditFileIOStatus status = INIT_FILEIO_STATUS; EditIndentationStatistic(Globals.hwndEdit, &status); if (ConsistentIndentationCheck(&status)) { - MsgBoxLng(MBINFO, IDS_MUI_INDENT_CONSISTENT); + InfoBoxLng(MB_ICONINFORMATION, NULL, IDS_MUI_INDENT_CONSISTENT); } } break; @@ -5165,7 +5165,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) IniSetBool(L"Window", tchMaximized, wi.max); IniSetInt(L"Window", tchZoom, wi.zoom); - InfoBoxLng(0, L"MsgStickyWinPos", IDS_MUI_STICKYWINPOS); + InfoBoxLng(MB_OK, L"MsgStickyWinPos", IDS_MUI_STICKYWINPOS); } else { // clear entries @@ -5338,15 +5338,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { if (WritePrivateProfileString(L"Settings", L"WriteTest", L"ok", Globals.IniFile)) { SaveSettings(true); - MsgBoxLng(MBINFO,IDS_MUI_SAVEDSETTINGS); + InfoBoxLng(MB_ICONINFORMATION, NULL, IDS_MUI_SAVEDSETTINGS); } else { Globals.dwLastError = GetLastError(); - MsgBoxLng(MBWARN,IDS_MUI_WRITEINI_FAIL); + InfoBoxLng(MB_ICONWARNING, NULL,IDS_MUI_WRITEINI_FAIL); } } - else - MsgBoxLng(MBWARN,IDS_MUI_CREATEINI_FAIL); + else { + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_CREATEINI_FAIL); + } } break; @@ -5909,7 +5910,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_NEW)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_NEW,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -5917,7 +5918,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_OPEN)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_OPEN,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -5925,7 +5926,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_BROWSE)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_BROWSE,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -5933,14 +5934,14 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd, IDM_FILE_RECENT)) SendMessage(hwnd, WM_COMMAND, MAKELONG(IDM_FILE_RECENT, 1), 0); else - AttentionBeep(0); + SimpleBeep(); break; case IDT_FILE_SAVE: if (IsCmdEnabled(hwnd,IDM_FILE_SAVE)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVE,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -5948,7 +5949,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_EDIT_UNDO)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_UNDO,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -5956,7 +5957,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_EDIT_REDO)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REDO,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -5964,7 +5965,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_EDIT_CUT)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CUT,1),0); else - AttentionBeep(0); + SimpleBeep(); //SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CUTLINE,1),0); break; @@ -5981,7 +5982,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_EDIT_PASTE)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_PASTE,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -5989,7 +5990,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_EDIT_FIND)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -5997,7 +5998,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_EDIT_REPLACE)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6005,7 +6006,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_VIEW_WORDWRAP)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_WORDWRAP,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6013,7 +6014,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_VIEW_ZOOMIN)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_ZOOMIN,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6021,7 +6022,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_VIEW_ZOOMOUT)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_ZOOMOUT,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6029,7 +6030,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd, IDM_VIEW_CHASING_DOCTAIL)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_CHASING_DOCTAIL,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6037,7 +6038,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_VIEW_SCHEME)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEME,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6045,7 +6046,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_VIEW_SCHEMECONFIG)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEMECONFIG,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6058,7 +6059,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_SAVEAS)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVEAS,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6066,7 +6067,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_SAVECOPY)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVECOPY,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6082,7 +6083,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_PRINT)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_PRINT,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6090,7 +6091,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_OPENFAV)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_OPENFAV,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6098,7 +6099,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_ADDTOFAV)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_ADDTOFAV,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6106,7 +6107,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_VIEW_TOGGLEFOLDS)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_TOGGLEFOLDS,1),0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6114,7 +6115,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd, IDM_VIEW_TOGGLE_VIEW)) SendMessage(hwnd, WM_COMMAND, MAKELONG(IDM_VIEW_TOGGLE_VIEW, 1), 0); else - AttentionBeep(0); + SimpleBeep(); break; @@ -6122,7 +6123,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_FILE_LAUNCH)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_LAUNCH,1),0); else - AttentionBeep(0); + SimpleBeep(); break; default: @@ -7519,7 +7520,6 @@ void SaveSettings(bool bSaveSettingsNow) SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, TabIndents); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, TabWidth); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, IndentWidth); - SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, IndentWidth); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, LongLinesLimit); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, BackspaceUnindents); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, WordWrapMode); @@ -9673,7 +9673,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, // Ask to create a new file... if (!bReload && !PathFileExists(szFileName)) { - if (s_flagQuietCreate || MsgBoxLng(MBYESNO,IDS_MUI_ASK_CREATE,szFileName) == IDYES) { + if (s_flagQuietCreate || InfoBoxLng(MB_YESNO | MB_ICONQUESTION, NULL, IDS_MUI_ASK_CREATE, szFileName) == IDYES) { HANDLE hFile = CreateFile(szFileName, GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL); @@ -9794,7 +9794,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, // Show warning: Unicode file loaded as ANSI if (fioStatus.bUnicodeErr) { - MsgBoxLng(MBWARN, IDS_MUI_ERR_UNICODE); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_UNICODE); } // Show inconsistent line endings warning @@ -9827,7 +9827,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, } else if (!(fioStatus.bFileTooBig || fioStatus.bUnknownExt)) { - MsgBoxLng(MBWARN, IDS_MUI_ERR_LOADFILE, szFileName); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_LOADFILE, szFileName); } return(fSuccess); } @@ -10023,7 +10023,7 @@ bool FileSave(bool bSaveAlways, bool bAsk, bool bSaveAs, bool bSaveCopy) else { GetLngString(IDS_MUI_UNTITLED, tch, COUNTOF(tch)); } - switch (MsgBoxLng(MBYESNOCANCEL, IDS_MUI_ASK_SAVE, tch)) { + switch (MessageBoxLng(MB_YESNOCANCEL | MB_ICONINFORMATION, IDS_MUI_ASK_SAVE, tch)) { case IDCANCEL: return false; case IDNO: @@ -10039,7 +10039,7 @@ bool FileSave(bool bSaveAlways, bool bAsk, bool bSaveAs, bool bSaveCopy) s_bFileReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY); if (s_bFileReadOnly) { UpdateToolbar(); - if (MsgBoxLng(MBYESNOWARN, IDS_MUI_READONLY_SAVE, Globals.CurrentFile) == IDYES) { + if (InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_READONLY_SAVE, Globals.CurrentFile) == IDYES) { bSaveAs = true; } else { @@ -10120,7 +10120,7 @@ bool FileSave(bool bSaveAlways, bool bAsk, bool bSaveAs, bool bSaveCopy) { if (!s_bIsElevated && (Globals.dwLastError == ERROR_ACCESS_DENIED)) { - if (IDYES == MsgBoxLng(MBYESNOWARN, IDS_MUI_ERR_ACCESSDENIED, Globals.CurrentFile)) + if (IDYES == InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_ERR_ACCESSDENIED, Globals.CurrentFile)) { if (DoElevatedRelaunch(&fioStatus)) { @@ -10129,13 +10129,13 @@ bool FileSave(bool bSaveAlways, bool bAsk, bool bSaveAs, bool bSaveCopy) else { s_flagAppIsClosing = false; UpdateToolbar(); - MsgBoxLng(MBWARN, IDS_MUI_ERR_SAVEFILE, Globals.CurrentFile); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_SAVEFILE, Globals.CurrentFile); } } } else { UpdateToolbar(); - MsgBoxLng(MBWARN, IDS_MUI_ERR_SAVEFILE, Globals.CurrentFile); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_SAVEFILE, Globals.CurrentFile); } } return fSuccess; @@ -10374,7 +10374,7 @@ bool ActivatePrevInst() return true; } // IsWindowEnabled() - if (IDYES == MsgBoxLng(MBYESNOWARN, IDS_MUI_ERR_PREVWINDISABLED)) { + if (IDYES == InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_ERR_PREVWINDISABLED)) { return false; } return true; @@ -10458,7 +10458,7 @@ bool ActivatePrevInst() return true; } // IsWindowEnabled() - return ((IDYES == MsgBoxLng(MBYESNOWARN, IDS_MUI_ERR_PREVWINDISABLED)) ? false : true); + return ((IDYES == InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_ERR_PREVWINDISABLED)) ? false : true); } return false; } diff --git a/src/Notepad3.vcxproj b/src/Notepad3.vcxproj index 82f576dd4..10cf2c01d 100644 --- a/src/Notepad3.vcxproj +++ b/src/Notepad3.vcxproj @@ -122,7 +122,7 @@ /utf-8 %(AdditionalOptions) - comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;winmm.lib;muiload.lib;dwrite.lib;scintilla.lib;%(AdditionalDependencies) + comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;dwrite.lib;scintilla.lib;%(AdditionalDependencies) Debug Windows MachineX86 @@ -185,7 +185,7 @@ /utf-8 %(AdditionalOptions) - comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;winmm.lib;muiload.lib;dwrite.lib;scintilla.lib;%(AdditionalDependencies) + comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;dwrite.lib;scintilla.lib;%(AdditionalDependencies) Debug Windows MachineX64 @@ -249,7 +249,7 @@ true - comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;winmm.lib;muiload.lib;dwrite.lib;scintilla.lib;%(AdditionalDependencies) + comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;dwrite.lib;scintilla.lib;%(AdditionalDependencies) No .rdata=.text true @@ -316,7 +316,7 @@ true - comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;winmm.lib;muiload.lib;dwrite.lib;scintilla.lib;%(AdditionalDependencies) + comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;dwrite.lib;scintilla.lib;%(AdditionalDependencies) No .rdata=.text true diff --git a/src/Print.cpp b/src/Print.cpp index cdef4ba3c..fb9b88609 100644 --- a/src/Print.cpp +++ b/src/Print.cpp @@ -69,7 +69,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) { // Don't print empty documents if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) { - MsgBoxLng(MBWARN,IDS_MUI_PRINT_EMPTY); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_PRINT_EMPTY); return true; } @@ -498,11 +498,11 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, SendDlgItemMessage(hwnd,1137,CB_SETEXTENDEDUI,true,0); SendDlgItemMessage(hwnd,1138,CB_SETEXTENDEDUI,true,0); } - break; + return true; case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_COMMAND: if (LOWORD(wParam) == IDOK) @@ -519,12 +519,12 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, { PostMessage(hwnd, WM_COMMAND, MAKELONG(1026, 1), 0); } - break; + return true; default: break; } - return 0; + return false; } diff --git a/src/Styles.c b/src/Styles.c index e656be353..5d78c0866 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -658,7 +658,7 @@ bool Style_Export(HWND hwnd) Globals.dwLastError = Style_ExportToFile(szFile, true); if (Globals.dwLastError != ERROR_SUCCESS) { - MsgBoxLng(MBINFO, IDS_MUI_EXPORT_FAIL, szFile); + InfoBoxLng(MB_ICONERROR, NULL, IDS_MUI_EXPORT_FAIL, szFile); } } return (Globals.dwLastError == ERROR_SUCCESS); @@ -673,7 +673,7 @@ DWORD Style_ExportToFile(const WCHAR* szFile, bool bForceAll) { if (StrIsEmpty(szFile)) { - MsgBoxLng(MBWARN, IDS_MUI_SETTINGSNOTSAVED); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SETTINGSNOTSAVED); return false; } @@ -3524,11 +3524,11 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case WM_ACTIVATE: DialogEnableWindow(hwnd, IDC_PREVIEW, ((pCurrentLexer == s_pLexCurrent) || (pCurrentLexer == GetCurrentStdLexer()))); - break; + return true; case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: { @@ -3961,7 +3961,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam if ((!bWarnedNoIniFile && StrIsEmpty(Theme_Files[s_idxSelectedTheme].szFilePath)) && (s_idxSelectedTheme > 0)) { - MsgBoxLng(MBWARN, IDS_MUI_SETTINGSNOTSAVED); + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SETTINGSNOTSAVED); bWarnedNoIniFile = true; } //EndDialog(hwnd,IDOK); @@ -4154,7 +4154,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR case WM_DPICHANGED: UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0); - break; + return true; case WM_DESTROY: diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 2e0bd33aa..28e095b59 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -129,7 +129,6 @@ typedef enum typedef enum { FND_NOP = 0, NXT_NOT_FND, NXT_FND, NXT_WRP_FND, PRV_NOT_FND, PRV_FND, PRV_WRP_FND } FR_STATES; typedef enum { FRMOD_IGNORE = 0, FRMOD_NORM, FRMOD_WRAPED } FR_UPD_MODES; -typedef enum { MBINFO = 0, MBWARN, MBYESNO, MBYESNOWARN, MBYESNOCANCEL, MBOKCANCEL, MBRETRYCANCEL } MBTYPES; //==== Statusbar ==============================================================