Link to home
Start Free TrialLog in
Avatar of Alpha_AI
Alpha_AI

asked on

I can scale my application smaller, but now i want to go to a bigger scale and then back my normal scale

I have am trying scaling my application, make it smaller, normal size, bigger and back to normal size again
well thats what im trying to achieve but my code isnt working properly.

It can go smaller, but it cant go bigger or back to the original size. Could someone look at it?

var
CurrentScreenWidth := Screen.Width;
CurrentScreenHeight := Screen.Height;
OriginalScreenWidth := Screen.Width;
OriginalScreenHeight := Screen.Height;


Procedure TForm1.Smaller1Click(Sender: TObject);
begin
CurrentScreenWidth := CurrentScreenWidth + 100;
CurrentScreenHeight := CurrentScreenHeight + 100;
Form1.ScaleForm(Form1,CurrentScreenWidth,CurrentScreenHeight);
end;

procedure TForm1.ScaleForm(F: TForm; ScreenWidth, ScreenHeight: Integer);
begin
   F.Scaled := True;
   F.AutoScroll := False;
   F.Position := poScreenCenter;
   F.Font.Name := 'Arial';
   if (Screen.Width <> ScreenWidth) then begin
     F.Height :=
         LongInt(F.Height) * LongInt(Screen.Height)
         div ScreenHeight;
     F.Width :=
         LongInt(F.Width) * LongInt(Screen.Width)
         div ScreenWidth;
     F.ScaleBy(Screen.Width,ScreenWidth) ;
   end;

   if (Screen.Width = ScreenWidth) then begin
     F.Height :=
         LongInt(F.Height) * LongInt(Screen.Height)
         div ScreenHeight;
     F.Width :=
         LongInt(F.Width) * LongInt(Screen.Width)
         div ScreenWidth;
     F.ScaleBy(Screen.Width,ScreenWidth) ;
   end;
end;

Procedure TForm1.Bigger1Click(Sender: TObject);
begin
CurrentScreenWidth := CurrentScreenWidth - 100;
CurrentScreenHeight := CurrentScreenHeight - 100;
Form1.ScaleForm(Form1,CurrentScreenWidth,CurrentScreenHeight);
end;

How do I go smaller and bigger and back to the original size again.
If i go smaller that works, but if i go bigger it keep going smaller.

Weird?

Ben
SOLUTION
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial