----------------
TestLay Overview
----------------

Program TestLay demonstrates how to save a TrueGrid layout then 
restore it.  A TrueGrid layout consists of a long binary string 
which contains information used to describe what data is contained 
in each column, heading information, format, etc.  The user can, at 
"run time", change some of these setting, primarily column width 
and column location.

After the user has painstakingly setup the grid the way he wants to 
see it then it would be nice to restore those settings the next 
time the user starts the application.  And since the user could 
really mess up the grid, it would me nice to give him a quick way 
to restore the "factory settings."

---------------------
Grid Layout Functions
---------------------

We have created two VB Functions to perform the task of saving and 
restoring the layouts.  They are contained in file TGLayout.Bas

The Functions are:

Function GridGetLayout (TheFile As String, Which As String, What As 
String, TheGrid As Control) As Integer

Function GridSaveLayout (TheFile As String, Which As String, What 
As String, TheGrid As Control) As Integer

Where:

TheFile is the full file name and path where the layout information 
should be saved.  TheFile can contain many layouts.  They are 
identified by Which and What.

Which and What are used to identify the layout for TheGrid.  For 
example: Which=TestLay, What=Factory and Which=TestLay, 
What=Current would cause two layouts to be saved.  There is no 
limit to the number of layouts that can be saved in TheFile. 

----------------------
How The Functions Work
----------------------

The GridSaveLayout function:

1. Gets a temporary file name.
2. Opens for Binary the temporary file.
3. Opens for Binary TheFile, the exiting file if any.
4. Reads an existing layout from TheFile.
5. If a match is made then the new layout information is saved, if 
it is different, otherwise, the existing layout is written to 
the temporary file.
6. Loop through all the existing layouts.  If no match is found 
then the new layout is appended to the end of the temporary 
file.
7. Close the files.
8. The return code is set to True if the new layout was saved or 
replaced.  The return code is set to False if it was not saved 
or was the same as the one previously saved.
9. Replace the TheFile with the temporary file using the VB 
FileCopy statement.
10. Kill the temporary file.

The GridGetLayout function:

1. Open the TheFile.
2. Search TheFile for the desired layout.
3. If found, and if it is different from the existing setting set 
the grid's layout [Table1.Layout=FoundLayout], set the return 
code to True then exit.
4. If found, and is the same as the existing layout, set the return 
code to False then exit.
5. If not found then set the return code to False then exit.

---------------------------------
User Defined Type: TrueGridLayout
---------------------------------

The following VB user defined type is used.  Notice that the date 
and time are stored with the layout.

Type TrueGridLayout
    WhichLen As Integer 'length of which
    Which As String     'which grid, TablePeople, etc.
    TypeLen As Integer  'length of type
    Type As String      'Factory or Current, could be anything
    LastUpdatedLen As Integer   'length of date and time
    LastUpdated As String       'last updated, date and time
    ValueLen As Integer 'length of the layout
    Value As Variant    'the layout, 2000 or more characters
End Type

----------------
The Demo Program
----------------

Project file TestLay.Mak demonstrates the use of a very simple 
grid, and saving and restoring the grid settings.

The TestLay.Mak file:

TESTLAY.FRM	Demo VB Form
TESTLAY.FRX	Binary Info
TRUEGRID.VBX	TrueGrid VBX, not supplied with this demo
TGLAYOUT.BAS	The Functions
TESTLAY.BAS	Used by the Demo Program, change these
ProjWinSize=15,516,235,388
ProjWinShow=2
IconForm="Form1"
Title="Test Grid Layout"
ExeName="TESTLAY.EXE"

----------------
Other Components
----------------

TestLay.Exe	An executable, requires truegrid.vbx
TestLay.Mdb	Sample Database used by the demo.
TestLay.Ldb	Lock Database info, not needed
TestLay.Ico	Icon used by the demo
ReadMe.Txt	This read me file.

--------
Freeware
--------

These software items are presented as Freeware.  There is no charge 
for the use of the software.  There is no warranty.  Use the 
software at your own risk.

------------------------------
Other Software from The Bridge
------------------------------

MsgBox3D - A replacement for VB message box.  Download MsgB3D.Zip 
from CompuServe.  $4.95

Space Calendar - A small, compact calendar with holiday schedules 
in an Access database.  Download SpaCln.Zip.  $19.95

------
Author
------

If you have questions, problems, or suggestions, please contact:

Larry Rebich
The Bridge, Inc.
199 California Drive, Suite 210
Millbrae, CA  94030
415-697-2730
Fax: 415-692-3921
CompuServe: 71662,205

----------------------
Version 1.00, 94/05/18
----------------------

Original version completed.  A demo was uploaded to CompuServe on 
94/05/18.

-------
Credits
-------

TrueGrid is a proprietary product, trademarked by Apex Software 
Corporation.  Address:

Apex Software Corporation
4516 Henry Street
Pittsburgh, PA 1213
CompuServe: 71053,1062
Sales: 800-858-APEX
Phone: 412-681-4738
Fax: 412-681-4384

