TabCtrl_SetItemSize 和用户绘制的选项卡控件
我有一个 Win32 用户绘制的选项卡控件,其创建如下:
CONTROL "Tab1",IDC_TAB_CONT,"SysTabControl32",TCS_BOTTOM |
TCS_OWNERDRAWFIXED | NOT WS_VISIBLE,0,14,185,88
我希望该控件的选项卡大小调整为永远不必看到“滑动箭头”:
现在,该控件的几乎所有内容都按预期工作,除了它不会响应这一事实TabCtrl_SetItemSize
。尽我所能,当我绘制选项卡时(在传递给 WM_DRAWITEM
的 DRAWITEMSTRUCT
中),我得到的选项卡尺寸始终是适合最长标题的尺寸它们,而不是我使用 TabCtrl_SetItemSize
设置的大小。
但是,在 TabCtrl_SetItemSize
文档中,它说:
[
TabCtrl_SetItemSize
] 设置选项卡中选项卡的宽度和高度 固定宽度或所有者绘制的选项卡 控制。
我成功调整大小的唯一方法是通过向控件发送 TCM_SETITEM 消息来设置所需长度的虚拟字符串,并在绘制时在其中写入所需的文本。这相当不方便,而且不是一个特别好的技巧。
有谁知道
- 为什么
TabCtrl_SetItemSize
没有按预期工作?和/或 - 如何正确设置选项卡大小?
非常感谢,
乔斯。
I have this Win32 user-drawn tab control that is created as:
CONTROL "Tab1",IDC_TAB_CONT,"SysTabControl32",TCS_BOTTOM |
TCS_OWNERDRAWFIXED | NOT WS_VISIBLE,0,14,185,88
I'd like for this control to have its tabs resize as never to have to see the "sliding arrows":
Now, pretty much everything about this control works as expected, except for that fact that it won't respond to TabCtrl_SetItemSize
. Try as I may, the size I get for the tabs when I get to draw them (in the DRAWITEMSTRUCT
passed to WM_DRAWITEM
) is always the size that fits the longest caption in them and never the size I've set with TabCtrl_SetItemSize
.
However, in the TabCtrl_SetItemSize
documentation, it says that:
[
TabCtrl_SetItemSize
] sets the width and height of tabs in a
fixed-width or owner-drawn tab
control.
The only way I've managed to have a decent resizing is by setting a dummy string of the desired length in it by sending the control a TCM_SETITEM
message, and writing the desired text in it at draw time. This is rather inconvenient and not a particularly nice hack.
Is there anybody who would know
- Why
TabCtrl_SetItemSize
isn't working as expected? and/or - How to set the tab size properly?
Many thanks,
joce.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅设置
TCS_OWNERDRAWFIXED
样式还不够,还必须添加TCS_FIXEDWIDTH
样式。如果存在图标,选项卡的最小尺寸至少为图标宽度 + 3。
如果你有图标(imageList附加到tabControl),即使宽度固定,你也可能会得到那些“滑动箭头”(如果可用空间小于:选项卡数量*(图标宽度+3)
Setting
TCS_OWNERDRAWFIXED
style is not enough, you have also to addTCS_FIXEDWIDTH
style.The minimum size of a tab is at least icon width + 3 if icon is present.
If you have icons (imageList attached to tabControl), you might get those "sliding arrows" even with fixed width (if there is less space available than: number of tabs*(icon width+3)