Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving Grid Columns Positions
Message
From
25/01/2008 07:44:22
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
25/01/2008 03:24:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01285431
Message ID:
01285465
Views:
31
Jos,
this is the tricky part. Again, this is my way, others may find it cruel.

In general:

The save of the properties is mainly started after QUERYUNLOAD decides to return true, but before I realy destroy. I use a bunch of methods for this.

There is a custom hook object that does the job (i.e. getting the storable data from each object). My frame has methods and props for each class that controls this. It mainly works the way that the form exposes a array that describes what form.property, object.property to store or set the hook to ask the object itself.

The result is called somewhere within init. This is, the form baseclass defines a init event that calls a userform_init. A child only changes the userform_init. If the userform_inits end (this means all settings of the form are done and all data is to its factory settings), I call the hook to reload. After that init will do some more stuff.

My trick is that the hook does not need to know what to set.
Infact the storage creates a vfp programm that will set all properties and may also call methods. (The empty class will be transformed into a lot of code to recreate the data).

The form and there objects know what to store, and to reload a EXECSCRIPT() does the job

The data is stored in a table for each form/user.
See the example below for my stored settings. I simply need to EXECSCRIPT this code with the form as parameter. If the form changes in a way that the reload will fail I simply use an try-end outside.
LPARAMETERS;
 toForm

WITH toForm &&frmlieferperlieferung
 IF .VISIBLE THEN
  .MoveOnInit
 ENDIF &&.VISIBLE
 .MOVE(.LEFT,.TOP,796,574)
 WITH .shpSplitter_V
  .TOP = 296
 ENDWITH &&.shpSplitter_V


 WITH .shpSplitter_H
  .LEFT = 117
 ENDWITH &&.shpSplitter_H



 .gnAlignment = .gnAlignment
 WITH .cntList
  .ctlAuswahl.glDisplay_Prop = .T.
  WITH .grdListGrid
*******************************reload GridSetting
   DO CASE
    CASE TYPE(".empSettings.empProps")="U"
     ADDPROPERTY(.empSettings,"empProps", CREATEOBJECT('EMPTY'))
    CASE TYPE(".empSettings.empProps")="O"
*ADDPROPERTY(.empSettings,"empProps", .empSettings.empProps)
    OTHERWISE
     ADDPROPERTY(.empSettings,"empProps", CREATEOBJECT('EMPTY'))
   ENDCASE
   WITH .empSettings
    ADDPROPERTY(.empProps,"COLUMN1_COLUMNORDER",1)
    ADDPROPERTY(.empProps,"COLUMN1_WIDTH",75)
    ADDPROPERTY(.empProps,"COLUMN2_COLUMNORDER",2)
    ADDPROPERTY(.empProps,"COLUMN2_WIDTH",81)
    ADDPROPERTY(.empProps,"COLUMN3_COLUMNORDER",3)
    ADDPROPERTY(.empProps,"COLUMN3_WIDTH",220)
    ADDPROPERTY(.empProps,"LOCKCOLUMNS",0)
    ADDPROPERTY(.empProps,"LOCKCOLUMNSLEFT",0)
    ADDPROPERTY(.empProps,"PARTITION",0)
   ENDWITH &&.empSettings
*call method to set the value to grid
   .ReLoad_Property
  ENDWITH &&.grdListGrid
 ENDWITH &&.cntList

 WITH .PGFMAIN.Page2.cntAuswahl_Frame
  .cntAuswahl02.opgActive.VALUE        = 2
  .cntAuswahl03.opgActive.VALUE        = 2
  .cntAuswahl04.opgActive.VALUE        = 2
 ENDWITH &&.PGFMAIN.Page2.cntAuswahl_Frame
ENDWITH &&toForm (frmlieferperlieferung)
I realy like it, because I don't need to write a prg the restores the data. I simply fill an array on form level. The most classes like the grids know what to store itself.

All the code I need on form level is:
 DIMENSION;
  .gaStoreProperty(lnRows+1,2)

 .gaStoreProperty(lnRows+1,1) = ".PGFMAIN.Page2.cntAuswahl_Frame"
 .gaStoreProperty(lnRows+1,2) = dnSaveProp_Obj
the parent defines some more
 DIMENSION;
  .gaStoreProperty(05,2)

 .gaStoreProperty(01,1) = "Move"
 .gaStoreProperty(01,2) = dnSaveProp_Move
 .gaStoreProperty(02,1) = ".shpSplitter_V"
 .gaStoreProperty(02,2) = dnSaveProp_Obj
 .gaStoreProperty(03,1) = ".shpSplitter_H"
 .gaStoreProperty(03,2) = dnSaveProp_Obj
 .gaStoreProperty(04,1) = ".gnAlignment = .gnAlignment"
 .gaStoreProperty(04,2) = dnSaveProp_Command
 .gaStoreProperty(05,1) = ".cntList"
 .gaStoreProperty(05,2) = dnSaveProp_Obj
All this is in a per user way, extra records may also be used. I use it for example to recall complex record settings. (the user may recall different settings during instances life).

I use a table within the database to store. It's within a memo.

Agnes
>Agnes,
>
>This is very usefull, thanks. I suppose you put this code in the grids init and destroy events? Also, where/how to save the toStore object?
>
>Jos
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Reply
Map
View

Click here to load this message in the networking platform