Hi all!
I´m struggling with my code for automatic adaptation to different
screenresolutions. Can someone give me a hint about what is wrong. An
editbox does not keep its proportional placing when changing the
screenresolution.
I have made it simple for you, just copy and paste as below.
Any help would be very appreciated.
Regards
Christina
Give an empty form
- two propertys (pyHeightratio and pyWidthratio)
- a methode (mdResizecontrols)
* COPY THE CODE BELOW INTO THE FORMS INIT:
* the form itself
this.Width = 400
this.height = 200
* the bottompageframe
WITH This
.addobject('bottomPgFr','pageframe')
.bottomPgFr.top = 0
.bottomPgFr.height = this.height
.bottomPgFr.width = this.width
.bottomPgFr.pagecount = 2
ENDWITH
* the toppageframe inside the bottompageframe´s page 1
WITH This.bottomPgFr.page1
.addobject('topPgFr','pageframe')
.topPgFr.top = 0
.topPgFr.height = This.bottomPgFr.pageheight
.topPgFr.width = This.bottomPgFr.width
.topPgFr.pagecount = 2
ENDWITH
* an editbox inside the toppageframe´s page 1
WITH This.bottomPgFr.page1.topPgFr
.page1.addobject('edtNote','Editbox')
.page1.edtNote.height = 70
.page1.edtNote.width = .Width/2
.page1.edtNote.left = .Width/2
.page1.edtNote.top = .pageheight - .page1.edtNote.height
ENDWITH
* make all added objects visible
WITH This.bottomPgFr
.visible = .T.
.page1.topPgFr.visible = .T.
.page1.topPgFr.page1.edtNote.visible = .T.
ENDWITH
* code for different screenresolutions (form designed in 800x600)
this.pyHeightRatio = SYSMETRIC( 2 ) / 600
this.pyWidthRatio = SYSMETRIC( 1 ) / 800
this.height = this.height * this.pyHeightRatio
this.width = this.width * this.pywidthRatio
LOCAL loControl
FOR EACH loControl IN Thisform.Controls
Thisform.mdResizeControls(loControl)
ENDFOR
* COPY THE CODE BELOW INTO THE FORMS METHODE MDRESIZECONTROLS:
LPARAMETERS toControl
LOCAL loPage, loControl
IF PEMSTATUS( toControl, 'Width', 5 )
toControl.Width = toControl.Width * Thisform.pyWidthRatio
ENDIF
IF PEMSTATUS( toControl, 'Height', 5 )
toControl.Height = toControl.Height * Thisform.pyHeightRatio
ENDIF
IF PEMSTATUS( toControl, 'Top', 5 )
toControl.Top = toControl.Top * Thisform.pyHeightRatio
ENDIF
IF PEMSTATUS( toControl, 'Left', 5 )
toControl.Left = toControl.Left * Thisform.pyHeightRatio
ENDIF
IF PEMSTATUS( toControl, 'Fontsize', 5 )
toControl.Fontsize = INT( toControl.FontSize * Thisform.pyWidthRatio )
ENDIF
DO CASE
CASE ALLTRIM(UPPER( toControl.BaseClass )) == 'PAGEFRAME'
FOR EACH loPage IN toControl.Pages
Thisform.mdResizeControls( loPage )
ENDFOR
CASE ALLTRIM(UPPER( toControl.BaseClass )) == 'PAGE'
FOR EACH loControl IN toControl.Controls
Thisform.mdResizeControls( loControl )
ENDFOR
ENDCASE
** PS
** Gregory I know you have solved this before but the solution is gone - a
disccrash
** DS