Just checked.
The code in the file uploaded by
@arnelgp is by Richard Bompuis and is the same as that in Form4 of my example app.
It works well enough for popup forms but is off centre for standard forms.
The best approach will vary depending on the type of form used and whether the ribbon/nav pane are hidden, minimised or'maximised'