分类: C/C++
2012-01-27 01:41:17
1 2 3 4 | {\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fcharset134 \'cb\'ce\'cc\'e5;}} {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang2052\f0\fs22 Hello World\par } |
01 02 03 04 05 06 07 08 09 10 11 | void CTest_RicheditView::OnInitialUpdate() { CRichEditView::OnInitialUpdate(); SetMargins(CRect(720, 720, 720, 720)); CStringA rtfStr = "{\\rtf1\\ansi\\ansicpg936\\deff0\\deflang1033\\deflangfe2052{\\fonttbl{\\f0\\fnil\\fcharset134 \\'cb\\'ce\\'cc\\'e5;}}{\\*\\generator Msftedit 5.41.21.2509;}\\viewkind4\\uc1\\pard\\sa200\\sl276\\slmult1\\lang2052\\f0\\fs22 Hello World\\par}"; SETTEXTEX st; st.codepage = 1200; st.flags = ST_SELECTION | ST_KEEPUNDO; SendMessage(EM_SETTEXTEX, (WPARAM)&st, (LPARAM)(LPCSTR)rtfStr); } |
1 | CStringA rtfStr = "{\\rtf1\\ansi\\ansicpg936\\deff0\\deflang1033\\deflangfe2052{\\fonttbl{\\f0\\fnil\\fcharset134 \\'cb\\'ce\\'cc\\'e5;}}{\\*\\generator Msftedit 5.41.21.2509;}\\viewkind4\\uc1\\trowd\\cellx2000\\cellx4000\\intbl\\cell\\cell\\row\\trowd\\cellx2000\\cellx4000\\intbl\\cell\\cell\\row\\par}"; |
对于表格的各种设置,包括:外框宽度、边距等等,请参考RTF规范文档进行设置。
注意:对于默认的RichEdit20W只支持简单的表,而且在单元格内回车不换行,而RichEdit50W(即Version4.1)可以支持多级表,并且单元格内回车换行。以上的文章内容是基于RichEdit50W的,关于切换到RichEdit50W的介绍,请看《VC2008下CRichEditView加载RichEdit4.1版本》。