From ad148d89cc15341f29fe94ace7cea8a2b5d11210 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 6 Nov 2018 11:05:26 +0100 Subject: [PATCH 1/3] + chg: switch to RichText Edit Control v5.0 (MSFTEDIT.DLL) --- language/common_res.h | 2 + language/np3_af_za/dialogs_af_za.rc | Bin 75412 -> 75426 bytes language/np3_be_by/dialogs_be_by.rc | Bin 75210 -> 75224 bytes language/np3_de_de/dialogs_de_de.rc | Bin 76630 -> 76644 bytes language/np3_en_gb/dialogs_en_gb.rc | Bin 75438 -> 75452 bytes language/np3_en_us/dialogs_en_us.rc | Bin 75280 -> 75294 bytes language/np3_es_es/dialogs_es_es.rc | Bin 77514 -> 77528 bytes language/np3_fr_fr/dialogs_fr_fr.rc | Bin 76842 -> 76856 bytes language/np3_ja_jp/dialogs_ja_jp.rc | Bin 72334 -> 72348 bytes language/np3_nl_nl/dialogs_nl_nl.rc | Bin 76686 -> 76700 bytes language/np3_ru_ru/dialogs_ru_ru.rc | Bin 75188 -> 75202 bytes language/np3_zh_cn/dialogs_zh_cn.rc | Bin 70438 -> 70452 bytes src/Dialogs.c | 158 ++++++++++++++++++---------- src/Notepad3.c | 12 ++- 14 files changed, 111 insertions(+), 61 deletions(-) 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 fb3846f58316f990c43c3d388e9ccd8dab9f9617..12fb3305a9b152aa7bf21624b1bec503138a1621 100644 GIT binary patch delta 58 zcmbPomSxddmJL~g>Ol;i49*N546Y0=KvoDtJdo$l;0I&{0cjr~KMW`r)Z8q%y;+b^ GP!s^6N({^Z delta 44 ycmZ2gfr3@JcX34;-X0Yf;0Qu9Q??GptV1w{c91PaRl diff --git a/language/np3_be_by/dialogs_be_by.rc b/language/np3_be_by/dialogs_be_by.rc index da0c0aed46598491306f9339639ff1a2f434172a..ee87de578f6269087cb249ef7d541b106285f4a7 100644 GIT binary patch delta 58 zcmX?gn&rl6mJQnk)Pop28JrnB7+e`#fUFRPcp%T8!4Jp^0@6M}ei%?LsQJ9W_VWUa GzeNDd*be>x delta 48 zcmca{n&s4KmJQnkq?H(g7%~}>88R4L8B&0(5(Xm%1BP%0B?g_z7uyt@1h)w?-Vgx* DVRa2z diff --git a/language/np3_de_de/dialogs_de_de.rc b/language/np3_de_de/dialogs_de_de.rc index eace6a0c4ab336980cd5a7c4cae518de6886a551..2471ab08e182b95b27b34568d8ba3e6d5fdddf48 100644 GIT binary patch delta 64 zcmcb1jpfNTmJKgfr3@JcX34;-X0Yf;05`)g<{w~GlZGzjk2{Nve F1OR)}4oLt2 diff --git a/language/np3_en_gb/dialogs_en_gb.rc b/language/np3_en_gb/dialogs_en_gb.rc index 73566709ac18cbdd0c76f61ffed180fe7bcac96a..e8eadf2852106d96ba115657ac14079e831f47ad 100644 GIT binary patch delta 58 zcmZ2?mSxXbmJL;c>Ol;i49*N546Y0=KvoDtJdo$l;0I&{0cjr~KMW`r)I3>m`(!~z GX;A>M*bO=W delta 44 ycmdmUmSx>pmJL;cl1dCg44Dkc3>gfr3@JcX34;-X0Yf;0Qu9K=?F$7Nr9}ZA+6y@V diff --git a/language/np3_en_us/dialogs_en_us.rc b/language/np3_en_us/dialogs_en_us.rc index d20f057786e1a4a3e2c2d27c0cd63def26479efa..f48f993d7b16798717301932b0be6ef156d43698 100644 GIT binary patch delta 58 zcmbPmhGpIvmJJnx>Ol;i49*N546Y0=KvoDtJdo$l;0I&{0cjr~KMW`r)I3pe`$R#; GdJzDlat&Dk delta 44 ycmbPthGoJTmJJnxl1dCg44Dkc3>gfr3@JcX34;-X0Yf;0QuBPl?ehg0>qP(*^b1%3 diff --git a/language/np3_es_es/dialogs_es_es.rc b/language/np3_es_es/dialogs_es_es.rc index 995f3960ba4765d24d92d388749863b686fca5bf..4ffdec8f96bcc298379da06305f846628724e3c8 100644 GIT binary patch delta 58 zcmX?gm*vJ?mJOQ()q@y38JrnB7+e`#fUFRPcp%T8!4Jp^0@6M}ei%?LsQI+u_S1rl G|78Hv^A9Be delta 44 zcmca{m*v!5mJOQ(C6yS07%~}>88R4L8B&0(5(Xm%1BP%0rRJN0+iwao{+9s&Iu#8h diff --git a/language/np3_fr_fr/dialogs_fr_fr.rc b/language/np3_fr_fr/dialogs_fr_fr.rc index add0429be93d194076975b8b201485ace62873f6..7a8e6d97082af2c0a5cb49af21034b8e755da3f7 100644 GIT binary patch delta 58 zcmZ2=gJs7JmJJPp>Ol;i49*N546Y0=KvoDtJdo$l;0I&{0cjr~KMW`r)I3vg`%FQ` GiBbTzN)6Qj delta 44 zcmdmSgJsnXmJJPpl1dCg44Dkc3>gfr3@JcX34;-X0Yf;0QuA`b?aKujCrSYTBQy)t diff --git a/language/np3_ja_jp/dialogs_ja_jp.rc b/language/np3_ja_jp/dialogs_ja_jp.rc index 1c11c7f3668f40ec28c79d0b7098255b7c6ea9b8..52c199c008f67ea0cfc172f262db011e2e3e5632 100644 GIT binary patch delta 58 zcmeC%$}(pw%Z4yP^&kdM24@Bj23H0bAS;9+9?0`&@B^}ffV2;g9|n{QYR(tjo-fEK G&j|pJObk{4 delta 44 ycmbQUm8EYh%Z4yPNhO9LhD?TJh71N*h7=&Hgu#fxfFYbgskv5gd#xa&JSPAJW(rjR diff --git a/language/np3_nl_nl/dialogs_nl_nl.rc b/language/np3_nl_nl/dialogs_nl_nl.rc index 18507f6f2e4ec37217b9402d4764cdb76bbe27e2..0657fc4b7512728421591736d10b0ea1112bc0f1 100644 GIT binary patch delta 58 zcmeCX&NAmZ%Z3O+^&kdM24@Bj23H0bAS;9+9?0`&@B^}ffV2;g9|n{QYAzJqUMR>Y GD+K_amkh4} delta 44 ycmbPpou%(O%Z3O+NhO9LhD?TJh71N*h7=&Hgu#fxfFYbgskvTod%Yl|tP}tc-3qP% diff --git a/language/np3_ru_ru/dialogs_ru_ru.rc b/language/np3_ru_ru/dialogs_ru_ru.rc index 11f3244b2e7bfe54d70ed919e35d0ffe16815639..ee25b04c1c226dda026317c5a52e0c3eb4ed470a 100644 GIT binary patch delta 58 zcmdmTn&r@GmJKTe)Pop28JrnB7+e`#fUFRPcp%T8!4Jp^0@6M}ei%?LsQIA4_Jab9 GpG5$_k`AB% delta 44 zcmX?fnq|vrmJKTeB$XI~7%~}>88R4L8B&0(5(Xm%1BP%0rRMVj+s_Lyeii`$Dy|Hl diff --git a/language/np3_zh_cn/dialogs_zh_cn.rc b/language/np3_zh_cn/dialogs_zh_cn.rc index 399ef1538fd60e5ae6f2acc15ba096cb09e31129..243f5c96b05e53f31500647a947c678a5c9393d2 100644 GIT binary patch delta 58 zcmZ3sjAhF*mJKrm)Pop28JrnB7+e`#fUFRPcp%T8!4Jp^0@6M}ei%?LsClEn_KgCJ GrAz>%OAUGe delta 44 zcmdn8jAhv}mJKrmB$XI~7%~}>88R4L8B&0(5(Xm%1BP%0rRMzt+xH7FmNEeV726AW diff --git a/src/Dialogs.c b/src/Dialogs.c index 1d5befb21..67223e688 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -50,7 +50,6 @@ #include "Dialogs.h" - //============================================================================= // // MsgBoxLng() @@ -383,6 +382,7 @@ 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 +391,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 +410,36 @@ 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 //============================================================================= // @@ -494,64 +520,84 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETEVENTMASK, 0, (LPARAM)(ENM_LINK)); // link click #if true + static char pAboutResource[8192] = { '\0' }; + static char* pAboutInfo = NULL; + + if (pAboutInfo == NULL) + { + char pAboutRes[4000]; + GetLngStringA(IDS_MUI_ABOUT_RTF_1, pAboutRes, COUNTOF(pAboutRes)); + StringCchCopyA(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); - char pAboutRes[4000]; - GetLngStringA(IDS_MUI_ABOUT_RTF_1, pAboutRes, COUNTOF(pAboutRes)); - StringCchCopyA(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); - - - + 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; + + if (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); From dae03cf75d766f04e7c04a014b37ca50e5601b4d Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 6 Nov 2018 11:14:24 +0100 Subject: [PATCH 2/3] + fix: static text for About box must be reconstructed after module unload --- src/Dialogs.c | 107 +++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/src/Dialogs.c b/src/Dialogs.c index 67223e688..ed4b5ee01 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -383,6 +383,7 @@ static DWORD _LoadStringEx(UINT nResId, LPCTSTR pszRsType, LPSTR strOut) // _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 @@ -439,6 +440,7 @@ static DWORD CALLBACK _LoadRtfCallbackW( return 0; } // ---------------------------------------------------------------------------- + #endif //============================================================================= @@ -520,37 +522,36 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETEVENTMASK, 0, (LPARAM)(ENM_LINK)); // link click #if true + static char pAboutResource[8192] = { '\0' }; static char* pAboutInfo = NULL; - - if (pAboutInfo == NULL) - { - char pAboutRes[4000]; - GetLngStringA(IDS_MUI_ABOUT_RTF_1, pAboutRes, COUNTOF(pAboutRes)); - StringCchCopyA(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); - pAboutInfo = pAboutResource; - } + char pAboutRes[4000]; + GetLngStringA(IDS_MUI_ABOUT_RTF_1, pAboutRes, COUNTOF(pAboutRes)); + StringCchCopyA(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); + + pAboutInfo = pAboutResource; + EDITSTREAM editStreamIn = { (DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallback }; SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, SF_RTF, (LPARAM)&editStreamIn); @@ -559,33 +560,31 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam static WCHAR pAboutResource[8192] = { L'\0' }; static PWCHAR pAboutInfo = NULL; - if (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); + 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; - } + pAboutInfo = pAboutResource; EDITSTREAM editStreamIn = { (DWORD_PTR)&pAboutInfo, 0, _LoadRtfCallbackW }; SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_STREAMIN, (WPARAM)(UINT)(SF_TEXT | SF_UNICODE), (LPARAM)&editStreamIn); From 0119158fd0986d9a4f94228cd57276823836ad29 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 6 Nov 2018 11:38:42 +0100 Subject: [PATCH 3/3] + fix: increase waiting timeout for GUI tests --- test/TestAhkNotepad3.ahk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) {