请问窗口内的控件如何随窗口缩放 请问窗体大小变化时,里面的控件该如何计算才能随窗体放大缩小 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用一些Panel来对窗口布局,也可以自己处理消息来调整控件的位置 比如说edit,选择它的属性Anchors下面的四个属性akLeft、akTop、akRight、akBottom值都设置为True则可随窗口缩放而缩放。 1.Panel布局比较简单;2.自己修改; 唔,都不成设置Anchors的属性为后,将窗体最大化后里面的按钮都大得了不得,不符合申美观;如加个panel,panel是可以随窗体变大缩小,panel里面的控件却屹然不变,如也设置其Anchors属性,则好像也不雅观,不知各位有当拉动窗口边框改变其大小时,里面的控件有按其比例缩放的代码否? 控件不多的话可以在窗口的onResize事件里面加一些控制控件比例的代码。我以前这么试过,现在也是将控件放在Panel里面,挺好的啊。 有一個控件叫resizers有這個功能.拉這個控件放在窗體中然后在窗口的onResize事件里面寫resizers1.resize(self or sender都可以). 好象是要编代码的: onformCreate事件 self.width:=screen.width; self.height:=screen.height这是使窗口最大话! 把anchors的四个属性都设置成true 那么的他的大小就是随窗口的大小 变化而变化了 给楼主一段代码,可以自动计算窗口大小的变化量,希望会有用吧。procedure TFStateReopen.FormCreate(Sender: TObject);begin InitClientHeight:= ClientHeight; //要先在窗体类中声名这些Integer变量 InitClientWidth:= ClientWidth; CurClientHeight:= ClientHeight; CurClientWidth:= ClientWidth;end;procedure TFStateReopen.FormResize(Sender: TObject);begin inherited; //计算可视组件的坐标变化 HeightInc:= ClientHeight - CurClientHeight; if HeightInc > 0 then begin CurClientHeight:= ClientHeight; end; if (HeightInc < 0) and (ClientHeight > InitClientHeight) then begin CurClientHeight:= ClientHeight; end; if (HeightInc <0) and (ClientHeight <= InitClientHeight) then begin HeightInc:= InitClientHeight - CurClientHeight; CurClientHeight:= InitClientHeight; end; WidthInc:= ClientWidth - CurClientWidth; if WidthInc > 0 then begin CurClientWidth:= ClientWidth; end; if (WidthInc < 0) and (ClientWidth > InitClientWidth) then begin CurClientWidth:= ClientWidth; end; if (WidthInc <0) and (ClientWidth <= InitClientWidth) then begin WidthInc:= InitClientWidth - CurClientWidth; CurClientWidth:= InitClientWidth; end; //调整组件位置 GroupBox1.Width:= GroupBox1.Width + WidthInc; //楼主要自己定这些调整大小和位置的语句 GroupBox2.Width:= GroupBox2.Width + WidthInc; GroupBox2.Height:= GroupBox2.Height + HeightInc; GroupBox3.Width:= GroupBox3.Width + WidthInc; GroupBox3.Top:= GroupBox3.Top + HeightInc; PanelButton.Width:= PanelButton.Width + WidthInc; PanelButton.Top:= PanelButton.Top + HeightInc;end; 1,利用panel控件2,利用Anchors的四个属性akLeft、akTop、akRight、akBottom3,取得窗口的大小,计算 我在按钮的CLICK事件中定义PChar变量p然后p := StrAlloc(2),结果用StrPas(p)居然返回按钮的Caption ? delphi7中为什么我的程序中的中文显示方块? 一个操作上的问题,但困绕了一段时间,望指导,请发表观点,谢谢 COM究竟有什么用啊? 怎么把下载的控件搞到delphi 的标准控件里~! 剪贴板里的数据怎么能存到数据库里? 程序运行占用内存上10MB 高分相赠 三层结构的问题? 主窗口在任务栏上的右键菜单能改吗 幽琴入队 请问窗口上的的各种初始化设置应该在OnActivate事件、OnCreate事件还是OnShow事件中???
2.自己修改;
我以前这么试过,现在也是将控件放在Panel里面,挺好的啊。
onformCreate事件
self.width:=screen.width;
self.height:=screen.height这是使窗口最大话!
procedure TFStateReopen.FormCreate(Sender: TObject);
begin
InitClientHeight:= ClientHeight; //要先在窗体类中声名这些Integer变量
InitClientWidth:= ClientWidth;
CurClientHeight:= ClientHeight;
CurClientWidth:= ClientWidth;
end;procedure TFStateReopen.FormResize(Sender: TObject);
begin
inherited;
//计算可视组件的坐标变化
HeightInc:= ClientHeight - CurClientHeight;
if HeightInc > 0 then
begin
CurClientHeight:= ClientHeight;
end;
if (HeightInc < 0) and (ClientHeight > InitClientHeight) then
begin
CurClientHeight:= ClientHeight;
end;
if (HeightInc <0) and (ClientHeight <= InitClientHeight) then
begin
HeightInc:= InitClientHeight - CurClientHeight;
CurClientHeight:= InitClientHeight;
end;
WidthInc:= ClientWidth - CurClientWidth;
if WidthInc > 0 then
begin
CurClientWidth:= ClientWidth;
end;
if (WidthInc < 0) and (ClientWidth > InitClientWidth) then
begin
CurClientWidth:= ClientWidth;
end;
if (WidthInc <0) and (ClientWidth <= InitClientWidth) then
begin
WidthInc:= InitClientWidth - CurClientWidth;
CurClientWidth:= InitClientWidth;
end;
//调整组件位置
GroupBox1.Width:= GroupBox1.Width + WidthInc; //楼主要自己定这些调整大小和位置的语句
GroupBox2.Width:= GroupBox2.Width + WidthInc;
GroupBox2.Height:= GroupBox2.Height + HeightInc;
GroupBox3.Width:= GroupBox3.Width + WidthInc;
GroupBox3.Top:= GroupBox3.Top + HeightInc;
PanelButton.Width:= PanelButton.Width + WidthInc;
PanelButton.Top:= PanelButton.Top + HeightInc;
end;
2,利用Anchors的四个属性akLeft、akTop、akRight、akBottom
3,取得窗口的大小,计算