Board index » delphi » Form Resize in different Screen Resolution (Code Supplied)

Form Resize in different Screen Resolution (Code Supplied)

Hello All;
I found this code that was initially developed for Delphi 2 (I think)

---Code Supplied----
{This changes the Size of the form itself for other resolution's)
const
  ScreenWidth : LongInt  =1024;
  ScreenHeight : LongInt =768;

///FormCreate
begin
scaled := true;
if (screen.Width <> ScreenWidth) then
begin
  height := LongInt(height) * LongInt(Screen.height) div ScreenHeight;
  width := LongInt(width) * LongInt(Screen.Width) div ScreenWidth;
  scaleBy(Screen.Width, ScreenWidth);
{This compiles and works great under Delphi 6 Pro}

  {The code for resizing the Fonts}
type
  TFooClass = Class(TControl); {Needed to get at protected}
                                                  {Font Sizes}

  {I think that this part goes under the OnCreate As well}
  var
 I : Integer;
  begin
  for I := ControlCount - 1 downto 0 do
 TFooClass(controls[i]).Font.Size :=
   (NewFormWidth div OldFormWidth) *
  TFooClass(Controls[i]).Font.Size;
end;

---End Code for Resizing Screen Resolution--

  In the last part of the code, I get an error
[Error] Form2.pas(324): Undeclared identifier: 'NewFormWidth'
[Error] Form2.pas(324): Undeclared identifier: 'OldFormWidth'

  I tried to put the code like this:
var
NewFormWidth : integer;
OldFormWidth : Integer;

But I end up with it saying that they may not have been initialized?
------------
  If their is a better way of doing this in Delphi 6 Please, Please let me
know.
As the first part of the code does very well in resizing the form in an 800
X 600
Resolution. But the fonts I need them to be resized as well. Along .

  Please help anyone.

Wayne

--
Carrz-Fox-Fire Promotions
Delphi 6 Pro SP2 | Win2k SP2|
http://www.carrz-fox-fire.com/Delphi/Delphi_Fire_Security/Main.asp
//Delphi Components and Source Code page, For members only, Sign up today
[Free for now]
http://www.carrz-fox-fire.com/Delphi/Delphi_Fire_Security/EmailList/C....
asp
//Delphi TWebBrowser & TEmbeddeedWB Mailing List, Join Today

 

Re:Form Resize in different Screen Resolution (Code Supplied)


<<Wayne & Carr:
But I end up with it saying that they may not have been
initialized?

Quote

Well, they haven't been initialized - you haven't assigned
a value to them. I don't know what value you want to assign
to them.

Changing the user's font settings seems deeply evil to me,
anyway. :)

--
Deborah Pate (TeamB) http://delphi-jedi.org

  TeamB don't see posts sent via Google or ISPs
  Use the real Borland server: newsgroups.borland.com
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads