procedure TForm1.FormCreate(Sender: TObject);
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);
end;
end;各位仁兄,小弟我用上面的代码,对于自适应分辩率好像不起作用,并且我边缘有些控件就没有显示
以前1024*768,改成800*600不行了,各位help me!小弟我真的真的没有可用分,只能深深的祝大家身体健康,事业进步
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);
end;
end;各位仁兄,小弟我用上面的代码,对于自适应分辩率好像不起作用,并且我边缘有些控件就没有显示
以前1024*768,改成800*600不行了,各位help me!小弟我真的真的没有可用分,只能深深的祝大家身体健康,事业进步
以前1024*768,改成800*600不行了,各位help me!小弟我真的真的没有可用分,只能深深的祝大家身体健康,事业进步
implementation
const
ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
ScreenHeight: LongInt = 600;{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
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);
end;
end;下面是解决字体大小的代码:
USES typinfo; {Add this to your USES statement.}var
i: integer;
begin
for i := componentCount - 1 downto 0 do
with components[i] do
begin
if GetPropInfo(ClassInfo, 'font') <> nil then
font.size := (NewFormWidth DIV OldFormWidth) * font.size;
end;
end;下面的函数可以解决问题:
Form:需要调整的Form,OrgWidth:开发时屏幕的宽度,OrgHeight:开发时屏幕的高度。
注意:需要把Form的Scaled设置为True。
procedure AdjustForm(Form: TForm; const OrgWidth, OrgHeight: integer);
begin
with Form do
begin
Width := Width * Screen.Width div OrgWidth;
Height := Height * Screen.Height div OrgHeight;
ScaleBy(Screen.Width, OrgWidth);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
AdjustForm(Self,1280,1024);
end;
窗体上有三个panel.align值分为为altop、altop、alclient.但但是一更改800*600,panel1上的控件有些就显示不出来,请高手相助