问题描述
我正在尝试将TFrame后代作为ActiveX控件进行包装,但似乎无法使该控件显示在ActiveX控件向导中。这个方法是否可行,如果是这样,有没有可以指出的工作示例。
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.
提前感谢
推荐答案
@Mmarquee,简单的方法是使用,这是封装Delphi窗体的ActiveX控件,可以使用@Francois建议或下一个aproach可以轻松部署任何标准形式作为一个activex控件。
@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.
首先,您需要创建一个新的activex控件
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.
将标准表单的使用添加到位于 TActiveForm
的单位,并以此方式声明标准表单的变量
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;
最后在ActiveForm的oncreate事件中,你将代码调用标准形式并嵌入到活动形式。
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;
更多信息查看这些链接
- 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
这篇关于将Delphi TFrame后代包含为ActiveX控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!