TPageControl DrawTab 出现问题
我将 TPageControl 样式设置为平面按钮 (tsFlatButtons
),并使用 OnDrawTab
事件更改选项卡的按钮颜色。
它可以工作,但是未激活的按钮有灰色(btnFace 颜色)边框!
知道如何解决此问题吗?
procedure TForm1.PageControlDrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
AText: string;
ARect: TRect;
begin
with (Control as TPageControl).Canvas do
begin
ARect := Rect;
OffsetRect(ARect, 0, 4);
Brush.Color := COLOR1;
FillRect(Rect);
AText := TPageControl(Control).Pages[TabIndex].Caption;
with Control.Canvas do
DrawText(Control.Canvas.Handle, PChar(AText), -1,ARect, DT_CENTER or DT_SINGLELINE);
end;
end;
I set the TPageControl Style to Flat Buttons (tsFlatButtons
), and change the tab's button color using the OnDrawTab
event.
It works, but the button that is not-active has grey (btnFace color) border!
Any idea how to fix this?
procedure TForm1.PageControlDrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
AText: string;
ARect: TRect;
begin
with (Control as TPageControl).Canvas do
begin
ARect := Rect;
OffsetRect(ARect, 0, 4);
Brush.Color := COLOR1;
FillRect(Rect);
AText := TPageControl(Control).Pages[TabIndex].Caption;
with Control.Canvas do
DrawText(Control.Canvas.Handle, PChar(AText), -1,ARect, DT_CENTER or DT_SINGLELINE);
end;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为解决方法,如果设计适合您
,您可以隐藏当前选项卡:
并添加一个 TTabSet
具有这些属性:
As a workaround, if the design is ok for you
, you can hide the current tabs:
and add a TTabSet
with these properties:
我知道这是一篇非常旧的帖子,但由于它没有完整的答案,而且我遇到了同样的问题,最终找到了如何做到这一点,我想我应该让你知道......
此外,如果某些选项卡的 tabvisible 设置为 False
我认为解决此问题的最佳方法是使用整数 i 循环选项卡:
I know this is a very old post but since it does not have a complete answer and I had the same problem and finally found out how to do it, I thought I should let you know...
Also your code does not work well if some of the tabs have tabvisible set to False
Here is I think the best way to fix this, using an integer i to loop the tabs:
请参阅下面的本单元,修复 Win64 位上的绘图问题
https://forums.embarcadero.com/ thread.jspa?messageID=292598
See this unit below, to fix Draw problems on Win64bits
https://forums.embarcadero.com/thread.jspa?messageID=292598