Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have to write a class that have t

Status
Not open for further replies.

serkanb

Programmer
Jan 30, 2002
19
0
0
TR
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top