Delphi's ActiveX Control Wizard can only convert a Windowed VCL control
to a ActiveX Control. That means TGraphicControl and TComponent, such
as TImage, TBevel, TOpenDialog..., can not be converted to a ActiveX
Control by the Wizard directly.
If you want to make a ActiveX Control out of a TGraphicControl, you
can use a TWinControl as a GraphicControl container, and bind all the
graphic properties and method to that WinControl. After you havedo
ne
that and registered the new control, you can use the wizard to convert
it to a ActiveX Control.
For example:
Type
TWinImage = class(tpanel)
private
fImage: TImage;
function GetPicture: TPicture;
procedure SetPicture(value: TPicture);
function GetStretch: boolean;
procedure SetStretch(value: boolean);
public
constructor Create(AOwner: TComponent);
destructor Destroy;
procedure LoadFromFile(FileName: String);
published
property Picture: TPicture read GetPicture write SetPicture;
property Stretch: Boolean read GetStredth write SetStretch;
end;
...
implimentation
constructor TWinImage.Create(AOwner: TComponent);
begin
inherited;
fImage := TImage.Create(self);
fImage.Align := alClient;
fImage.Parent := Self;
end;
function TWinImage.GetPicture: TPicture;
begin
result := fImage.Picture;
end;
procedure TWinImage.SetPicture(value: TPicture);
begin
fImage.Picture := value;
end;
function TWinImage.GetStretch: boolean;
begin
result := fImage.Stretch;
end;
procedure TWinImage.SetStretch(value: boolean);
begin
fImage.Stretch := value;
end;
destructor TWinImage.Destroy;
begin
fImage.free;
inherited;
end;
An alternate way todo
this is to inherit a TWinControl and add Graphic
capabilities to it. A good example is TStaticText.