XE6:

http://docwiki.embarcadero.com/RADStudio/XE6/en/Generating_an_Active_Form_Based_on_a_VCL_Form

http://docwiki.embarcadero.com/RADStudio/XE8/en/Creating_a_VCL_Forms_ActiveX_Active_Form

http://docwiki.embarcadero.com/RADStudio/Seattle/en/Using_ActiveX_Controls_Index

Generating an Active Form Based on a VCL Form

Go Up to Using ActiveX controls Index

Unlike other ActiveX controls, Active Forms are not first designed and then wrapped by an ActiveX wrapper class. Instead, the Active Form wizard generates a blank form that you design later when the wizard leaves you in the Form Designer.

You can test an Active Form by creating an HTML page to contain a reference to the Active Form and specify its location on the page. The Active Form can then be displayed and run from a Web browser. Inside the browser, the form behaves just like a stand-alone Delphi form. The form can contain any VCL components or ActiveX controls, including custom-built VCL controls.

To start the Active Form wizard:

  1. Choose either:
    This creates a Dynamic Link Library [DLL] project that you can use to host in-process ActiveX Objects.
  2. Now choose either:
    • File > New > Other > Delphi Projects > ActiveX > Active Form
    • File > New > Other > C++Builder Projects > ActiveX > Active Form

On the Active Form wizard, you cannot specify the name of the VCL class to wrap. This is because Active forms are always based on Vcl.AxCtrls.TActiveForm.

You can change the default names for the CoClass, implementation unit, and ActiveX library project. Similarly, this wizard lets you indicate whether you want your Active Form to require a license, whether it should include version information, and whether you want an About box form.

When you exit the wizard, it generates the following:

  • An ActiveX Library project file, which contains the code required to start an ActiveX control. You usually don't change this file.
  • A type library, which defines a CoClass for your control, the interface it exposes to clients, and any type definitions that these require. For more information about the type library, see Working with Type Libraries - Overview.
  • A form that descends from AxCtrls.TActiveForm. This form appears in the Form Designer, where you can use it to visually design the Active Form that appears to clients. Its implementation appears in the generated implementation unit. In the initialization section of the implementation unit, a class factory is created, setting up Vcl.AxCtrls.TActiveFormControl as the ActiveX wrapper for this form.
  • An About box form and unit if you requested them.
  • An .LIC file if you enabled licensing.

At this point, you can add controls and design the form as you like.

After you have designed and compiled the Active Form project into an ActiveX library (which has the OCX extension), you can create a test HTML page that contains a reference to the Active Form. Then you can test the project using an ActiveX-enabled Web browser. For instructions, see Creating a VCL Forms ActiveX Active Form.

 

XE:

http://docwiki.embarcadero.com/RADStudio/XE/en/Generating_an_ActiveX_Control_Based_On_a_VCL_Form

 

Unlike other ActiveX controls, Active Forms are not first designed and then wrapped by an ActiveX wrapper class. Instead, the ActiveForm wizard generates a blank form that you design later when the wizard leaves you in the Form Designer.

When an ActiveForm is deployed on the Web, Delphi creates an HTML page to contain the reference to the ActiveForm and specify its location on the page. The ActiveForm can then displayed and run from a Web browser. Inside the browser, the form behaves just like a stand-alone Delphi form. The form can contain any VCL components or ActiveX controls, including custom-built VCL controls.

To start the ActiveForm wizard:

  1. Choose File > New > Other to open the New Items dialog box.
  2. Select the tab labeled ActiveX under the language you are using (Delphi or C++).
  3. Double-click ActiveX Library. This creates a Dynamic Link Library [DLL] project that you can use to host in-process ActiveX Objects.
  4. Choose File > New > Other again.
  5. Select the ActiveX tab again.
  6. Double-click the ActiveForm icon.

On the Active Form wizard, you can't specify the name of the VCL class to wrap. This is because Active forms are always based on AxCtrls.TActiveForm.

You can change the default names for the CoClass, implementation unit, and ActiveX library project. Similarly, this wizard lets you indicate whether you want your Active Form to require a license, whether it should include version information, and whether you want an About box form.

When you exit the wizard, it generates the following:

  • An ActiveX Library project file, which contains the code required to start an ActiveX control. You usually don't change this file.
  • A type library, which defines and CoClass for your control, the interface it exposes to clients, and any type definitions that these require. For more information about the type library, see Working with Type Libraries - Overview.
  • A form that descends from AxCtrls.TActiveForm. This form appears in the form designer, where you can use it to visually design the Active Form that appears to clients. Its implementation appears in the generated implementation unit. In the initialization section of the implementation unit, a class factory is created, setting up AxCtrls.TActiveFormControl as the ActiveX wrapper for this form.
  • An About box form and unit if you requested them.
  • A .LIC file if you enabled licensing.

At this point, you can add controls and design the form as you like.

 

void __fastcall InitializeControl()
{
m_VclCtl->OnActivate = ActivateEvent;
// m_VclCtl->OnAfterMonitorDpiChanged = AfterMonitorDpiChangedEvent;
// m_VclCtl->OnBeforeMonitorDpiChanged = BeforeMonitorDpiChangedEvent;
m_VclCtl->OnClick = ClickEvent;
m_VclCtl->OnCreate = CreateEvent;
m_VclCtl->OnDblClick = DblClickEvent;
m_VclCtl->OnDeactivate = DeactivateEvent;
m_VclCtl->OnDestroy = DestroyEvent;
m_VclCtl->OnMouseEnter = MouseEnterEvent;
m_VclCtl->OnMouseLeave = MouseLeaveEvent;
m_VclCtl->OnPaint = PaintEvent;
}

posted on 2014-08-23 08:56  lypzxy  阅读(642)  评论(0编辑  收藏  举报