所有者绘制的选项卡控件具有更宽的选项卡
我正在尝试自定义绘制选项卡控件。当我使用 GetTabRect
返回的尺寸绘制选项卡时,与正常绘制方式相比,选项卡的绘制明显更宽。我认为它试图为图像腾出空间,但我没有为选项卡定义图像。为什么 GetTabRect
返回更宽的尺寸?
不知道这是否与之有关,但这是我如何在自定义 TabControl 构造函数中将其设置为所有者绘制的方法。
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw |
ControlStyles.SupportsTransparentBackColor, true);
I am trying to custom draw a tabcontrol. When I draw the tabs using the dimensions returned by GetTabRect
, the tabs are drawn noticeably wider when compared to how they are normally drawn. I thought it was trying to make room for an image, but I have no images defined for the tabs. Why would GetTabRect
return a wider size?
Don't know if this has anything to do with it, but here is how I set it to owner draw in the custom TabControl constructor.
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw |
ControlStyles.SupportsTransparentBackColor, true);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里找到了一个解决方案: http://www.codeproject.com/Messages /2707590/Re-Tab-Size.aspx
引用:
当ControlStyle.UserPaint设置为true时,控件不再发送WM_SETFONT消息。
发送 FontChange 消息所需的代码:
I found a solution here: http://www.codeproject.com/Messages/2707590/Re-Tab-Size.aspx
Quote:
When ControlStyle.UserPaint is set to true, the control no longer sends WM_SETFONT messages.
The code needed to send the FontChange messages: