Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Form as COM Server in VFP 7 to be used in VB

COM and Automation

Creating Form as COM Server in VFP 7 to be used in VB

by  Walid  Posted    (Edited  )
After you design your form to be 100% self contained meaning it has to run correctly by it self in VFP as a stand alone form, modify your form and select Save As Class
Save your form as a class under the name myForm for example in a visual class file ActiveXFormClass.vcx.

Modify the class and from Class menu select Class Info and check OLE Public and save.

Now, Start a new project ActiveXFormTest for example and add your class to it.
Save the project and build as Exe COM Server (Not dll).

This will register your COM Server in your computer but donÆt forget to register it your self in any machine you will run your program on either manually
Activexformtest.exe /regserver or through the Setup program.


Test your COM Server from VFP first
Code:
o=CREATEOBJECT("Activexformtest.myform")
o.Visible=.T.
o=Null
RELEASE o

Start new EXE project from VB. From the Project menu select reference and check Activexformtest Type Library.

In the General declaration section (or wherever you see fit) add
Code:
Public loVFPForm As activexformtest.myform

It doesnÆt need to be public variable.

Now, add a command button and give it Caption Show VFP Form.
In the click event add
Code:
Set loVFPForm = CreateObject("activexformtest.myform")

loVFPForm.Show (1)
This is your VFP form as an ActiveX control or Out-of-Process COM Server or whatever name you like, it is just there.

Even though This will answer your question, I donÆt recommend this technique at all.
From a design point of view, you suppose to separate your GUI from the Biz logic, what will happen if you want to run the same functionality your form offer over the Web??
So, instead of doing that try to design a Biz object provide you all the functionality you need in VFP and call it from VB native GUI,I believe this is a better design.

Best of luck

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top