troubleshooting Question

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

Avatar of Alpha_AI
Alpha_AI asked on
DelphiPascal
2 Comments2 Solutions362 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros