如何在窗口变大后窗口内的各个控件也变大!!!请各位大侠帮忙!!!!!!

wsljj_2002 2002-04-29 09:25:11
我想在窗口变大的同时,窗口内的各个控件也随着窗口的变化而均匀分布,缩小时也是一样。请各位大侠指教!!!!!
...全文
85 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yanpeng79 2002-05-01
  • 打赏
  • 举报
回复
学习!
黑兵 2002-04-30
  • 打赏
  • 举报
回复
先定位,如:
Button1->Top=(Form1->Height)/4;
Button1->Left=(Form1->Width)/4;
再定大小
Button1->Height=(Form1->Height)/10;
Button1->Width=(Form1->Width)/10;
把以上代码加入到Form1的OnCanResize事件中。我做个类似的程序,
一定好用的。
wsljj_2002 2002-04-30
  • 打赏
  • 举报
回复
这个我也想过,但是控件太多了,有点麻烦,有没有更简单的方法??
我是不是有点懒了点?别见笑。
jerrymousenet2 2002-04-29
  • 打赏
  • 举报
回复
你把控件的left,top,用计算得来。
比如Text1->Right = Form1->Left + Form1->Width - 50;
就可以始终保持Text1的右边和form1为50的间距。
wooley 2002-04-29
  • 打赏
  • 举报
回复
用client的大小通过计算来定位,效果很好,也很好用.
wsljj_2002 2002-04-29
  • 打赏
  • 举报
回复
对不起,是我的问法有错误。
wsljj_2002 2002-04-29
  • 打赏
  • 举报
回复
我的意思是控件的大小不变,只是位置变化,还有是在子窗口里的控件。
BCppBuilder 2002-04-29
  • 打赏
  • 举报
回复
zbc(zbc) :不是这样吧。
你可以试试
zbc 2002-04-29
  • 打赏
  • 举报
回复
楼上,这么多英文,好了,简单一点:
设置组件的属性Anchors下的所有项为true,即可!
icefirewx 2002-04-29
  • 打赏
  • 举报
回复
设定 Anchors 属性
Specifies how the control is anchored to its parent.

__property TAnchors Anchors = {read=FAnchors, write=SetAnchors, stored=IsAnchorsStored, default=3};

Description

Use Anchors to ensure that a control maintains its current position relative to an edge of its parent, even if the parent is resized. When its parent is resized, the control holds its position relative to the edges to which it is anchored.

If a control is anchored to opposite edges of its parent, the control stretches when its parent is resized. For example, if a control has its Anchors property set to [akLeft,akRight], the control stretches when the width of its parent changes.

Anchors is enforced only when the parent is resized. Thus, for example, if a control is anchored to opposite edges of a form at design time and the form is created in a maximized state, the control is not stretched because the form is not resized after the control is created.

Note: If a control should maintain contact with three edges of its parent (hugging one side of the parent and stretching the length of that side), use the Align property instead. Unlike Anchors, Align allows controls to adjust to changes in the size of other aligned sibling controls as well as changes to the parent抯 size.

13,826

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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