c++ - Add formatting to Richtext box -
i have rich edit control , want add formatted text in doesn't work:
const char* str="{\rtf1\ansi{\fonttbl\f0\fswiss helvetica;}\f0\pard\ {\b bold} text.\par\ }"; loadlibrary("riched32.dll"); hwnd hedit= createwindowex(ws_ex_clientedge, richedit_class, str, ws_child | ws_visible | ws_vscroll | es_multiline | es_autovscroll | es_readonly, 0, 0, 100, 100, hwnd, (hmenu) idc_main_edit, getmodulehandle(null), null);
i know can add formatting using paraformat
, charformat
, sending message control this:
paraformat pf; charformat cf; memset( &cf, 0, sizeof cf ); cf.cbsize = sizeof cf; cf.dwmask = cfm_bold; cf.dweffects = cfe_bold; sendmessage( hedit, em_setcharformat, scf_selection, (lparam) &cf); sendmessage( hedit, em_replacesel, false, (lparam) "bold ");
but how can make first 1 work or if there no way, there simpler method second? in advance.
rich edit controls won't accept rtf in way you're trying in first code block. rtf control need use es_streamin message.
Comments
Post a Comment