BeginDeferWindowPos 和 DeferWindowPos、EndDeferWindowPos 是一组一起使用的函数, 可对一组窗口的位置、大小、Z 序等进行调整, 在 ExtCtrls 单元有用到.

下面先用常规方法实现对 Panel1 中的一组 Button 进行调整, 然后再用上面三个函数重新实现.


本例效果图:




代码文件:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls; type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
  end; var
  Form1: TForm1; implementation {$R *.dfm} procedure TForm1.RadioButton1Click(Sender: TObject);
var
  num,i: Integer;
  btn: TButton;
  L,T,W,H: Integer;
begin
  num := Panel1.ControlCount;   L := ;
  T := ;
  W := (Panel1.ClientWidth - L * (num+)) div num;
  H := (Panel1.ClientHeight - T * (num+)) div num;   for i := to num - do
  begin
    if Panel1.Controls[i] is TButton then
    begin
      btn := TButton(Panel1.Controls[i]);
      btn.Left := L;
      btn.Top := (H + T) * i + T;
      btn.Width := W;
      btn.Height := H;
    end;
  end;
end; procedure TForm1.RadioButton2Click(Sender: TObject);
var
  num,i: Integer;
  btn: TButton;
  L,T,W,H: Integer;
begin
  num := Panel1.ControlCount;   L := ;
  T := ;
  W := (Panel1.ClientWidth - L * (num+)) div num;
  H := (Panel1.ClientHeight - T * (num+)) div num;   for i := to num - do
  begin
    if Panel1.Controls[i] is TButton then
    begin
      btn := TButton(Panel1.Controls[i]);
      btn.Left := (W + L) * i + L;
      btn.Top := T;
      btn.Width := W;
      btn.Height := H;
    end;
  end;
end; end.

VCL 中的 Windows API 函数(6): BeginDeferWindowPos的更多相关文章

  1. VCL 中的 Windows API 函数(5): AlphaBlend

    AlphaBlend 是指定图像混合透明的函数, 在 Graphics.GraphUtil.RibbonStyleActnCtrls 单元用到. 下面的测试是把一张图片显示在窗体, 并可以调整透明度. ...

  2. VCL 中的 Windows API 函数(2): ActivateKeyboardLayout

    ActivateKeyboardLayout 分别在 Controls.DBGrids.Grids 单元用到, 基本都是如下语句: ActivateKeyboardLayout(Screen.Defa ...

  3. VCL 中的 Windows API 函数(1): AbortDoc

    AbortDoc: 该函数终止当前打印作业并删除最好一次调用 StartDoc 函数写入的所有信息. 该函数在 Printers 单元的应用:AbortDoc(Canvas.Handle);

  4. VCL 中的 Windows API 函数(4): AdjustWindowRectEx

    AdjustWindowRectEx 用在了 Forms.DBCtrls 单元. AdjustWindowRectEx 可以根据窗口样式获取的边缘尺寸. 测试: var   R: TRect; beg ...

  5. MFC中调用Windows API函数的方式

    windows aoi 函数的调用前面加::

  6. 在VBA中使用Windows API

    VBA是一种强大的编程语言,可用于自定义Microsoft Office解决方案.通过使用VBA处理一个或多个Office应用程序对象模型,可以容易地修改Office应用程序的功能或者能够使两个或多个 ...

  7. Windows API 函数列表 附帮助手册

    所有Windows API函数列表,为了方便查询,也为了大家查找,所以整理一下贡献出来了. 帮助手册:700多个Windows API的函数手册 免费下载 API之网络函数 API之消息函数 API之 ...

  8. Windows API函数大全(完整)

    Windows API函数大全,从事软件开发的朋友可以参考下 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一 ...

  9. [windows菜鸟]Windows API函数大全(完整)

    Windows API函数大全,从事软件开发的朋友可以参考下 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一 ...

随机推荐

  1. svn导出历史版本

    svn导出历史某一个版本,有时候想拷贝出项目某个版本的代码,又不希望覆盖现在的代码,需要用到导出历史版本 1.浏览历史版本    鼠标移到项目上右击显示: 2.选择显示日志,出现版本历史记录: 3.选 ...

  2. Jquery获得子页面中某个元素

    本页面中有子框架iframe1.获取iframe1中元素 $("input[name$='svNo']", window.frames["iframe1"].d ...

  3. cpu降频问题

    cpu做为能耗很高的硬件,最近几年厂商在节能方面做了很多处理,在服务器运行时,基于负载情况可调节成节能模式,节省电能,副作用是cpu的频率会降低,导致应用程序性能降低. 有第三方统计,服务器规模达到万 ...

  4. Linux系统cp: omitting directory `XXX'问题解决

    在linux系统中复制文件夹时提示如下: cp: omitting directory `foldera/' 其中foldera是我要复制的文件夹名,出现该警告的原因是因为foldera目录下还存在目 ...

  5. cocos2d-x--精灵反转效果--CCOrbitCamera

    CCSprite* pSprite = CCSprite::spriteWithFile("grossini.png"); pSprite->setPosition(ccp( ...

  6. python学习之pyc,pyo,pyd文件

    pyc:二进制文件,python文件经过编译器编译之后的文件.可以提高文件加载速度. pyo:二进制文件,优化编译后的文件.可以通过`python -O file.py`生成. pyd:python的 ...

  7. Solr学习之三 solr配置说明之一

    严格来说,我这篇内容,主要是根据Solr in Action关于配置的说明,以及参考Solr的wiki写的算是读书笔记吧,所有的图片默认来自Solr in Action这本书. 这本书我觉得对学习So ...

  8. LeetCode: Substring with Concatenation of All Words 解题报告

    Substring with Concatenation of All Words You are given a string, S, and a list of words, L, that ar ...

  9. flask中的g、add_url_rule、send_from_directory、static_url_path、static_folder的用法

    Flask中的g对象是个很好的东西,主要用于在一个请求的过程中共享数据.可以随意给g对象添加属性来保存数据,非常的方便,下面的代码是一个使用g对象的例子.下面的这个例子会使用random随机产生一个0 ...

  10. 初始化git linux上传文件常见问题

    SSH生成id_rsa, id_rsa.pub后,连接服务器却报: Agent admitted failure to sign using the key 错误. 解决方法: 在当前用户下执行命令: ...