Papafrank,
The divide by 2 centres the form it doesn't halve the form.
I don't have a different screen size to test this out on. I think we will get there with a combination of centering the form and using maximum size constraints in the object inspector.
It might help to have the following temporary debug code in the Form1_OnShow event.
showmessage('screen width = '+ intToStr(screen.width) + ' screen height = ' + intToStr(screen.height));
This will report your screen size - this is just to ensure Windows and VDB are seeing the same thing.
From here there are some other things you can try.
1. Move the screen sizing code from the On_Show event to the begin....end that by default has the 'Hello World' call in it.
2. Some code that didn't work for me when I was trying to get monitors with different magnifications to work, but it might work for you.
procedure ScaleForm (F: TForm; ScreenWidth, ScreenHeight: LongInt) ;
begin
F.Scaled := True;
F.AutoScroll := False;
F.Position := poDefaultPosOnly; //poScreenCenter;
F.Font.Name := 'Arial';
if (Screen.Width <> ScreenWidth) then
begin
F.Height := (F.Height * Screen.Height) div ScreenHeight;
F.Width := (F.Width * Screen.Width) div ScreenWidth;
F.ScaleBy(Screen.Width,ScreenWidth) ;
end;
end;
Called by:
begin
ScaleForm(frmMain,1920,1080) ; //OR ScaleForm(frmMain,screen.width,screen.height)
end.
The code immediately above is again using the default begin...end that the script file will have.
3. Another option might be (based on code by Tony Bryer SDA UK on DelphiGroups)
procedure CentreForm(Form: TForm);
begin
with Form do
begin
Left := Application.Form1.Left + (Application.Form1.Width - Width) div 2;
if Left < 0 then Left:=0;
Top := Application.Form1.Top + (Application.Form1.Height - Height) div 2;
if Top <0 then Top:=0;
end;
end;
Called by:
begin
//ScaleForm(Form1 , Screen.Width, Screen.Height) ;
CentreForm(Form1); //substitute the name of your main form here
end.