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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code completion for properties of custom classes. (created visually) 1

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
US
I've created a class using the UI to generate a VCX/VCT and am successfully using this class in my code.
This is the first class I've created in this manner in VFP. Most of my properties have assign methods, no access methods.

I understand that code completion of my properties/methods is possible. However, I'm not able to display them for some reason.

Code:
SET CLASSLIB TO myclassfile 
LOCAL oClass1 as "myclassfile.myclass"
oClass1 = CREATEOBJECT("myclass")

oClass1.  (nothing)

What am I missing?
 
Unless you're writing (and have compiled and registered) an automation server DLL I think you have the syntax wrong. My help file says:

Code:
LOCAL Var1 [ AS type [ OF ClassLib ] ]

 
As dan said it should be ... myclass OF myclassfile.vcx, ideally with the full path to the vcx/vct file pair.

Besides, as the VFP task pane registers web services, it also registers intelllisense for the web service methods by adding to foxcode.dbf.
You can add your own classes, too, via Intellisense manager, it will generate the needed record(s) in foxcode.dbf for you.

1. Start Intellisense Manager from Tools->Intellisense Manager
2. Activate the tab "Types".
3. Click the button "classess..."
4. Add your vcx.
5. Now in any code editor, type LOCAL loMyVar AS
at this point intellisense will offer you a list of types, the standard base types and now also including your own classes of the vcx added in step 4.
6. In the end if you choose "myclass" you will have a line like that:
Code:
Local loMyVar AS myclass OF "c:\users\youraccount\own documents\...etc. etc...\myclasslib.vcx"
You could also do this on your own but it's much easier this way, isn't it? Intellisense Manager knows your locations this way and you don't have to remember.
7. Now after you have that, typing loMyVar. does display your class methods etc. via intellisense.

It does so even before you set loClass = CreateObject("myclass"), but you show you know this already, as you posted the essential SET CLASSLIB and CREATEOBJECT() as proof of having an understanding of vcx classes, even if you say this is your first visually created class - you've got that correctly, yes!

So you know you're still responsible to do that and to SET CLASSLIB in advance, or use NEWOBJECT() instead. This way of "strong typing" variables is indeed only helping with intellisense, nothing else.

Just one thing: You don't need set classlib before every createobject(), you set this in main.prg for all VCXes of your project in one go, typically.

So to summarize: You have to SET CLASSLIB and you have to CREATEOBJECT("theclass"). I just clearly mention this for anyone else reading and thinking this is a way of writing safer code, unfortunately it's not. It has to stand the test of runtime, still. It's jsut an intellisense helper.

Last not least there is no such syntax as classlib.class for a class name or type of a variable. This nameing convention is just a default for OLE Public classes, but doesn't start with vcx name, it starts with EXE or DLL file name containing the OLE public class after build. Well, this is going off topic now. Just follow steps 1-6 above and you'll get your intellisense in step 7.

Bye, Olaf.
 
Thanks Olaf and Dan!

That worked great. I've created quite a few classes, just not in VFP.
I've gotta say, it's a hellava lot easier to find good information on VFP than it is in old Delphi Pascal haha.

Off topic or not, I'm always learning from you two.
Thanks again.
-Stephen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top