关于不同分辨率下的窗体大小问题

APRIL424 2004-12-14 05:11:46
在1024*768下设计的窗体,在800*600下显示时过大,满屏幕都显示不完,高手们有什么办法?
...全文
181 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cyywhl 2004-12-14
  • 打赏
  • 举报
回复
const
ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
ScreenHeight: LongInt = 600;
Orignwidth=800;
Orignheight=600;
if (screen.width<>orignwidth) then
begin
height:=longint(height)*longint
(screen.height) div orignheight;
width:=longint(width)*longint
(screen.width) div orignwidth;
scaleby(screen.width , orignwidth);
soundbug 2004-12-14
  • 打赏
  • 举报
回复
程序运行时先检测分辨率
if Screen.Width = 1024 then
begin
//设置窗体最大化
Self.WindowState := wsMaximized;
end
else
begin
//大小自己定
Self.Width := 800;
Self.Height := 600;
end;
wkj520 2004-12-14
  • 打赏
  • 举报
回复
我也不知道能不能行,你自己试下吧
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
Const
ScreenWidth: LongInt = 800;
ScreenHeight: LongInt = 600;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var OldFormWidth: Integer;
begin
Scaled := True;
if Screen.Width <> ScreenWidth then
begin
OldFormWidth := Width;
Height := LongInt(Height) * LongInt(Screen.Height) div ScreenHeight;
Width := LongInt(Width) * LongInt(Screen.Width) div ScreenWidth;
ScaleBy(Screen.Width,ScreenWidth);
font.Size := (Width div OldFormWidth) * Font.Size;
end;
end;

end.
Drunkard2000 2004-12-14
  • 打赏
  • 举报
回复
窗体设计时要注意布局,可以研究一下组件的Align属性,如果窗体里各个组件
都设置好了Align,窗体大小变动对组件显示是不会有影响的。自己研究一下吧
gxgyj 2004-12-14
  • 打赏
  • 举报
回复
.....
楼主在本版搜索一下分辩率看看。

5,930

社区成员

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

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