H
hjp0214
Unregistered / Unconfirmed
GUEST, unregistred user!
{ TZRPanel }
procedure Frame3DPanel(Canvas: TCanvas; var Rect: TRect; TopColor, BottomColor: TColor;
Width: Integer;aBevelMode:TBevelMode);
procedure DoRect;
var
TopRight, BottomLeft: TPoint;
begin
with Canvas, Rect do
begin
TopRight.X := Right;
TopRight.Y := Top;
BottomLeft.X := Left;
BottomLeft.Y := Bottom;
if aBevelMode=bmNone then
begin
Pen.Color := TopColor;
PolyLine([BottomLeft, TopLeft, TopRight]); //
Pen.Color := BottomColor;
Dec(BottomLeft.X);
PolyLine([TopRight,BottomRight, BottomLeft]);//
end
else begin
Pen.Color := TopColor;
PolyLine([BottomLeft,BottomRight]); //
Pen.Color := BottomColor;
Dec(BottomLeft.X);
PolyLine([BottomRight, BottomLeft]);//
end;
end;
end;
begin
Canvas.Pen.Width := 1;
Dec(Rect.Bottom); Dec(Rect.Right);
while Width > 0 do
begin
Dec(Width);
DoRect;
InflateRect(Rect, -1, -1);
end;
Inc(Rect.Bottom); Inc(Rect.Right);
end;
constructor TZRPanel.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := ControlStyle - [ csSetCaption ];//
end;
procedure TZRPanel.Paint;
const
Alignments: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
var
Rect: TRect;
TopColor, BottomColor: TColor;
FontHeight: Integer;
Flags: Longint;
procedure AdjustColors(Bevel: TPanelBevel);
begin
TopColor := clBtnHighlight;
if Bevel = bvLowered then TopColor := clBtnShadow;
BottomColor := clBtnShadow;
if Bevel = bvLowered then BottomColor := clBtnHighlight;
end;
begin
Rect := GetClientRect;
if BevelOuter <> bvNone then
begin
AdjustColors(BevelOuter);
Frame3DPanel(Canvas, Rect, TopColor, BottomColor, BevelWidth,FBevelMode);
end;
Frame3DPanel(Canvas, Rect, Color, Color, BorderWidth,FBevelMode);
if BevelInner <> bvNone then
begin
AdjustColors(BevelInner);
Frame3DPanel(Canvas, Rect, TopColor, BottomColor, BevelWidth,FBevelMode);
end;
with Canvas do
begin
// if not ThemeServices.ThemesEnabled or not ParentBackground then
// begin
// Brush.Color := Color;
// FillRect(Rect);
// end;
Brush.Style := bsClear;
Font := Self.Font;
FontHeight := TextHeight('W');
with Rect do
begin
Top := ((Bottom + Top) - FontHeight) div 2;
Bottom := Top + FontHeight;
end;
Flags := DT_EXPANDTABS or DT_VCENTER or Alignments[Alignment];
Flags := DrawTextBiDiModeFlags(Flags);
DrawText(Handle, PChar(Caption), -1, Rect, Flags);
end;
end;
procedure TZRPanel.SetBevelMode(const Value: TBevelMode);
begin
FBevelMode := Value;
Invalidate;
end;
在设计或运行时,每次改变BevelMode值,不会自动刷新控件,一定要刷新窗体,才会刷新控件。
不是有调用Invalidate;
为什么呢??请指点一下吧。
procedure Frame3DPanel(Canvas: TCanvas; var Rect: TRect; TopColor, BottomColor: TColor;
Width: Integer;aBevelMode:TBevelMode);
procedure DoRect;
var
TopRight, BottomLeft: TPoint;
begin
with Canvas, Rect do
begin
TopRight.X := Right;
TopRight.Y := Top;
BottomLeft.X := Left;
BottomLeft.Y := Bottom;
if aBevelMode=bmNone then
begin
Pen.Color := TopColor;
PolyLine([BottomLeft, TopLeft, TopRight]); //
Pen.Color := BottomColor;
Dec(BottomLeft.X);
PolyLine([TopRight,BottomRight, BottomLeft]);//
end
else begin
Pen.Color := TopColor;
PolyLine([BottomLeft,BottomRight]); //
Pen.Color := BottomColor;
Dec(BottomLeft.X);
PolyLine([BottomRight, BottomLeft]);//
end;
end;
end;
begin
Canvas.Pen.Width := 1;
Dec(Rect.Bottom); Dec(Rect.Right);
while Width > 0 do
begin
Dec(Width);
DoRect;
InflateRect(Rect, -1, -1);
end;
Inc(Rect.Bottom); Inc(Rect.Right);
end;
constructor TZRPanel.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := ControlStyle - [ csSetCaption ];//
end;
procedure TZRPanel.Paint;
const
Alignments: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
var
Rect: TRect;
TopColor, BottomColor: TColor;
FontHeight: Integer;
Flags: Longint;
procedure AdjustColors(Bevel: TPanelBevel);
begin
TopColor := clBtnHighlight;
if Bevel = bvLowered then TopColor := clBtnShadow;
BottomColor := clBtnShadow;
if Bevel = bvLowered then BottomColor := clBtnHighlight;
end;
begin
Rect := GetClientRect;
if BevelOuter <> bvNone then
begin
AdjustColors(BevelOuter);
Frame3DPanel(Canvas, Rect, TopColor, BottomColor, BevelWidth,FBevelMode);
end;
Frame3DPanel(Canvas, Rect, Color, Color, BorderWidth,FBevelMode);
if BevelInner <> bvNone then
begin
AdjustColors(BevelInner);
Frame3DPanel(Canvas, Rect, TopColor, BottomColor, BevelWidth,FBevelMode);
end;
with Canvas do
begin
// if not ThemeServices.ThemesEnabled or not ParentBackground then
// begin
// Brush.Color := Color;
// FillRect(Rect);
// end;
Brush.Style := bsClear;
Font := Self.Font;
FontHeight := TextHeight('W');
with Rect do
begin
Top := ((Bottom + Top) - FontHeight) div 2;
Bottom := Top + FontHeight;
end;
Flags := DT_EXPANDTABS or DT_VCENTER or Alignments[Alignment];
Flags := DrawTextBiDiModeFlags(Flags);
DrawText(Handle, PChar(Caption), -1, Rect, Flags);
end;
end;
procedure TZRPanel.SetBevelMode(const Value: TBevelMode);
begin
FBevelMode := Value;
Invalidate;
end;
在设计或运行时,每次改变BevelMode值,不会自动刷新控件,一定要刷新窗体,才会刷新控件。
不是有调用Invalidate;
为什么呢??请指点一下吧。