mfc - MessageBox with rich text

孤人 提交于 2019-12-06 10:30:45
TGMDev

Simply create a dialog bow with a RichEdit2 control...

In InitInstance, add the follwing call:

// Init RichEdit Library

AfxInitRichEdit2();

In your dialog box, create a variable to the RichEdit control and update it as:

// Turn Word Wrap on (based on window width)

m_RichEditMsg.SetTargetDevice( NULL, 0);

// Set Base Text

strText = "{\\rtf1\\ansi\\fs20 ";
strText += "{\\colortbl;\\red0\\green0\\blue0;\\red0\\green0\\blue255;\\red0\\green255\\blue255;\\red0\\green255\\blue0;\\red255\\green0\\blue0;}";
    strText += "{\\f1\\cb1\\cf2\\b Main Title} \\par\\par \\fs18 Other text to add {\\b In Bold} no more in bolb ... \\par";
str.Format( "\\par Id: {\\b %s}", m_strProgId);
strText += str;
strText+= "\\par \\par {\\f1 \\b Please Confirm ...} \\par}";

// Update Controls

m_RichEditMsg.SetWindowText( strText);

Simply build your own message and you get bold, color, ...

I have solved this problem thanks to the very helpful suggestions of DavidK (see comments on the question). The FIX for Windows 2000 comment fixed this neatly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!