richedit2使用

richedit2使用

1)
必须导入dll
HINSTANCE	_hsRichDLL
	_hsRichDLL = NULL;

	//加载富文本dll
	TCHAR tmp[1024] = {0};
	_stprintf(tmp, TEXT("%s\\riched20.dll"), g_pApplication->GetAppPath());
	_hsRichDLL = ::LoadLibraryEx(tmp,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
	if (_hsRichDLL == NULL)
	{
		MessageBox(0, TEXT("riched20.dll加载失败!\n程序即将退出!"), TEXT("错误"), 0);
		g_pApplication->ExitApp();
	}


2)
参数设置
Multiline:true 多行
No Hide Selection
Vertical scroll :true 垂直滚动,仅对多行编辑控件有效

3)
在末尾追加行
HWND hRichEdTradesMsg = GetDlgItem(this->GetHWND(), IDC_RICHEDIT_TRADE);
	::SendMessage(hRichEdTradesMsg, EM_SETSEL, -1, -1);
	::SendMessage(hRichEdTradesMsg, EM_REPLACESEL, 0, (LPARAM)cText);
	::SendMessage(hRichEdTradesMsg, EM_REPLACESEL, 0, (LPARAM)TEXT("\r\n"));

你可能感兴趣的:(it)