diff --git a/language/common_res.h b/language/common_res.h index 5a7fc3dd8..497ee971c 100644 --- a/language/common_res.h +++ b/language/common_res.h @@ -943,4 +943,6 @@ #define IDS_LEX_STR_63352 63352 #define IDS_LEX_STR_63353 63353 +#define RICHEDIT_CONTROL_VER "RichEdit50W" // RICHEDIT_CONTROL_VER + #endif //_COMMON_RES_H_ diff --git a/language/np3_af_za/dialogs_af_za.rc b/language/np3_af_za/dialogs_af_za.rc index fb3846f58..12fb3305a 100644 Binary files a/language/np3_af_za/dialogs_af_za.rc and b/language/np3_af_za/dialogs_af_za.rc differ diff --git a/language/np3_be_by/dialogs_be_by.rc b/language/np3_be_by/dialogs_be_by.rc index da0c0aed4..ee87de578 100644 Binary files a/language/np3_be_by/dialogs_be_by.rc and b/language/np3_be_by/dialogs_be_by.rc differ diff --git a/language/np3_de_de/dialogs_de_de.rc b/language/np3_de_de/dialogs_de_de.rc index eace6a0c4..2471ab08e 100644 Binary files a/language/np3_de_de/dialogs_de_de.rc and b/language/np3_de_de/dialogs_de_de.rc differ diff --git a/language/np3_en_gb/dialogs_en_gb.rc b/language/np3_en_gb/dialogs_en_gb.rc index 73566709a..e8eadf285 100644 Binary files a/language/np3_en_gb/dialogs_en_gb.rc and b/language/np3_en_gb/dialogs_en_gb.rc differ diff --git a/language/np3_en_us/dialogs_en_us.rc b/language/np3_en_us/dialogs_en_us.rc index d20f05778..f48f993d7 100644 Binary files a/language/np3_en_us/dialogs_en_us.rc and b/language/np3_en_us/dialogs_en_us.rc differ diff --git a/language/np3_es_es/dialogs_es_es.rc b/language/np3_es_es/dialogs_es_es.rc index 995f3960b..4ffdec8f9 100644 Binary files a/language/np3_es_es/dialogs_es_es.rc and b/language/np3_es_es/dialogs_es_es.rc differ diff --git a/language/np3_fr_fr/dialogs_fr_fr.rc b/language/np3_fr_fr/dialogs_fr_fr.rc index add0429be..7a8e6d970 100644 Binary files a/language/np3_fr_fr/dialogs_fr_fr.rc and b/language/np3_fr_fr/dialogs_fr_fr.rc differ diff --git a/language/np3_ja_jp/dialogs_ja_jp.rc b/language/np3_ja_jp/dialogs_ja_jp.rc index 1c11c7f36..52c199c00 100644 Binary files a/language/np3_ja_jp/dialogs_ja_jp.rc and b/language/np3_ja_jp/dialogs_ja_jp.rc differ diff --git a/language/np3_nl_nl/dialogs_nl_nl.rc b/language/np3_nl_nl/dialogs_nl_nl.rc index 18507f6f2..0657fc4b7 100644 Binary files a/language/np3_nl_nl/dialogs_nl_nl.rc and b/language/np3_nl_nl/dialogs_nl_nl.rc differ diff --git a/language/np3_ru_ru/dialogs_ru_ru.rc b/language/np3_ru_ru/dialogs_ru_ru.rc index 11f3244b2..ee25b04c1 100644 Binary files a/language/np3_ru_ru/dialogs_ru_ru.rc and b/language/np3_ru_ru/dialogs_ru_ru.rc differ diff --git a/language/np3_zh_cn/dialogs_zh_cn.rc b/language/np3_zh_cn/dialogs_zh_cn.rc index 399ef1538..243f5c96b 100644 Binary files a/language/np3_zh_cn/dialogs_zh_cn.rc and b/language/np3_zh_cn/dialogs_zh_cn.rc differ diff --git a/src/Dialogs.c b/src/Dialogs.c index 1d5befb21..ed4b5ee01 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -50,7 +50,6 @@ #include "Dialogs.h" - //============================================================================= // // MsgBoxLng() @@ -383,6 +382,8 @@ static DWORD _LoadStringEx(UINT nResId, LPCTSTR pszRsType, LPSTR strOut) // (EditStreamCallback) // _LoadRtfCallback() RTF edit control StreamIn's callback function // +#if true + static DWORD CALLBACK _LoadRtfCallback( DWORD_PTR dwCookie, // (in) pointer to the string LPBYTE pbBuff, // (in) pointer to the destination buffer @@ -391,7 +392,7 @@ static DWORD CALLBACK _LoadRtfCallback( ) { LPSTR* pstr = (LPSTR*)dwCookie; - LONG len = (LONG)StringCchLenA(*pstr,0); + LONG const len = (LONG)StringCchLenA(*pstr,0); if (len < cb) { @@ -410,10 +411,37 @@ static DWORD CALLBACK _LoadRtfCallback( } // ---------------------------------------------------------------------------- +#else -static char pAboutResource[8192] = { '\0' }; -static char* pAboutInfo; +static DWORD CALLBACK _LoadRtfCallbackW( + 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 +) +{ + LPWSTR* pstr = (LPWSTR*)dwCookie; + LONG const len = (LONG)StringCchLen(*pstr, 0); + LONG const size = len * sizeof(WCHAR); + cb -= (cb % sizeof(WCHAR)); + + if (size < cb) { + *pcb = size; + memcpy(pbBuff, (LPCWSTR)*pstr, *pcb); + *pstr += len; + //*pstr = '\0'; + } + else { + *pcb = cb; + memcpy(pbBuff, (LPCWSTR)*pstr, *pcb); + *pstr += (cb / sizeof(WCHAR)); + } + return 0; +} +// ---------------------------------------------------------------------------- + +#endif //============================================================================= // @@ -495,6 +523,9 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam #if true + static char pAboutResource[8192] = { '\0' }; + static char* pAboutInfo = NULL; + char pAboutRes[4000]; GetLngStringA(IDS_MUI_ABOUT_RTF_1, pAboutRes, COUNTOF(pAboutRes)); StringCchCopyA(pAboutResource, COUNTOF(pAboutResource), pAboutRes); @@ -519,39 +550,53 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam GetLngStringA(IDS_MUI_ABOUT_RTF_6, pAboutRes, COUNTOF(pAboutRes)); StringCchCatA(pAboutResource, COUNTOF(pAboutResource), pAboutRes); - + pAboutInfo = pAboutResource; EDITSTREAM editStreamIn = { (DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallback }; - pAboutInfo = pAboutResource; SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn); - - //DWORD dwSize = _LoadStringEx(IDR_ABOUTINFO_RTF, L"RTF", NULL); - //if (dwSize != 0) { - // char* pchBuffer = AllocMem(dwSize + 1, HEAP_ZERO_MEMORY); - // pAboutInfo = pchBuffer; - // _LoadStringEx(IDR_ABOUTINFO_RTF, L"RTF", pAboutInfo); - // SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn); - // FreeMem(pchBuffer); - //} - //else { - // pAboutInfo = chErrMsg; - // SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn); - //} - #else - PARAFORMAT2 pf2; - ZeroMemory(&pf2, sizeof(PARAFORMAT2)); - pf2.cbSize = (UINT)sizeof(PARAFORMAT2); - pf2.dwMask = (PFM_SPACEBEFORE | PFM_SPACEAFTER | PFM_LINESPACING); - pf2.dySpaceBefore = 48; // paragraph - pf2.dySpaceAfter = 48; // paragraph - pf2.dyLineSpacing = 24; // [twips] - pf2.bLineSpacingRule = 5; // 5: dyLineSpacing/20 is the spacing, in lines, from one line to the next. - SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETPARAFORMAT, 0, (LPARAM)&pf2); - SetDlgItemText(hwnd, IDC_RICHEDITABOUT, ABOUT_INFO_PLAIN); - #endif + static WCHAR pAboutResource[8192] = { L'\0' }; + static PWCHAR pAboutInfo = NULL; + + WCHAR pAboutRes[4000]; + GetLngString(IDS_MUI_ABOUT_RTF_1, pAboutRes, COUNTOF(pAboutRes)); + StringCchCopy(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_CONTRIBS, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_RTF_2, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_LIBS, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_RTF_3, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_ACKNOWLEDGES, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_RTF_4, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_MORE, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_RTF_5, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_LICENSES, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + GetLngString(IDS_MUI_ABOUT_RTF_6, pAboutRes, COUNTOF(pAboutRes)); + StringCchCat(pAboutResource, COUNTOF(pAboutResource), pAboutRes); + + pAboutInfo = pAboutResource; + + EDITSTREAM editStreamIn = { (DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallbackW }; + SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, (WPARAM)(UINT)(SF_TEXT | SF_UNICODE), (LPARAM)&editStreamIn); + + // EM_SETTEXTEX is Richedit 3.0 only + //SETTEXTEX ste; + //ste.flags = ST_SELECTION; // replace everything + //ste.codepage = 1200; // Unicode is codepage 1200 + //SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)pAboutInfo); + + #endif + CenterDlgInParent(hwnd); } return true; diff --git a/src/Notepad3.c b/src/Notepad3.c index 0e5ab1b2c..ca6673aa1 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -126,7 +126,6 @@ static WCHAR* const _s_RecentReplace = L"Recent Replace"; static WCHAR s_tchLastSaveCopyDir[MAX_PATH + 1] = { L'\0' }; static bool s_bExternalBitmap = false; -static HMODULE s_hRichEdit = NULL; static bool s_bRunningWatch = false; static bool s_bFileReadOnly = false; @@ -159,6 +158,7 @@ static int s_iExprError = -1; static WIN32_FIND_DATA s_fdCurFile; +static HMODULE s_hRichEdit = INVALID_HANDLE_VALUE; // Globals <= @@@ bool g_bWordWrapG; @@ -495,6 +495,7 @@ static void _CleanUpResources(const HWND hwnd, bool bIsInitialized) if (s_hRichEdit) { FreeLibrary(s_hRichEdit); + s_hRichEdit = INVALID_HANDLE_VALUE; } if (bIsInitialized) { @@ -645,12 +646,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, } // ---------------------------------------------------- + if (s_hRichEdit == INVALID_HANDLE_VALUE) { + //s_hRichEdit = LoadLibrary(L"RICHED20.DLL"); // Use RICHEDIT_CONTROL_VER for control in common_res.h + s_hRichEdit = LoadLibrary(L"MSFTEDIT.DLL"); // Use "RichEdit50W" for control in common_res.h + } s_msgTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated"); - s_hRichEdit = LoadLibrary(L"RICHED20.DLL"); // Use "RichEdit20W" for control in .rc - //s_hRichEdit = LoadLibrary(L"MSFTEDIT.DLL"); // Use "RichEdit50W" for control in .rc - if (!Globals.hDlgIcon) { Globals.hDlgIcon = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); @@ -2768,7 +2770,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) EnableCmd(hmenu,IDM_EDIT_ESCAPECCHARS,!s && !ro); EnableCmd(hmenu,IDM_EDIT_UNESCAPECCHARS,!s && !ro); - EnableCmd(hmenu,IDM_EDIT_CHAR2HEX, !ro); // Char2Hex allowed for char after curr pos + EnableCmd(hmenu,IDM_EDIT_CHAR2HEX, !ro); // Char2Hex allowed for char after current pos EnableCmd(hmenu,IDM_EDIT_HEX2CHAR, !s && !ro); //EnableCmd(hmenu,IDM_EDIT_INCREASENUM,!s && !ro); diff --git a/test/TestAhkNotepad3.ahk b/test/TestAhkNotepad3.ahk index 2703b30f6..715d3b540 100644 --- a/test/TestAhkNotepad3.ahk +++ b/test/TestAhkNotepad3.ahk @@ -45,7 +45,7 @@ Goto LABEL_END ; ============================================================================= CHECK_NP3_STARTS: ; check that NP3 starts up -WinWait ahk_pid %v_Notepad3_PID%, , 3 +WinWait ahk_pid %v_Notepad3_PID%, , 10 v_ErrLevel = %ErrorLevel% if (v_ErrLevel != 0) { @@ -91,7 +91,7 @@ WinActivate, ahk_pid %v_Notepad3_PID% ; This will select File->Open in Notepad: WinMenuSelectItem, ahk_pid %v_Notepad3_PID%, , Help, About... -WinWait, About %v_NP3Name%, , 1 +WinWait, About %v_NP3Name%, , 3 v_ErrLevel = %ErrorLevel% if (v_ErrLevel != 0) { @@ -103,7 +103,7 @@ WinActivate ; About Box ;ControlFocus, OK, About %v_NP3Name% ControlClick, OK, About %v_NP3Name% ;Send {Enter} -WinWaitClose, About %v_NP3Name%, , 1 +WinWaitClose, About %v_NP3Name%, , 2 v_ErrLevel = %ErrorLevel% if (v_ErrLevel != 0) { @@ -116,7 +116,7 @@ Return ; ============================================================================= LABEL_END: -WinClose ahk_pid %v_Notepad3_PID%, , 1 +WinClose ahk_pid %v_Notepad3_PID%, , 2 v_ErrLevel = %ErrorLevel% if (v_ErrLevel != 0) {