BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TImage in ActiveX control

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ActiveX Controls Development
View previous topic :: View next topic  
Author Message
nelid
Guest





PostPosted: Sun Feb 25, 2007 3:05 pm    Post subject: TImage in ActiveX control Reply with quote



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'm using TImageX activex control:

TMainFrom = class(TForm)
...
ImageX: TImageX;
procedure Button1Click(Sender: TObject);
...
end;

In Button1Click procedure, I would 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't see any text on TImageX, why ?

please, help me and very thanks!

ps. sorry for my baaaaaaad english.... :(

--
nelid
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ActiveX Controls Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.