canvas ( 积分: 300 )

V

vpanel

Unregistered / Unconfirmed
GUEST, unregistred user!
with Canvasdo

begin

Font := Self.Font;

if ThemeServices.ThemesEnabled then

begin

if Text <> '' then

begin

GetTextExtentPoint32(Handle, PChar(Text), Length(Text), Size);
CaptionRect := Rect(0, 0, Size.cx, Size.cy);
if not UseRightToLeftAlignment then

OffsetRect(CaptionRect, 8, 0)
else

OffsetRect(CaptionRect, Width - 8 - CaptionRect.Right, 0);
end
else

CaptionRect := Rect(0, 0, 0, 0);

OuterRect := ClientRect;
OuterRect.Top := (CaptionRect.Bottom - CaptionRect.Top) div 2;
with CaptionRectdo

ExcludeClipRect(Handle, Left, Top, Right, Bottom);
if Enabled then

Box := tbGroupBoxNormal
else

Box := tbGroupBoxDisabled;
Details := ThemeServices.GetElementDetails(Box);
ThemeServices.DrawElement(Handle, Details, OuterRect);

SelectClipRgn(Handle, 0);
if Text <> '' then

ThemeServices.DrawText(Handle, Details, Text, CaptionRect, DT_LEFT, 0);
end
else

begin

H := TextHeight('0');
R := Rect(0, H div 2 - 1, Width, Height);
if Ctl3D then

begin

Inc(R.Left);
Inc(R.Top);
Brush.Color := clBtnHighlight;
FrameRect(R);
OffsetRect(R, -1, -1);
Brush.Color := clBtnShadow;
end else

Brush.Color := clWindowFrame;
FrameRect(R);
if Text <> '' then

begin

if not UseRightToLeftAlignment then

R := Rect(8, 0, 0, H)
else

R := Rect(R.Right - Canvas.TextWidth(Text) - 8, 0, 0, H);
Flags := DrawTextBiDiModeFlags(DT_SINGLELINE);
DrawText(Handle, PChar(Text), Length(Text), R, Flags or DT_CALCRECT);
Brush.Color := Color;
DrawText(Handle, PChar(Text), Length(Text), R, Flags);
end;

end;

end;
 
with Canvasdo

begin

Font := Self.Font;

if ThemeServices.ThemesEnabled then

begin

if Text <> '' then

begin

GetTextExtentPoint32(Handle, PChar(Text), Length(Text), Size);
CaptionRect := Rect(0, 0, Size.cx, Size.cy);
if not UseRightToLeftAlignment then

OffsetRect(CaptionRect, 8, 0)
else

OffsetRect(CaptionRect, Width - 8 - CaptionRect.Right, 0);
end
else

CaptionRect := Rect(0, 0, 0, 0);

OuterRect := ClientRect;
OuterRect.Top := (CaptionRect.Bottom - CaptionRect.Top) div 2;
with CaptionRectdo

ExcludeClipRect(Handle, Left, Top, Right, Bottom);
if Enabled then

Box := tbGroupBoxNormal
else

Box := tbGroupBoxDisabled;
Details := ThemeServices.GetElementDetails(Box);
ThemeServices.DrawElement(Handle, Details, OuterRect);

SelectClipRgn(Handle, 0);
if Text <> '' then

ThemeServices.DrawText(Handle, Details, Text, CaptionRect, DT_LEFT, 0);
end
else

begin

H := TextHeight('0');
R := Rect(0, H div 2 - 1, Width, Height);
if Ctl3D then

begin

Inc(R.Left);
Inc(R.Top);
Brush.Color := clBtnHighlight;
FrameRect(R);
OffsetRect(R, -1, -1);
Brush.Color := clBtnShadow;
end else

Brush.Color := clWindowFrame;
FrameRect(R);
if Text <> '' then

begin

if not UseRightToLeftAlignment then

R := Rect(8, 0, 0, H)
else

R := Rect(R.Right - Canvas.TextWidth(Text) - 8, 0, 0, H);
Flags := DrawTextBiDiModeFlags(DT_SINGLELINE);
DrawText(Handle, PChar(Text), Length(Text), R, Flags or DT_CALCRECT);
Brush.Color := Color;
DrawText(Handle, PChar(Text), Length(Text), R, Flags);
end;

end;

end;
 
Flags := DrawTextBiDiModeFlags(DT_SINGLELINE);
DrawText(Handle, PChar(Text), Length(Text), R, Flags or DT_CALCRECT);
 
接受答案了.
 

Similar threads

S
回复
0
查看
616
SUNSTONE的Delphi笔记
S
S
回复
0
查看
618
SUNSTONE的Delphi笔记
S
I
回复
0
查看
537
import
I
I
回复
0
查看
458
import
I
顶部