TabCtrl_SetItemSize 和用户绘制的选项卡控件

发布于 2024-08-04 06:37:32 字数 1063 浏览 2 评论 0原文

我有一个 Win32 用户绘制的选项卡控件,其创建如下:

    CONTROL "Tab1",IDC_TAB_CONT,"SysTabControl32",TCS_BOTTOM | 
            TCS_OWNERDRAWFIXED | NOT WS_VISIBLE,0,14,185,88

我希望该控件的选项卡大小调整为永远不必看到“滑动箭头”:

alt text

现在,该控件的几乎所有内容都按预期工作,除了它不会响应这一事实TabCtrl_SetItemSize。尽我所能,当我绘制选项卡时(在传递给 WM_DRAWITEMDRAWITEMSTRUCT 中),我得到的选项卡尺寸始终是适合最长标题的尺寸它们,而不是我使用 TabCtrl_SetItemSize 设置的大小。

但是,在 TabCtrl_SetItemSize 文档中,它说:

[TabCtrl_SetItemSize] 设置选项卡中选项卡的宽度和高度 固定宽度或所有者绘制的选项卡 控制。

我成功调整大小的唯一方法是通过向控件发送 TCM_SETITEM 消息来设置所需长度的虚拟字符串,并在绘制时在其中写入所需的文本。这相当不方便,而且不是一个特别好的技巧。

有谁知道

  1. 为什么 TabCtrl_SetItemSize 没有按预期工作?和/或
  2. 如何正确设置选项卡大小?

非常感谢,

乔斯。

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":

alt text

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

  1. Why TabCtrl_SetItemSize isn't working as expected? and/or
  2. How to set the tab size properly?

Many thanks,

joce.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魂归处 2024-08-11 06:37:32
  • 仅设置 TCS_OWNERDRAWFIXED 样式还不够,还必须添加 TCS_FIXEDWIDTH 样式。

  • 如果存在图标,选项卡的最小尺寸至少为图标宽度 + 3。
    如果你有图标(imageList附加到tabControl),即使宽度固定,你也可能会得到那些“滑动箭头”(如果可用空间小于:选项卡数量*(图标宽度+3)

  • Setting TCS_OWNERDRAWFIXED style is not enough, you have also to add TCS_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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文