구글링해보니 나오네요
unit Span;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TShapePanel = class(TCustomPanel)
private
{ Private declarations }
FShape: TShapeType;
procedure SetShape(v: TShapeType);
protected
{ Protected declarations }
procedure Paint;override;
public
{ Public declarations }
constructor Create(A: TComponent);override;
published
{ Published declarations }
property Shape: TShapeType read FShape write SetShape default stRectangle;
end;
procedure Register;
implementation
constructor TShapePanel.Create (A: TComponent);
begin
inherited Create(A);
FShape:=stRectangle;
Caption:='';
Invalidate;
end;
procedure TShapePanel.SetShape(v: TShapeType);
begin
if V<>FShape then
begin
FShape:=v;
Invalidate;
end;
end;
procedure TShapePanel.Paint;
var
Rect: TRect;
TopColor, BottomColor: TColor;
FontHeight: Integer;
a: Integer;
const
Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
begin
Rect := GetClientRect;
with Canvas do
begin
Brush.Color := Color;
FillRect(Rect);
case FShape of
stRectangle: Rectangle(Rect.Left,Rect.Top,Rect.Right, Rect.Bottom);
stSquare: begin
If Rect.bottom-Rect.top>=Rect.Right-Rect.Left then
A:=Rect.Right-Rect.Left
else
A:=Rect.bottom-Rect.top;
Rectangle(Rect.Left,Rect.Top,Rect.Left+a, Rect.Top+a);
end;
stRoundRect: RoundRect (Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,6,6);
stRoundSquare:begin
If Rect.bottom-Rect.top>=Rect.Right-Rect.Left then
A:=Rect.Right-Rect.Left
else
A:=Rect.bottom-Rect.top;
RoundRect(Rect.Left,Rect.Top,Rect.Left+a, Rect.Top+a,6,6);
end;
stEllipse: Ellipse(Rect.Left,Rect.top,Rect.Right,Rect.Bottom);
stCircle: begin
If Rect.bottom-Rect.top>=Rect.Right-Rect.Left then
A:=Rect.Right-Rect.Left
else
A:=Rect.bottom-Rect.top;
Ellipse(Rect.Left,Rect.Top,Rect.Left+a, Rect.Top+a);
end;
end;//case
Brush.Style := bsClear;
Font := Self.Font;
FontHeight := TextHeight('W');
with Rect do
begin
Top := ((Bottom + Top) - FontHeight) div 2;
Bottom := Top + FontHeight;
end;
DrawText(Handle, PChar(Caption), -1, Rect, (DT_EXPANDTABS or
DT_VCENTER) or Alignments[Alignment]);
end;
end;
procedure Register;
begin
RegisterComponents('SAS', [TShapePanel]);
end;
end.
김현승 님이 쓰신 글 :
: 안녕하세요
: 질문은 제목과 같습니다.
: 벡터로 이미지를 그려야 하는데...찾아보니 TShapePanel 이런게 있어서요...
:
: 혹시 델파이에서 자체적으로 지원하는 건가요? 아님 따로 받아야 하나요??
:
: 아시는 분 답변 바랍니다.