Aligning screen centre

This is probably covered in the documents somewhere, but I can't find it.


Is there a way to align forms horizontally in the screen centre or do you have to that in the html template?

You could do this with a template where you position a DIV centered and have the form hosted in this DIV. 
Alternatively, you could do this with code. This sample code snippet will always center a panel in the browser window:


procedure TForm3.WebFormResize(Sender: TObject);
var
  jsr: TJSDOMRect;
begin
  jsr := document.body.getBoundingClientRect;

  webpanel1.Left := Round((jsr.right - jsr.left - webpanel1.Width) / 2);
end;

thanks Bruno

This returns jsr.width correctly but not height. 

How to get browser window current height?

If you have scrollbars, this might indeed have a different height.
The browser window height is returned by window.height

jsr.height always returns small number (8, 24) 
window:TJSWindow does not have height but there are innerHeight and outerHeight. These are good.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.