mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+ chg: switch to RichText Edit Control v5.0 (MSFTEDIT.DLL)
This commit is contained in:
parent
2044c922a9
commit
ad148d89cc
@ -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.
158
src/Dialogs.c
158
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;
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user