如何将静态标签中的文本设置为粗体样式?
我正在为 Pocket PC 2003 设备编写一个应用程序。其中有一个对话框,其中显示各种文本信息。信息被分开,以便每个部分都驻留在其自己的标签内,在资源文件中定义为 LTEXT。
现在我的问题是,目前所有文本标签都具有相同的字体和样式(正常或简单,即不是粗体或斜体);我希望将其设置为粗体。我知道我可以在资源文件中将字体设置为粗体,但这会设置所有标签的样式。
如何实现这一目标?我已经看到它在 Windows 的“关于”屏幕中使用,所以我知道这是可能的。我直接使用 Win32 API 用 C++ 编写了程序(除了我使用资源文件的某些对话框),因此如果以相同的语言和方法给出答案,我将不胜感激。
谢谢。
I'm writing an application for a Pocket PC 2003 device. In it there is a dialog where various text information is shown. The information is separated so that each piece resides inside its own label, defined as LTEXT in the resource file.
Now my problem is that, at the moment, all text lables have the same font and style (normal or simple, i.e. not bold or italic); I want want one to be set in bold. I know that I can set the font to bold in the resource file, but that sets the style of all labels.
How does one achieve this? I've seen it be used in the Windows 'About' screen so I know it's possible. I've written the program in C++ using the Win32 API directly (except for certain dialogs where I've used the resource file) so I would appreciate if the answer was given in the same language and approach.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在资源编辑器中,编辑静态文本项,并将其控件 ID 更改为唯一的内容:例如 IDC_BOLD。
在承载该控件的对话框的 DialogProc 中,添加一个
WM_CTLCOLORSTATIC
处理程序:您正在为 Pocket PC 2003 进行开发,我不知道有哪些按钮样式可用。 此页面当然指的是桌面XP。但是,如果对话框中的按钮不是纯灰色 95esq 按钮,则返回 0 可能更合适,因为如果对话框背景不是纯灰色,则可以正确绘制文本背景。
预视觉样式返回 0 会导致系统重置 DC,因此了解哪个返回值合适很重要。
In the resource editor, edit the static text item, and change its control ID to something unique: IDC_BOLD for example.
In the DialogProc for the dialog boxes that is hosting the control, add a
WM_CTLCOLORSTATIC
handler:You are developing for Pocket PC 2003, I don't know what buttons styles are available. This Page refers of course to desktop XP. But, if the buttons in the dialogs are not flat grey 95esq buttons, then it might be more appropriate to return 0 as that will paint the text background correctly if the dialogs background is not plain grey.
Pre-visual styles a return of 0 causes the system to reset the DC so its important to know which return is appropriate.