Board index » delphi » TImage in ActiveX control

TImage in ActiveX control


2007-02-25 08:16:48 AM
delphi277
hello,
I write my first ActiveX control in Delphi7. Conrol is TImage. My First step, I created TImageEx:
TImageEx = class(TCustomControl)
private
FImage: TImage;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy;
published
property Image: TImage read FImage;
end;
implementation
constructor TImage.Create(AOwner: TComponent);
begin
inherited Create(AOwner):
Self.Visible := False;
FImage := TImage.Create(Self);
FImage.Name := 'Image';
FImage.Parent := Self;
FImage.SetSubComponent(True);
Self.SetBounds(Self.Left, Self.Top, 105, 105);
Self.Visible := True;
end;
destructor Destroy;
begin
FImage.Free;
inherited Destroy;
end;
Now I create ActiveX control from wizard Delphi, and I have TImageX:
TImageX = class(TActiveXContol)
private
...
FDelphiControl: TImageEx;
...
public
...
function Get_CanvasHandle: Cardinal;
...
end;
implementation
...
function TImageEx.Get_CanvasHandle: cardinal;
begin
Result := FDelphiControl.Image.Canvas.Handle;
end;
From my application, I am using TImageX activex control:
TMainFrom = class(TForm)
...
ImageX: TImageX;
procedure Button1Click(Sender: TObject);
...
end;
In Button1Click procedure, I'd like draw on TImageX.Canvas:
procedure TMainForm.Button1Click(Sender: TObject);
var
LCanvas: TCanvas;
begin
LCanvas := TCanvas.Create;
try
LCanvas.Handle := ImageX.Get_CanvasHandle;
LCanvas.TextOut(10, 10, 'Test TextOutCanvas');
finally
LCanvas.Free;
end;
end;
but, I can not see any text on TImageX, why ?
please, help me and very thanks!
ps. sorry for my baaaaaaad english.... :(
--
nelid
 
 

Re:TImage in ActiveX control

hello,
I write my first ActiveX control in Delphi7. Conrol is TImage. My First step, I created TImageEx:
TImageEx = class(TCustomControl)
private
FImage: TImage;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy;
published
property Image: TImage read FImage;
end;
implementation
constructor TImage.Create(AOwner: TComponent);
begin
inherited Create(AOwner):
Self.Visible := False;
FImage := TImage.Create(Self);
FImage.Name := 'Image';
FImage.Parent := Self;
FImage.SetSubComponent(True);
Self.SetBounds(Self.Left, Self.Top, 105, 105);
Self.Visible := True;
end;
destructor Destroy;
begin
FImage.Free;
inherited Destroy;
end;
Now I create ActiveX control from wizard Delphi, and I have TImageX:
TImageX = class(TActiveXContol)
private
...
FDelphiControl: TImageEx;
...
public
...
function Get_CanvasHandle: Cardinal;
...
end;
implementation
...
function TImageEx.Get_CanvasHandle: cardinal;
begin
Result := FDelphiControl.Image.Canvas.Handle;
end;
From my application, I am using TImageX activex control:
TMainFrom = class(TForm)
...
ImageX: TImageX;
procedure Button1Click(Sender: TObject);
...
end;
In Button1Click procedure, I'd like draw on TImageX.Canvas:
procedure TMainForm.Button1Click(Sender: TObject);
var
LCanvas: TCanvas;
begin
LCanvas := TCanvas.Create;
try
LCanvas.Handle := ImageX.Get_CanvasHandle;
LCanvas.TextOut(10, 10, 'Test TextOutCanvas');
finally
LCanvas.Free;
end;
end;
but, I can not see any text on TImageX, why ?
please, help me and very thanks!
ps. sorry for my baaaaaaad english.... :(
--
nelid