Some words about classes from GridLib.vcx library (only for VFP 6.0 SP3 and later)

Problem:
   Allocation classes MyColumn, MyHeader, SessionDE in vcx-library is not typical from the point of view of Microsoft, so they have written VFP that the use only from a code (see definitions of these classes in HeaderInGrid_p.prg), however on my sight it's rather severe restriction, ... and I have located these classes in library that is to say by "handles", the apart from is clean of aesthetic reasons, there is also a certain problem under discussion below. 
   The main thing of a problem that a method AnyObj.AddObject() does not allow to create instances of classes from prg-files immediately (only from vcx-libraries together with SET CLASSLIB TO...), while only just the method AddObject() correctly works with Private Data Session of the form, as against CreateObject()/NewObject() [see theme "I have VFP 6.0+SP3 VS6 and now class Session has appeared. Not whether will show an example of its use?" in FAQ on http://vfpdmur.narod.ru/ask_r.html]
   The possible way to overcome of the indicated difficulty consists in locating a class SessionDE (derivative from Session) in vcx-library. However here again, to make it immediately it is not possible, because there is an error: Cannot visually modify a class of this type (Error 1978) (it have place as well for classes: MyColumn, MyHeader :-(). Nevertheless, there is a small trick to realize it. Pitches below are explained how to make it, on an example Class SessionDE from library GridLib.vcx

Solution:
1) Create a new class Custom
2) Edit it in Class Designer, implying that it is a class Session
3) On completion of editing open vcx-library as the dbf-file and change values in fields Class and BaseClass with custom on Session (Column, Header, for classes MyColumn and MyHeader accordingly)
4) Recompile the project, with the included flag Recompile All Files
5) If you will need to edit thus obtained classes directly "as is" to make it immediately in Class Designer it is not possible. However, by inverse action in item 3) is higher, you receive classes edited from Class Designer. After modification it is necessary only to execute items 3-4 above.

Warning:
If you accidentally have tried to edit a not edited class Session (Column, Header) i.e. have received Error 1978, it is better to close VFP environment and to open it again, as such attempt of editing results to exclusive-grab of the file of your library and any forces to be closed of such grab is not possible :-( The reliable indication of a possibility of editing of a class SessionDE (MyColumn, MyHeader) in Class Designer is the availability is the icon of a class Custom on a tab Classes in the project. And on the contrary, do not try to open on editing in Class Designer a class, which does not have icon (i.e. derivative from Session), it inevitably will reduce Error 1978.

Creation of the own class Column:
I would be not up to an extremity honest man in relation to you, if has not uncovered one piquant detail :-) There is a certain complexity in creation of a class, derivative from Column. The problem consists on definition the container including the class Header. Thus, if we not contrive to include the class (MyHeader) in a class created as derivative from Column, i.e. exactly that makes a code:

DEFINE CLASS MyColumn AS Column
 ADD OBJECT Header1 AS MyHeader
ENDDEFINE

that we shall be do, somewhere in an event MyColumn.Init() in runtime, to make the following:

WITH This
 IF TYPE('This.Header1') = 'O'
   .RemoveObject('Header1')
 ENDIF
 .AddObject('Header1', 'MyHeader')
ENDWITH

Deleting a Header1 class, inserted by default, and adding instead of it the own class MyHeader: - (... Just so the class MyColumn from GridLib.vcx is written. It certainly not a masterpiece, however are no any problems with editing it, but an elemination that are indicated in the warning above.

Now, when as I hope a problem be clear, it is possible to create and rigorous class-ontainer, as derivative from Column. For this purpose it is possible to act asfollows:
- create a new class Label shall name it of MyLable (template for a consequent replacement on a class MyHeader)
- create a new class Container shall name it of NewColumn (it is future our new class, derivatived from Column)
- locate in a class NewColumn the instance of a class MyLable, by adding it as the Header1 name (at this stage, as you understand, our class NewColumn still is edited from Class Designer)
- now we shall close our library, and by opening it again as the dbf-file, we shall make appropriate replacements, i.e. label, container and MyLable on header, column and MyHeader accordingly. It is obvious, that after that pitch our classes will cease to be edited from Class Designer.
-recompile the project

At last, that it was easily possible to change a used class with MyColumn on NewColumn and to inspect with what from classes I am used, has located in an event MyForm.Load() following code:

In the conclusion I want to advise: before to begin something to do with library GridLib.vcx, make backup copy for it : -)

Using:
To check up said above you can on the following example containing files:  
HeaderInGrid_p.prg - "direct" code, i.e. all definitions of classes in the prg-file as well as executable example
GridLib.vcx - is created on a just technique above for classes from HeaderInGrid_p.prg
HeaderInGrid_l.prg - example using of classes from library GridLib.vcx

Best regards.
Michael Drozdov, ICS Soft, Perm, Russia
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mailto:Drozdov@ics.perm.su
My Page:  http://vfpdmur.narod.ru/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~