?
Solved

Converting a delphi form to an activeX form

Posted on 2000-01-30
3
Medium Priority
?
1,131 Views
Last Modified: 2010-04-04
I have an existing delphi form, which I would like to use as is as an activeX form, however the activeX form wizard only allows the activeX form to be inherited from TActiveXForm.

How can I convert my form to an activeX form without copy and paste??
0
Comment
Question by:gavindew
  • 2
3 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2446642
Listening
0
 
LVL 17

Accepted Solution

by:
inthe earned 400 total points
ID: 2447981
Hi,
this is from a faq:

Converting a standard Delphi Form to an ActiveForm

By Conrad Herrmann, 25 July 1997

 

People ask me this question often, and there are several techniques that can do this. The technique that I prefer is easy to learn and the most flexible. In this technique, you make your existing Delphi form a child window of an otherwise ActiveForm. Because it’s a child form, you’ll have to add code to set some of its properties to reflect that fact—to remove the window frame, to align it to its parent’s client area, etc.

This approach has several advantages. The first advantage is that its easy to get up and running—the only thing you need to do that’s not already done for you is to add code to create and embed your form in the ActiveForm. Another advantage is that unlike copying your code to the ActiveForm’s implementation file, this approach doesn’t change your form’s implementation at all. The code you’re familiar with is still familiar. It also means the form’s implementation unit can still be included in a regular Delphi application if you so desire.

 

Steps to convert a Delphi form to an ActiveForm:

Create a blank ActiveForm.
In the form’s property inspector, add an Create handler like the one shown below:

Procedure TActiveForm1.FormCreate(Sender: TObject);
begin
// This code creates a child form that is just a normal
// Delphi TForm.
// This allows the form to be shown both as a normal
// VCL form and as an ActiveForm.
ChildForm := TForm1.Create( Self );
ChildForm.Parent := Self;
ChildForm.Align := alClient;
ChildForm.BorderStyle := bsNone;
ChildForm.Visible := True;

end;
In the uses clause, add a reference to your form’s unit (in this case, Unit1).
Add the form’s implementation unit to the project (in this case, Unit1.pas).
Add the declaration of ChildForm to your TActiveForm1 class, like this:

type
TActiveForm1 = class ...
.....
public
ChildForm: TForm1;
.....
end;

Compile and test your form.

Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 2448142
another couple o ways(yes the first one involve cut'n'paste but its quick ;-)

Select everything on the form, including non-visual components, but not the form itself.
Copy them.
Now, Close the project and choose New|ActiveForm.
The IDE will create a new Dll project for you, and then a new ActiveForm. Now, paste the clipboard!
 
There's your form, including all the code attached to the components
 
Another way:
Select everything on the form, except the form
Choose Component|CreateComponentTemplate
 this will make a new component and put on your templates tab
use the ActiveForm wizard and put your componenttemplate on the active form.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question