I want to be able to display formatted text inside a message box (like bold text, bullet points, italics, etc.).

I came across this wonderful article but can't seem to get it to work. I am using the demo application at that same link.

Can someone please help me out? I have tried debugging/understanding that code in vain.

Constraints: (not my choice)

  • Has to be compatible with Windows XP.
  • I'm using Visual C++ 6.

How it is supposed to display:

How it is supposed to display


How it actually displays:

enter image description here

有帮助吗?

解决方案 2

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.

其他提示

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, ...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top