I have to write a class that have transparent background. I know that TImage have transparency property. So I wrote a class that inherited from TImage which draws an ellipse. Like this:
TMyControl=class(TImage)
private
procedure MyMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
public
constructor Create(AOwner:TComponent); override;
procedure Paint; override;
end;
implementation
constructor TMyControl.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
OnMouseDown:=MyMouseDown;
end;
procedure TMyControl.Paint;
begin
// SetBkMode(Handle, TRANSPARENT);
Canvas.Ellipse(0,0,Width-1,Height-1);
Canvas.TextOut(1,1,'Deneme');
end;
procedure TMyControl.MyMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
const
SC_DragMove = $F012; { a magic number }
begin
ReleaseCapture;
Perform(WM_SysCommand, SC_DragMove, 0);
end;
end.
When I created an instance of this class in another form I coudn't see anything (clear form),
But when I inherited TMyControl from TCustomControl I can see the ellipse. But TCustomControl have not tranparancy property.
What can I do?
Thanks?
TMyControl=class(TImage)
private
procedure MyMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
public
constructor Create(AOwner:TComponent); override;
procedure Paint; override;
end;
implementation
constructor TMyControl.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
OnMouseDown:=MyMouseDown;
end;
procedure TMyControl.Paint;
begin
// SetBkMode(Handle, TRANSPARENT);
Canvas.Ellipse(0,0,Width-1,Height-1);
Canvas.TextOut(1,1,'Deneme');
end;
procedure TMyControl.MyMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
const
SC_DragMove = $F012; { a magic number }
begin
ReleaseCapture;
Perform(WM_SysCommand, SC_DragMove, 0);
end;
end.
When I created an instance of this class in another form I coudn't see anything (clear form),
But when I inherited TMyControl from TCustomControl I can see the ellipse. But TCustomControl have not tranparancy property.
What can I do?
Thanks?