2013-03-14 93 views
2

我希望能够在消息框内显示带格式的文本(如粗体文本,项目符号点,斜体等)。mfc - 带有丰富文本的MessageBox

我遇到了this wonderful article,但似乎无法使其工作。我在同一链接上使用演示应用程序。

有人可以帮我吗?我试图调试/理解代码是徒劳的。

限制:(不是我的选择)

  • 必须与Windows XP兼容。
  • 我使用Visual C++ 6

它应该如何显示:

How it is supposed to display


它是如何实际显示:

enter image description here

+1

你的文章是14岁。所以,我认为你应该搜索更现代的,或者使用自定义的conrols库 - 比如BCG Controls Pro。 – eraxillan 2013-03-14 06:39:18

+0

我个人会发现这样一个消息框非常冷漠......真是一个难看的东西!为什么不使用任务对话框?它们比香草消息盒灵活得多,而且看起来不错,没有炫耀。 – 2013-03-14 06:41:22

+0

@Axilles,哈哈真实。我会的,但我的开发环境有限。仅限自由软件(不是我的选择)。 – 2013-03-14 06:41:29

回答

0

我已经解决d由于DavidK非常有帮助的建议,这个问题(请参阅问题的评论)。 FIX for Windows 2000评论固定这个整齐。

3

只需创建一个RichEdit2控制对话框弓...

在InitInstance中,添加follwing电话:

// Init RichEdit Library 

AfxInitRichEdit2(); 

在你的对话框中,创建一个变量RichEdit控件和更新如:

// 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); 

简单地建立自己的信息,你会得到大胆,颜色,...

+0

谢谢你的回答。我想过这个,但是我不太喜欢这样的表现。理想情况下,我希望它看起来像一个普通的消息框,但带有丰富的文本。这绝对是我的后备选择。 – 2013-03-20 09:53:56