Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic form design..
Message
From
29/05/2001 03:51:50
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
 
 
To
24/05/2001 08:12:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00510753
Message ID:
00512086
Views:
10
Hi Cetin,

Thanks again for this code, but I've some question about it.. (shame on my poor knowledge :( I'm especially poor at OOP...)

What is the purpose of having the dimension SourceObjects[] in the MyForm class? I see you passed the lable name into it, but then you just use taObjects when defining the label objects.. so what did the SourceObjects[] do?

Thanks a lot!

Jimi


>Assume you have an array defining objects needed dimensioned [lnNumberOfObjects,2] with structure :
>arrObjects[ix,1]=lcLabelCaption
>arrObjects[ix,1]=lcTxtControlsource
>this could be a table too :)
>
>
Dimension arrObjects[20,2]
>For ix=1 to alen(arrObjects,1)
>  arrObjects[ix,1] = 'Label'+padl(ix,3,'0')
>Endfor
>oForm = createobject('myForm', @arrObjects, 400, 500)
>oForm.Show
>Read events
>
>Dimension arrObjects[120,2]
>For ix=1 to alen(arrObjects,1)
>  arrObjects[ix,1] = 'Label'+padl(ix,3,'0')
>Endfor
>oForm = createobject('myForm', @arrObjects, 300, 450)
>oForm.Show
>Read events
>
>
>Define class myForm as Form
>  ObjWdth = 0
>  ObjHgt = 0
>  ColGap = 20
>  RowGap = 5
>  ColPerRow = 0
>  RowPerPage = 0
>  ObjPerPage = 0
>  FrmHgt = 0
>  PgfPageHeight = 0
>  Dimension SourceObjects[1]
>
>  Procedure Init
>  Lparameters taObjects, tnHeight, tnWidth
>  Local oTempLbl, oTempTxt, oTempPgf, lnPages, ix
>  With this
>    .Height =tnHeight
>    .Width = tnWidth
>    oTempLbl = createobject('myLabel')
>    oTempTxt = createobject('myTextBox')
>    oTempPgf = createobject('myPageFrame',.Height,.Width,1)
>    .ObjWdth = oTempLbl.Width + oTempTxt.Width + 5
>    .ObjHgt  = oTempTxt.Height
>    .PgfPageHeight = oTempPgf.PageHeight
>    Release oTempLbl, oTempTxt, oTempPgf
>    Acopy(taObjects, .SourceObjects)
>    .ColPerRow = floor((.Width  - .ColGap) / .ObjWdth) && Max cols on a row
>    .RowPerPage = floor((.Height - .RowGap) / .ObjHgt) && Max rows
>    .ObjPerPage = .ColPerRow * .RowPerPage
>    If alen(taObjects,1) > .ObjPerPage && Need a pageframe
>      .FrmHgt = .PgfPageHeight
>      .RowPerPage = floor((.PgfPageHeight - .RowGap) / .ObjHgt) && Max rows
>      .ObjPerPage = .ColPerRow * .RowPerPage
>      lnPages = ceiling(alen(taObjects,1)/.ObjPerPage)
>      .AddObject('myPageFrame','myPageFrame',.Height,.Width,lnPages)
>      For ix=1 to lnPages
>        ._Addobjects(.myPageFrame.Pages(ix), ix, ;
>          .ObjPerPage, .RowPerPage, @taObjects, .ObjWdth , .ColGap, .RowGap)
>      Endfor
>    Else
>      .FrmHgt = .Height
>      ._Addobjects(this, 1, ;
>        .ObjPerPage, .RowPerPage, @taObjects, .ObjWdth , .ColGap, .RowGap)
>    Endif
>    .Setall('Visible',.t.)
>  Endwith
>Endproc
>  Procedure _Addobjects
>  Lparameters toTarget, tnGroup, tnObjPerPage, tnRowPerPage, taObjects, tnObjWdth , tnColGap, tnRowGap
>  Local lnStart, lnStop, ix
>  With this
>    lnStart = (tnGroup - 1) * tnObjPerPage + 1
>    lnStop  = min(tnGroup * tnObjPerPage, alen(taObjects,1))
>    For ix=lnStart to lnStop
>      lnPosOnCol = (ix-lnStart) % tnRowPerPage + 1
>      lnPosOnRow = floor((ix-lnStart) / tnRowPerPage)
>      toTarget.AddObject('lbl'+padl(ix,4,'0'),'myLabel',taObjects[ix,1])
>      toTarget.AddObject('txt'+padl(ix,4,'0'),'myTextBox',taObjects[ix,2])
>      With eval('toTarget.lbl'+padl(ix,4,'0'))
>        .Left = lnPosOnRow * (tnObjWdth + tnColGap)
>        .Top  = (lnPosOnCol-1) * (tnRowGap + .Height)
>        lnTxtLeft = .Left + .Width + 5
>        lnTxtTop = .Top
>      Endwith
>      With eval('toTarget.txt'+padl(ix,4,'0'))
>        .Left = lnTxtLeft
>        .Top = lnTxtTop
>      Endwith
>    Endfor
>  Endwith
>Endproc
>  Procedure queryunload
>  Clear events
>Endproc
>Enddefine
>
>Define class myPageFrame as PageFrame
>  Procedure Init
>  Lparameters tnHeight, tnWidth, tnPageCount
>  With this
>    .Height = tnHeight
>    .Width = tnWidth
>    .PageCount = tnPageCount
>  Endwith
>Endproc
>Enddefine
>
>Define class myLabel as Label
>  FontBold = .T.
>  FontItalic = .T.
>  BackStyle = 0
>  Procedure init
>  Lparameters tcCaption
>  If !empty(tcCaption)
>    This.Caption = tcCaption
>  Endif
>Endproc
>Enddefine
>
>Define class myTextBox as Textbox
>  Procedure init
>  Lparameters tcControlSource
>  If !empty(tcControlSource)
>    This.ControlSource = tcControlSource
>  Endif
>Endproc
>Enddefine
Cetin
error(503): file structure failure, signature file corrupted.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform