Hi,
When user launched a Basic4PPC-compiled as Windows app, the application will starts in the center of the desktop screen. When user moves the app to a different location, subsequent forms will move back to the center. However, subsequently when the same form is being accessed, the position where the form was previously is used.
A request here.. when the app is moved to a different location, it would be great to have all forms shown on the same location in the first instance, rather than in the center.
If you want that at the next start of the desktop program the Main form is placed at the position where it was the last time, you can save it's coordinates in a file and read it at start-up and position the Main form. And then the others with Erel's code.
Hi All,
Thanks... I think saving to a file or registry is better as users can move the app from 'any form'.. and need not be in Form1... as it's all transparent to them.. this way, regardless of which Form they're in.. it will be displayed in the 'last moved position'.
Hi Erel,
I tried using the methods suggested. It works.. but noticed there was 'flashing' of the windows from center to the position moved. This is obvious when the Form is displayed the first time. Subsequently it will not.
In your example..
Sub Button1_Click
form2.Show
form2.Left = form1.Left
form2.Top = form1.Top
End Sub
Form2 was shown before the 'moving' was done. If I changed it to:
Sub Button1_Click
form2.Left = form1.Left
form2.Top = form1.Top
form2.Show
End Sub
the Form2 will not moved to the new coordinate the first time Form2 was shown, however it will recognise the coordinate on subsequent display of Form2.
Is there a way to prevent the 'windows flashing' from being seen?
This code will prevent the flashing (door is a Door object):
Code:
Sub App_Start Form1.Show door.New1(false) door.FromControl("form2") door.SetProperty("StartPosition","Manual") ' door.FromControl("form3") ' door.SetProperty("StartPosition","Manual") ' ... End Sub
Sub Button1_Click form2.left = form1.left form2.top = form1.top form2.Show End Sub
Hi Erel and WZSun,
Works fine !
I modified the code a bit to postion also the first form, in some programs I have only one form.
Code:
Sub App_Start LoadInit ' reads the position of the main form frmTop and frmLeft door.New1(false)
IfNot(CPPC) Then door.FromControl("form1") door.SetProperty("StartPosition","Manual") EndIf
Form1.Top=frmTop ' sets the position Form1.Left=frmLeft Form1.Show
IfNot(CPPC) Then door.FromControl("form2") door.SetProperty("StartPosition","Manual") ' door.FromControl("form3") ' door.SetProperty("StartPosition","Manual") EndIf ' ... End Sub
Hi,
Perhaps it's due to my limited skillset.. I could not get the form to position where it's moved at.
Let's say I have 3 forms. Each form has a button to click to go to the next form.
When app starts, form1 is shown. I then move form1 to another area. Then I click on Form1_Button1 which shows Form2. Form2 should be in new position. Now, I move Form2 to another new location. Then click on Form2_Button to show Form3 which should be displayed in the new location.
I tried but it doesn't. Can you create a sample sbp demo so that I can grasp correctly? I believe the demo would also be useful for beginners.