如何获取默认复选框图像?
我正在尝试使用 CButton 构建一个所有者绘制的复选框,但由于我只想更改文本颜色,因此我希望复选框标记保持不变。
是否有命令允许我检索程序运行平台的默认复选框位图?
(或者:如何仅更改文本颜色,保留复选框标记?)
I'm trying to build an owner-drawn check box using CButton, but since I only want to change the text color, I'd like the check-box marks to remain the same.
Is there a command that allows me to retrieve the default check box bitmaps for the platform where the program is running?
(alternatively: how could I change only the text color, preserving the check box marks?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我使用 UxTheme.dll 来绘制自定义复选框。
首先,我使用以下方法绘制复选框标记: DrawThemeBackground 向其传递一个修改后的矩形 (checkboxRect.right = pCustomDraw->rc.left + 15;)
然后我使用 ::DrawText 自己绘制文本。
我希望它有帮助。
I use UxTheme.dll to draw my custom checkbox.
First I draw the check-box marks using: DrawThemeBackground passing it a modified rect (checkboxRect.right = pCustomDraw->rc.left + 15;)
And then I draw the text by myself using ::DrawText.
I hope it helps.
您最好的策略是覆盖 OnCtlColor 处理程序:
请参阅 http ://msdn.microsoft.com/en-us/library/0wwk06hc(VS.80).aspx|
Your best strategy would be to override the OnCtlColor handler:
See http://msdn.microsoft.com/en-us/library/0wwk06hc(VS.80).aspx|
如果您只想更改文本颜色,请在包含的对话框中实现
OnCtlColor
的处理程序。像这样:请注意,这不适用于常规按钮,但对于复选框应该没有问题。无需实现所有者绘制的控件。
编辑:
您必须确保您的复选框使用
BS_AUTOCHECKBOX
样式。另请确保未设置BS_OWNERDRAW
样式。编辑#2:
DrawFrameControl() 与 DFCS_BUTTONCHECK 会让你绘制默认复选框位图。
If you only want to change the text color, implement a handler for
OnCtlColor
in your containing dialog. Like this:Beware that this works not for regular push buttons, but for check boxes there should be no problem. No need to implement an owner-drawn control.
EDIT:
You have to make sure, your check box uses the
BS_AUTOCHECKBOX
style. Also make sure theBS_OWNERDRAW
style is not set.EDIT #2:
DrawFrameControl() with DFCS_BUTTONCHECK will let you draw the default check box bitmaps.
要获取 Windows 系统复选框图像(我认为这是所要求的):
将返回所有复选框的 4x3 位图的位图句柄(包括单选按钮,还启用和禁用)
To get the windows system checkbox images (which is I think what was asked):
will return a bitmap handle to a 4x3 bitmap of all the checkboxes (includes radio buttons, and also enabled and disabled)