Fix bug #1080, Unicode stubs must use RichEdit20W, otherwise EM_GETTEXTRANGE gives us ANSI strings

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6410 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2013-08-15 23:14:12 +00:00
parent 51e2b07f05
commit 5744372364
3 changed files with 28 additions and 10 deletions

View file

@ -20,6 +20,8 @@ Released on ?
\b Fixed !define Unicode null terminator bug (\W{http://sf.net/p/nsis/bugs/1079/}{bug #1079})
\b Unicode stubs create WCHAR richedit controls (\W{http://sf.net/p/nsis/bugs/1080/}{bug #1080})
\b Fixed MakeNSISW default pushbutton and tab order
\H{v3.0a1} 3.0 Alpha 1

View file

@ -385,18 +385,22 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
{ // load richedit DLL
static const TCHAR riched20[]=_T("RichEd20");
static const TCHAR riched32[]=_T("RichEd32");
static const TCHAR richedit20a[]=_T("RichEdit20A");
#ifdef UNICODE
static const TCHAR richedit20t[]=_T("RichEdit20W");
#else
static const TCHAR richedit20t[]=_T("RichEdit20A");
#endif
static const TCHAR richedit[]=_T("RichEdit");
if (!LoadLibrary(riched20))
{
LoadLibrary(riched32);
LoadLibrary(riched32); // Win95 only ships with v1.0, NT4 has v2.0: web.archive.org/web/20030607222419/http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/aboutricheditcontrols.asp
}
// make richedit20a point to RICHEDIT
if (!GetClassInfo(NULL,richedit20a,&wc))
// make richedit20a/w point to RICHEDIT
if (!GetClassInfo(NULL,richedit20t,&wc))
{
GetClassInfo(NULL,richedit,&wc);
wc.lpszClassName = richedit20a;
wc.lpszClassName = richedit20t;
RegisterClass(&wc);
}
}
@ -797,7 +801,7 @@ static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
},
ps_tmpbuf
};
if (tr.chrg.cpMax-tr.chrg.cpMin < sizeof(ps_tmpbuf)) {
if (tr.chrg.cpMax-tr.chrg.cpMin < COUNTOF(ps_tmpbuf)) {
SendMessage(hwLicense,EM_GETTEXTRANGE,0,(LPARAM)&tr);
SetCursor(LoadCursor(0, IDC_WAIT));
ShellExecute(hwndDlg,_T("open"),tr.lpstrText,NULL,NULL,SW_SHOWNORMAL);

View file

@ -9,6 +9,12 @@
//
#include "afxres.h"
#include "config.h"
#undef RICHEDIT_CLASS
#ifdef UNICODE
#define RICHEDIT_CLASS "RichEdit20W"
#else
#define RICHEDIT_CLASS "RichEdit20A"
#endif
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@ -37,7 +43,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDI_ICON2,IDC_ULICON,0,0,22,20
LTEXT "",IDC_INTROTEXT,25,0,241,23
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
WS_TABSTOP | 0x804,0,24,266,105
END
#endif
@ -53,7 +59,7 @@ FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_ICON2,1031,0,0,22,20
LTEXT "",IDC_INTROTEXT,25,0,241,23
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
WS_TABSTOP | 0x804,0,24,266,85
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTORADIOBUTTON |
WS_TABSTOP,0,110,266,9
@ -73,7 +79,7 @@ FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_ICON2,1031,0,0,22,20
LTEXT "",IDC_INTROTEXT,25,0,241,23
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
WS_TABSTOP | 0x804,0,24,266,95
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,0,120,266,9
@ -244,7 +250,13 @@ END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"#include ""config.h""\0"
"#include ""config.h""\r\n"
"#undef RICHEDIT_CLASS\r\n"
"#ifdef UNICODE\r\n"
"#define RICHEDIT_CLASS ""RichEdit20W""\r\n"
"#else\r\n"
"#define RICHEDIT_CLASS ""RichEdit20A""\r\n"
"#endif\0"
END
3 TEXTINCLUDE DISCARDABLE