MFC在编辑控件框中显示多行文本
我正在尝试实现一个显示文件名的工具。 我想通过使用 SetWindowText() 方法来做到这一点。 但是,当我尝试在循环中使用此方法时, 文本一行显示,并且不断刷新。
这是代码片段
for (int i = 0; i<10; i++)
{
SetWindowText(filenames);
}
请帮助。!谢谢。
I am trying to implement a tool that displays file names.
I would like to do this by using SetWindowText() method.
However, When I was trying to use this method in a loop,
the text is displayed in one line and it is continuously refreshed.
here is code snippet
for (int i = 0; i<10; i++)
{
SetWindowText(filenames);
}
please help.! thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SetWindowText
用您提供的字符串替换当前窗口文本。因此,如果你想用它显示多行,你首先必须创建一个多行字符串。
一个简单的例子:
SetWindowText
replaces the current window text with the string you provide.So, if you want to show multiple lines with it, you first have to create a multi-line string.
A quick example:
另一种经过时间考验的同时显示多个名称的方法是列表框。 MFC 提供了一个带有 CListBox 类的漂亮包装器(请参阅 http://msdn.microsoft.com/en-us/library/y04ez4c9%28v=vs.80%29.aspx)。如果列表很长,这还有一个额外的好处,那就是可滚动和(可选)可排序。
Another time-tested method of showing multiple names at once is the list box. MFC provides a nice wrapper with the CListBox Class (see http://msdn.microsoft.com/en-us/library/y04ez4c9%28v=vs.80%29.aspx). This has the added benefit of being scrollable and (optionally) sortable if the list is long.