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!

using external classes - vcx file

Status
Not open for further replies.

ravicoder

Programmer
Apr 29, 2006
26
0
1
IN
Hi all

need some some help in using 3rd party classes in my form. How do I make the class available on any toolbar in the visual foxpro main window when a form is open?

e.g I have a library which has a vcx file. how to use this vcx file in the form to set its properties and call its methods?

Thanks in advance for help

Ravi Bangera
 
Hello Ravi,

This is quite simple.

Go to Tools > Options > Controls. Click Add, and navigate to the VCX file. The name of the file will then appear in the box to the left of the dialogue.

When you come out of the dialogue, you should see the classes in the relevant toolbar when you are in the form designer. You can then drop the classes onto the form in the usual way, and adjust their properties, access their methods, etc.

You can add multiple class libraries in this way. Just remember that, as with everything in the Options dialogue, the settings will be lost when you exit VFP. To avoid that, be sure click the Set as Default button.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
There are several possible ways.

The general idea of classes is that they are just definitions, what you actually use is instances (objects) created from the class definitions.

1. SET CLASSLIB can be used to add a VCX to the known list of VCXes, after which you can use oClassInstance = CREATEOBJECT("classname") and then use it's properties and methods.
2. You can spare the SET CLASSLIB when using the more complex parameterization of the NEWOBJECT() function.

To create an instance as part of a form or container on a form, you neither use CREATEOBJECT or NEWOBJECT function, you use the root objects (say it's form) methods of form.Addobject (3) or form.Newobject (4). The simple difference is that the object of which you used one of these methods is the parent or the resulting object, that's not just an option that's more complicated as it involves a parent, it's also the only way to have a parent object, there's nothing that enables you to set a parent of an object after creating it. You can set a property to an object, but then the object.parent property still won't point to that object as a parent. So, for example, an instance of a control generated by CREATEOBJECT("controlclass") and stored in a form property like form.mycontrol won't become a visible control of the form.

Well, and I think you do wonder about controls you want to put on a form or toolbar when designing them, not by code. That's also possible in several ways.
I) Add a VCX into your project, expand the classlibrary and drag&drop a class from there onto a form or toolbar or a visual class
II) Open the form controls toolbar that shows the standard native controls and use the second icon after the mouse pointer, then "Add" to add a VCX. It'll add to the list of control groups you can activate from that context menu.
morecontrols_adojda.png

Here, for example, is the list of control groups that defaults to Standard and ActiveX, extended with "Mycontrols.vcx"
You can add many more and switch between Standard, ActiveX and any VCX
III) Use the/your Toolbox from the Tools menu. The first time you'll use this, you're asked about generating a new toolbox and where, When you right click on the bottom (status bar element) of the toolbox you get a context menu item "Add Class Library" besides other. In short, organize your classes and more there and you don't just have controls for form designers available anytime. The toolbox allows creating categories that can contain multiple class libraries and more.

Chriss
 
Thanks Mike & Chris

I did the above steps and it worked. The classes are showing up when I select view classes on the form controls toolbar

thanks again
Ravi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top