Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proportional resizing of forms
Message
 
To
21/02/2023 06:36:58
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01686228
Message ID:
01686235
Views:
57
Hm...

It's a colision between anchors and ratio.
You need tow modes: Resize and Ratio

Default is Resize mode and use Anchors.

MartinaJ
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


 **************************************************
*-- Form:         form1 (x:\xfrx\test\customers\tamar.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   02/20/23 07:57:01 PM
*
DEFINE CLASS form1 AS form


 Top = 0
 Left = 0
 Height = 295
 Width = 406
 DoCreate = .T.
 Caption = "Form1"
 oldwidth = 0
 oldheight = 0
 Name = "Form1"
 iResizeMode=0 && 0 - resize (default), 1 - ratio

 ADD OBJECT check1 AS checkbox WITH ;
  Top = 5, ;
  Left = 12, ;
  Height = 17, ;
  Width = 60, ;
  Alignment = 0, ;
  Caption = "Ratio", ;
  ControlSource = "Thisform.iResizeMode", ;
  Name = "Check1"

 ADD OBJECT edit1 AS editbox WITH ;
  Height = 120, ;
  Left = 12, ;
  Top = 21, ;
  Width = 189, ;
  Anchor = 15, ;
  Name = "Edit1"


 ADD OBJECT edit2 AS editbox WITH ;
  Height = 120, ;
  Left = 205, ;
  Top = 163, ;
  Width = 189, ;
  Anchor = 8, ;
  Name = "Edit2"


 PROCEDURE Resize
  *LOCAL 
  IF This.iResizeMode=1 && 0 - resize, 1 - ratio

     This.SetAll("Anchor", 0) 

     lnRatioY = This.Height/This.OldHeight
     lnRatioX = This.Width/This.OldWidth


     WITH This.edit1
     .Move(.nOrigLeft*lnRatioX, .nOrigTop*lnRatioY, .nOrigWidth*lnRatioX, .nOrigHeight*lnRatioY)
     ENDWITH

     WITH This.edit2
     .Move(.nOrigLeft*lnRatioX, .nOrigTop*lnRatioY, .nOrigWidth*lnRatioX, .nOrigHeight*lnRatioY)
     ENDWITH
  ELSE
     This.OldWidth=This.Width
     This.OldHeight=This.Height
  ENDIF

  This.edit1.ResetOrig()
  This.edit2.ResetOrig()



 ENDPROC


 PROCEDURE Init
  This.OldWidth=This.Width
  This.OldHeight=This.Height
 ENDPROC


 PROCEDURE edit1.Init
  This.AddProperty("nOrigWidth", This.Width) 
  This.AddProperty("nOrigHeight", This.Height) 
  This.AddProperty("nOrigLeft", This.Left) 
  This.AddProperty("nOrigTop", This.Top) 
  This.AddProperty("nOrigAnchor", This.Anchor) 
 ENDPROC


 PROCEDURE edit2.Init
  This.AddProperty("nOrigWidth", This.Width) 
  This.AddProperty("nOrigHeight", This.Height) 
  This.AddProperty("nOrigLeft", This.Left) 
  This.AddProperty("nOrigTop", This.Top) 
  This.AddProperty("nOrigAnchor", This.Anchor) 
 ENDPROC


 PROCEDURE edit1.ResetOrig
  IF Thisform.iResizeMode=0 && 0 - resize, 1 - ratio
  DEBUGOUT "edit1.Resize - 0"
     This.nOrigWidth=This.Width 
     This.nOrigHeight=This.Height
     This.nOrigLeft=This.Left
     This.nOrigTop=This.Top
     This.nOrigAnchor=This.Anchor
  ELSE
  DEBUGOUT "edit1.Resize - 1"
     This.Anchor=This.nOrigAnchor
  ENDIF
 ENDPROC

 PROCEDURE edit2.ResetOrig
  IF Thisform.iResizeMode=0 && 0 - resize, 1 - ratio
     This.nOrigWidth=This.Width 
     This.nOrigHeight=This.Height
     This.nOrigLeft=This.Left
     This.nOrigTop=This.Top
     This.nOrigAnchor=This.Anchor
  ELSE
     This.Anchor=This.nOrigAnchor
  ENDIF
 ENDPROC

ENDDEFINE
*
*-- EndDefine: form1
*************************************************
>>Hi Tamar,
>>
>> Maybe this ...
>>
>>
>>MartinaJ
>
>Thanks, Martina. The thing is that Anchor works fine for moving and resizing the controls on the form. What we're trying to do is manage the size of the form itself and keep it in the same ratio.
>
>Tamar
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform