![]() |
|
|
|
#1
|
|||
|
|||
|
Hi All and thanks for your help.
I was wondering if you guys can help me out on this code. I used to program my Applications in Delphi 7 however a while back I updagraded to 2010. I own a copy of ElasticForm which is in charge of handeling all type of Screen resolution changes, however, ElasticForm is not compatible with 2010. I tried to contact the Component developer but no answer from her. I found this code out there, which is suposed to take care of resolution changes and make all components inside the form resolution independant, however it is not working for me, I am sure that I am not doing things right. Perhaps you have a better solution, or a better explanation of how to use the below code the right way. Thanks again for your help. Here is the code Code:
procedure ScaleForm(F: TForm; ScreenWidth, ScreenHeight: LongInt) ;
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;
end;
|
|
#2
|
|||
|
|||
|
I've tried fMain.scaleby(120,120);
But nothing happens. Tried a button, panel but non change size. Is there something i need to activate? Scaled is set to true. Delphi 6 |
|
#3
|
|||
|
|||
|
Hi Sorry, never worked for me neither.
Sorry |
|
#4
|
|||
|
|||
|
Not sure what is expected to happen?
Anyway, few years ago I started getting feedback about problems with some resolutions. Not all components would fit into window. I added this line to every formcreate and I haven't had problems since. (D7/D2006) if pixelsperinch>120 then scaleby(120,120); |
|
#5
|
|||
|
|||
|
After trying heaps of options with ScaleBy and nothing happening, I finally found a tutorial on the web which showed my the error .
ScaleBy(M,D:Integer) You would think that M and D would be height and width, but no, M is new and D is original. If you want to scale something by 20% you enter ScaleBy(120,100) or ScaleBy(60,50) or (30,25) Make sense. Unless you are smoking the same weed as the Delphi developers are, it won't. Now read the help ? Any better - No. If some one is not intelligent enough to program ScaleBy(Round(NewSize/OldSize)) then they should be banned from using Delphi. Saying all that, ScaleBy only does panels and other static bits. It does not do DBGrids. For that you really have no option left other than recoding each page with each grid for each screen resolution. You would thinks that a 10 + year old and very expensive developmemnt package would cater for different resolutions but no. It Sucks. I've tried 3 third party scaling packages and all have issues. . |
|
#6
|
|||
|
|||
|
Hopefully I'm not on the wrong path but this works well enough.
Is there a way to take all visible elements on a form and apply a scaling factor programatically instead of one by one as below? Code:
procedure TfMain.Button1Click(Sender: TObject); var rWidScale,rHeiScale:real; begin rWidScale:=Screen.Width/fMain.Width; // Scale to full screen rHeiScale:=Screen.Height/fMain.Height; fMain.Left:=0; // Full screen fMain.Top:=0; Button1.Top:=Round(Button1.Top*rHeiScale); Button1.Left:=Round(Button1.Left*rHeiScale); Button1.Width:=Round(Button1.Width*rHeiScale); Button1.Height:=Round(Button1.Height*rHeiScale); Button1.Font.Size:=Round(Button1.Font.Size*rWidScale); fMain.Width:=Round(fMain.Width*rWidScale); fMain.Height:=Round(fMain.Height*rHeiScale); DBGrid1.Width:=Round(dbGrid1.Width*rWidScale); DBGrid1.Height:=Round(dbGrid1.Height*rHeiScale); DBGrid1.Top:=Round(dbGrid1.Top*rHeiScale); DBGrid1.Left:=Round(dbGrid1.Left*rWidScale); DBGrid1.Font.Size:=Round(dbGrid1.Font.Size*rWidScale); end; |
![]() |
| Thread Tools | |
| Display Modes | |
|
|