窗口自适应分辨率问题?????

zhai769275 2003-10-21 11:15:17
我在书上看到这样一段自适应窗体的代码!
const displaywidth=800;
displayheight=600;
type
Tfooclass=class(Tcontrol);
//以下为Formcreate事件内写的代码:
var
i:integer;
begin
scaled:=true;
if (screen.width<>displaywidth) then
begin
height:=longint(height)*longint(screen.height) div displayheight;
width:=longint(width)*longint(screen.width) div displaywidth;
scaleby(screen.width , displaywidth);
end;
for i:=controlcount-1 downto 0 do
begin
Tfooclass(controls[i]).Font.Size:=(newformwith div oldformwith)*Tfooclass(controls[i]).Font.Size;
end;
end;
可是在调试过程中总是出现newformwith 和 oldformwith 没有定义,请教其在哪里定义
如果有好的方法请赐教,多谢!!!!!!!!!
...全文
64 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ziyideshu 2010-05-29
  • 打赏
  • 举报
回复
就是阿,都不知道是怎么一回事。
yue_yt 2003-10-21
  • 打赏
  • 举报
回复
好像不需要这么烦,只要两行代码即可搞定

MainForm.AutoScroll:=False;
Scaleby(Screen.Width,800); //设计时屏幕设置为800*600
zhai769275 2003-10-21
  • 打赏
  • 举报
回复
赐教!
EastBuBai 2003-10-21
  • 打赏
  • 举报
回复
自己写一段吧
zhai769275 2003-10-21
  • 打赏
  • 举报
回复
不行呀,在改变字体大小的时候出现:
DefaultHeight 和TMyControl未定义呀!!!!!
再请教??
lr2000 2003-10-21
  • 打赏
  • 举报
回复
up
nyf1220 2003-10-21
  • 打赏
  • 举报
回复
procedure TfrmJtBaseScale.FormCreate(Sender: TObject);
var
i: integer;
a: real;
begin
if Screen.Width <> DefaultWidth then
begin
height:=longint(height)*longint(screen.height) div DefaultHeight;
width:=longint(width)*longint(screen.width) div DefaultWidth;
scaleby(screen.width , DefaultWidth);
for i := 0 to self.ControlCount -1 do
begin
a := screen.Height / DefaultHeight * TMyControl(self.Controls[i]).Font.Size;
TMyControl(self.Controls[i]).Font.Size := trunc(a);
end;
end;
end;
用这个吧

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧