我在对话框上有一个richedit控件。我想用字符串填充richedit控件。richedit控件本身显示正确。但是我不知道如何用字符串填充richedit控件。我在下面的resource.rc代码中进行了猜测。
在main.cpp中,我有:
case IDC_BUT_ABOUT:
{
HINSTANCE hRichEdit;
hRichEdit = LoadLibrary("RICHED32.DLL");
DialogBox( hInst, MAKEINTRESOURCE(IDD_ABOUT), hDlgWnd,(DLGPROC)InitAbout );
//ShowWindow(hDlgWnd, SW_SHOWNORMAL);
return TRUE;
}
break;
在resource.rc中,我有:
IDD_ABOUT DIALOGEX 0, 0, 206, 136
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Close",IDCANCEL,77,115,50,14
CONTROL "",IDC_RICHEDIT21,"RichEdit20W",ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_TABSTOP,36,53,130,46
END
string rt = "{rtf1ansiansicpg1252deff0deflang1033{fonttbl{f0fswissfcharset0 Arial;}{f1fnilfprq2fcharset0 Biondi;}}{colortbl ;red255green0blue0;}viewkind4uc1pardf0fs20parcf1f1 hellocf0f0 ul some text herepar}";
this.IDC_RICHEDIT21.Rtf = rt;
但这显然还不接近于我应该如何将字符串中的文本放入富编辑控件?
尝试EM_SETTEXTEX或EM_STREAMIN。