Form position

WZSun

Member
Licensed User
Longtime User
Hi,
Sometime back I was using the Door library to get the top and left positions of the form (Example #1) so that when the form is moved to another location, the new form is position in the 'new' location (Example #2).

Example #1:
If Not(cPPC) Then
door.FromControl("fm2")
End If
fm9.Show
PosTop = fm2.top
PosLeft = fm2.left


Example #2:
If Not(cPPC) Then
door.FromControl("fm7")
door.SetProperty("StartPosition","Manual")
fm7.top = fm2.top
fm7.left = fm2.left
End If


Question: Is there a way where I can set them as Subroutines so that I can get the position from previous form, and then set the position to the next form.

Example:
Sub GetPositionNow(FormName)
If Not(cPPC) Then
door.FromControl(FormName)
PosTop = door.FromControl(FormName).top
PosLeft = door.FromControl(FormName).left
End If
End Sub

Sub SetPositionNow(FormName)
If Not(cPPC) Then
door.FromControl(FormName)
door.SetProperty("StartPosition","Manual")
Form.top = PosTop
Form.left = PosLeft
End If
End Sub



Any help is appreciated.
 

eww245

Member
Licensed User
Hi,
Sometime back I was using the Door library to get the top and left positions of the form (Example #1) so that when the form is moved to another location, the new form is position in the 'new' location (Example #2).

Example #1:
If Not(cPPC) Then
door.FromControl("fm2")
End If
fm9.Show
PosTop = fm2.top
PosLeft = fm2.left


Example #2:
If Not(cPPC) Then
door.FromControl("fm7")
door.SetProperty("StartPosition","Manual")
fm7.top = fm2.top
fm7.left = fm2.left
End If


Question: Is there a way where I can set them as Subroutines so that I can get the position from previous form, and then set the position to the next form.

Example:
Sub GetPositionNow(FormName)
If Not(cPPC) Then
door.FromControl(FormName)
PosTop = door.FromControl(FormName).top
PosLeft = door.FromControl(FormName).left
End If
End Sub

Sub SetPositionNow(FormName)
If Not(cPPC) Then
door.FromControl(FormName)
door.SetProperty("StartPosition","Manual")
Form.top = PosTop
Form.left = PosLeft
End If
End Sub



Any help is appreciated.
To get a Forms position with the door library use this.

B4X:
door.FromControl(FormName)
TopPos = door.GetProperty("Top")
LeftPos = door.GetProperty("Left")

The rest of the code should work fine
 

agraham

Expert
Licensed User
Longtime User
It's undocumented but because a Form is actually a Control FormName.Top and FormName.Left will work both in the IDE and when optimised compiled. This might of course change in future versions but it still works in the forthcoming version 6.80.
 

WZSun

Member
Licensed User
Longtime User
Hi,
Thanks for the tips.... below are the subroutines that work...

Sub GetPositionNow(FormName)
If Not(cPPC) Then
door.FromControl(FormName)
PosTop = door.GetProperty("Top")
PosLeft = door.GetProperty("Left")
End If
End Sub

Sub SetPositionNow(FormName)
If Not(cPPC) Then
door.FromControl(FormName)
door.SetProperty("Top",PosTop)
door.SetProperty("Left",PosLeft)
End If
End Sub


Hi Erel,
I still noticed that the 'window' could still be seen (as flashing) when the form is moved. It'd be great to have Basic4PPC takes care of the window position internally in 6.80 to eliminate the window flashing..

Thanks!
 
Top