Merge pull request #779 from RaiKoHoff/Dev_RC2_fixes

Switch to RichText Edit Control v.5.0 (msftedit.dll) for AboutBox text
This commit is contained in:
Rainer Kottenhoff 2018-11-06 11:46:32 +01:00 committed by GitHub
commit 731a633ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 89 additions and 40 deletions

View File

@ -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_

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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;

View File

@ -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);

View File

@ -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)
{