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!

Class defintion xxx is not found

Status
Not open for further replies.

SimplyES

Programmer
Oct 5, 2012
39
GB
I have a form with 3 grids. For one of these grids I require checkbox in column8. Not normally a problem if the grid is setup in the properties panel. Since I have some dynamic attributes on the form I have a WITH/ENDWITH for this grid calculating overall width, column widths and height. I have found that, once you start defining elements of a grid within the programming, you really need to define (or redefine) all properties. So, the WITH/ENDWITH does this. My problem is with the checkbox. Adding this in the properties panel is no good because that gets lost when the grid is 'redfined'. I included AddObject in the WITH/ENDWITH but that reports Class definition is not found. I have a complete class library copy with classes prefixed 'b'. So, .Column8.AddObject("check1", "bCheckBox") should do the trick. It doesn't, resulting instead in the class not found message. In desperation, I tried starting from scratch using AddObject to add the entire grid to the form but that also produces the same message!

bClassLib is in path. I am really hoping you are not going to suggest the class library is corrupted!
 
bClassLib is in path.

That's might not be enough. You probably also need to execute [tt]SET CLASSLIB TO bClassLib[/tt].

I am really hoping you are not going to suggest the class library is corrupted!

It's highly unlikely. But you can easily check that for yourself by trying to open it in the Class Designer. If it opens OK, it is almost certainly not corrupted.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike.
I checked in the Class Designer and that's OK. Also SET CLASSLIB but that hasn't made any difference. I have now created a new class for the whole grid (perhaps I should have done that at outset?!) with the checkbox onboard. Using NewObject("Gridname", "bNewGrid") from the form INIT works with no problem at all.

Not sure what else I was doing wrong with the AddObject() and I don't recall having a problem like that before.
 
One question :
The class library and the class have the same name, "bClassLib" ?

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
No. Only the class library is called bClassLib.
 
Sorry, my fault.
But maybe you have more than a single class library with the same name. One with and the other without the bCheckBox class.


Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
And what about class hierarchy? All parent and grand parent and grand grand parent classes etc. have to be available where they are referred to by the class you want to use.
It's unlikely your bCheckbox has a long inheritance chain above, I assume it's based on the native checkbox, but you have to have the whole framework of classlibs in place to use some class.

And as Mike already said having a vcx in path is not enough for VFP to find classes, indeed. Classes you want to use via CREATEOBJECT or ParentObject.ADDOBJECT have to be known by SET CLASSLIB [Additive] or SET PROCEDURE [ADDITIVE] for classes defined in PRGs via DEFINE CLASS. That is even true for vcxes compiled into an EXE. What gets unnecessary in the compiled exe is specifying a path or having things "in path".

I always recommend using absolute pathes. not in the sense of writing SET CLASSLIB TO c:\somefolder\libs\yorlib.vcx which makes all this unmovable, but as in determining SYS(16) at main.prg and working relative to that main prg path, eg:

Code:
lcHomePath = AddBS(JUSTPATH(SYS(16,0)))
lcLibsPath = lcHomepath+"libs\"
SET CLASSLIB TO (lcLibsPath + "yourlib1.vcx") ADDITVE
SET CLASSLIB TO (lcLibsPath + "yourlib2.vcx") ADDITVE

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top