如何确定 Windows 单选按钮的按钮部分的大小
我正在使用 DrawFrameControl 自己绘制老式学校(无主题 - 主题收音机是一个完全不同的问题)单选按钮:
DrawFrameControl(dc, &rectRadio, DFC_BUTTON, isChecked() ? DFCS_BUTTONRADIO | DFCS_CHECKED : DFCS_BUTTONRADIO);
我一直无法找到一种可靠的方法来找出要传递给 RECT 的内容。 我一直在使用 12x12 矩形,但我希望 Windows 告诉我单选按钮的大小。
DrawFrameControl 似乎缩放单选按钮以适合我通过的矩形,因此我必须接近无线电的“正确”尺寸,与屏幕上的其他(非所有者绘制的)无线电不同。
有人知道怎么做吗?
I'm drawing old school (unthemed - themed radios are a whole other problem) radio buttons myself using DrawFrameControl:
DrawFrameControl(dc, &rectRadio, DFC_BUTTON, isChecked() ? DFCS_BUTTONRADIO | DFCS_CHECKED : DFCS_BUTTONRADIO);
I've never been able to figure out a sure fire way to figure out what to pass for the RECT. I've been using a 12x12 rectangle but I'de like Windows to tell me the size of a radio button.
DrawFrameControl seems to scale the radio button to fit the rect I pass so I have to be close to the "right" size of the radio looks off from other (non-owner drawn) radios on the screen.
Anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我从事这个工作已经有一段时间了,所以我所描述的是我所做的,不一定是对问题的直接回答。
我碰巧使用位图 13 x 13 而不是 12 x 12。复选框的位图部分似乎是在 WM_DRAWITEM 中传递的。 然而,我还设置了 WM_MEASUREITEM 并为其提供相同的值,因此我的答案很可能是正确的哲学意义上的“乞求问题”。
这似乎对 Win2000 和 XP 都有效,尽管我不知道 Vista 可能会做什么。
可能值得进行一次实验来看看省略 WM_MEASUREITEM 会带来什么影响,尽管我通常会发现旧代码通常有充分的理由去做一些看起来多余的事情。
It has been a while since I worked on this, so what I am describing is what I did, and not necessarily a direct answer to the question.
I happen to use bit maps 13 x 13 rather than 12 x 12. The bitmap part of the check box seems to be passed in the WM_DRAWITEM. However, I had also set up WM_MEASUREITEM and fed it the same values, so my answer may well be "Begging the question" in the correct philosophical sense.
This seems to work well for both Win2000 and XP, though I have nbo idea what Vista might do.
It might be worth an experiment to see what leaving out WM_MEASUREITEM does, though I usually discover with old code that I usually had perfectly good reason for doing something that looks redundant.
此页显示了一些控件大小调整指南。 请注意,尺寸以 DLU(对话框单位)和像素给出,具体取决于您是否将控件放置在对话框上:
http://msdn.microsoft.com/en-us/library/aa511279.aspx#controlsizing
我认为
GetSystemMetrics
API可能会返回一些常见控件的标准大小,但我没有找到任何东西。 可能有一个通用的控制特定 API 来确定大小。This page shows some sizing guidelines for controls. Note that the sizes are given in both DLU (dialog units) and pixels, depending on whether you are placing the control on a dialog or not:
http://msdn.microsoft.com/en-us/library/aa511279.aspx#controlsizing
I thought the
GetSystemMetrics
API might return the standard size for some of the common controls, but I didn't find anything. There might be a common control specific API to determine sizing.