Wrapping a Delphi TFrame descendant as an ActiveX control

本小妞迷上赌 提交于 2019-12-21 05:51:49

问题


I am trying to wrap up a TFrame descendant as an ActiveX control, but don't seem to be able to get the control to show up in the ActiveX Control wizard. Is this approach possible, and if so, are there any working examples that I can be pointed at.

I have tried to follow the instructions here, but as I said the control show in the list of available controls.

Thanks in advance.


回答1:


@Mmarquee, the easy way to do this is use an Activeform , this is an ActiveX control that encapsulates a Delphi form, you can use the @Francois suggestion or the next aproach wich makes easy deploy any standard form as an activex control.

First you need to create a new activex control

then you add new activeform

Now , you need to create a new standard form and put your component here.

Add the uses of your standard form to the unit where is located the TActiveForm and declare an variable of your standard form in this way

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ActiveX, AxCtrls, Project75_TLB, StdVcl,
  Form1; //your unit with the standard form

type
  TActiveFormX = class(TActiveForm, IActiveFormX)
   private

   ...
   public
   MyForm :  TForm1;

finally in the oncreate event of the ActiveForm you put the code to call the standard form and embeded inside of the activeform.

procedure TActiveFormX.ActiveFormCreate(Sender: TObject);
begin
  MyForm := TForm1.Create(Self); //set the owner 
  MyForm.Parent := Self;//embed the form
  MyForm.Align := alClient;
  MyForm.BorderStyle := bsNone; //hide the border of the form
  MyForm.Visible := True;//makes the form visible
end;

for more info check theses links

  • Creating a VCL Forms ActiveX Active Form
  • Talking to ActiveForms
  • Building ActiveX Controls with Delphi 3 (old , but with excellent information)
  • Delphi 5 Developer's Guide: Creating an ActiveX control



回答2:


I think the easiest is to create your TFrame normally, so you can use it in regular Delphi apps.
Then Create an empty ActiveForm and put your Frame in it.
And voila, you can use your ActiveForm wherever you want...



来源:https://stackoverflow.com/questions/3066015/wrapping-a-delphi-tframe-descendant-as-an-activex-control

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!