B4J Question B4J Newbie Questions (Forms)

LWGShane

Well-Known Member
Licensed User
Longtime User
How do I center the form?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
In the center of the screen?
B4X:
Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Show
   CenterForm(MainForm)
End Sub

Sub CenterForm(f As Form)
   Dim ps As Screen = fx.PrimaryScreen
   MainForm.WindowLeft = (ps.MaxX - ps.MinX) / 2 - MainForm.Width / 2
   MainForm.WindowTop = (ps.MaxY - ps.MinY) / 2 - MainForm.Height / 2
End Sub
 
Upvote 0

LWGShane

Well-Known Member
Licensed User
Longtime User
Thanks!

I also remember my other question I was going to post: Is there a tutorial anywhere that deals with opening new forms?
 
Upvote 0

LWGShane

Well-Known Member
Licensed User
Longtime User
Remember that a Form is not special. You work with it like any other object.

To show a form you call Form.Show.

Thanks again. :)
 
Upvote 0
Top