Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Definable Screens - Good Start
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
User Definable Screens - Good Start
Divers
Thread ID:
00286547
Message ID:
00286547
Vues:
67
Thanks to everyone for their input on my original question. I thought I would just share the results of a few hours of work (I quit answering the phone).

1. I got the article Bob Archer referred me to in Advisor, it gave me a good idea on the table to hold the data, structure listed below:

fname (c10) Hold the Form Name
cname (c20) ControlName
gName (c20) Group
cType (c1) F or C (Form or Control)
top (I)
Left (I)
Height(I)
width (I)
ccaption (C30) Control Caption/Label Caption
class (C10) Control Class to use when loading

2. Created a form with the following code in the load to load the control from the control table:

**Load Event Code****
set deleted on
set excl off
set talk off
set echo off
if !used('frmlist')
use frmlist alias frmlist in select(1) shared
endif
select frmlist
* Setup the form
locate for fname=this.name and ctype='F'
if !found()
m.fname=this.name
m.cname=''
m.gname=[Group]
m.ctype='F'
m.top=this.top
m.left=this.left
m.height=this.height
m.width=this.width
m.caption=this.caption
insert into frmlist from memvar
else
this.left=frmlist.left
this.height=frmlist.height
this.width=frmlist.width
this.top=frmlist.top
endif

* Load all the form controls
set classlib to mylib.vcx addi
scan for ctype=[C] and fname=this.name
lcObjName=allt(frmlist.cname)
llAddItem=.t.
for x=1 to thisform.controlcount
if allt(thisform.controls[x].name)==allt(lcObjName)
llAddItem=.f.
exit
endif
endfor
if llAddItem
this.addobject(lcObjName,allt(frmList.Class))
lcFrmObj=[this.]+lcObjName+[.]
&lcFrmObj.left=frmlist.left
&lcFrmObj.Top=frmlist.top
&lcFrmObj.Width=frmlist.Width
if upper(allt(frmList.Class))='MYLABEL'
&lcFrmObj.caption=frmlist.ccaption
endif
&lcFrmObj.Visible=.t.
endif
endscan

***DragDrop Event Code****
LPARAMETERS oSource, nXCoord, nYCoord
lcMess=[Do you want me to add a field for: ]+chr(13)+chr(13)+;
osource.displayvalue
if empty(oSource.displayvalue)
wait [oSource.DisplayValue=]+oSource.Value window
return
endif
set classlib to mylib.vcx addi
* Add the text field to the form
lcObjName=osource.displayvalue
this.addobject(lcObjName,"myText")
lcFrmObj=[this.]+lcObjName+[.]
&lcFrmObj.left=nXCoord
&lcFrmObj.Top=nYCoord
&lcFrmObj.Visible=.t.
* Now add a label right above it
lclblName=[lbl]+lcObjName
* Create The New Object
this.addobject(lclblName,"mylabel")
* Create an means to reference this object
lclblObj=[this.]+lclblName+[.]
local lcGetCap
do form getCap with oSource.DisplayValue to lcGetCap
&lclblObj.caption=lcGetCap
&lclblObj.left=&lcFrmObj.left
&lclblObj.Top=&lcFrmObj.Top-15
&lclblObj.width=&lcFrmObj.width
&lclblObj.Visible=.t.
thisform.refresh()


** Query Unload Event
*Save the form data
select frmlist
locate for fname=this.name and ctype='F'
if !found()
m.fname=this.name
m.cname=''
m.gname=[Group]
m.ctype='F'
m.top=this.top
m.left=this.left
m.height=this.height
m.width=this.width
m.caption=this.caption
m.class=justfname(this.classlibrary)
insert into frmlist from memvar
else
replace frmlist.top with this.top
replace frmlist.left with this.left
replace frmlist.height with this.height
replace frmlist.width with this.width
endif
* Save All of our controls
for x=1 to thisform.controlcount
lcSeek=thisform.controls[x].name
locate for fname=this.name and cname=lcSeek
if !found() && Add the control to the frmlist table
m.fname=this.name
m.cname=lcSeek
m.gname=[Group]
m.ctype='C'
m.top=thisform.controls[x].top
m.left=thisform.controls[x].left
m.height=thisform.controls[x].Height
m.width=thisform.controls[x].width
if upper(thisform.controls[x].class)=[MYLABEL]
m.ccaption=thisform.controls[x].Caption
else
m.ccaption=thisform.controls[x].name
endif
m.class=justfname(thisform.controls[x].class)
insert into frmlist from memvar
else
replace frmlist.top with thisform.controls[x].top
replace frmlist.left with thisform.controls[x].left
replace frmlist.height with thisform.controls[x].height
replace frmlist.width with thisform.controls[x].width
endif
endfor

3. Since I'm just playing at this point, I set the right-click method of the form to do an AFIELDS() on a table, and pop up a list of available fields in a seperate form. Then the user can drag the field they want to the main form and drop it. On the query unload, the field data is saved to the frmList.dbf.

4. I've still got a long ways to go, like assigning the control source and allowing the user to modify the position, aligning the controls, setting tab orders), but I think this might just work.

Anyway, no question's this time, just thought I'd share what I had learned. I'm suring there is a better way, a more "class"-y way, but it's a start.

Thanks again for all the help.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform