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. 【Android】7.8 MyDemos项目的结构和主界面相关代码

    分类:C#.Android.VS2015: 创建日期:2016-02-17 一.简介 上一讲已经说过,系统升级为Win10后,重新创建了一个新的项目:MyDemos,并把前7章合并到了这个项目中,这次 ...

  2. 玩转oracle学习第七天

     1.上节回想 2.PL/SQL的进阶 3.oracle的视图 4.oracle的触发器 目标: 1.掌握PL/SQL的高级使用方法(能编写分页过程模块,下订单过程模块.. . ) 2.会处理or ...

  3. tomcat 源码分析

    Tomcat源码分析——Session管理分析(下)    Tomcat源码分析——Session管理分析(上)     Tomcat源码分析——请求原理分析(下)     Tomcat源码分析——请 ...

  4. less css框架的学习

    什么是LESSCSS LESSCSS是一种动态样式语言,属于CSS预处理语言的一种,它使用类似CSS的语法,为CSS的赋予了动态语言的特性,如变量.继承.运算.函数等,更方便CSS的编写和维护. LE ...

  5. static使用实例

    public class LocationActivity extends Activity { //一个Activity传值到service public static String workid ...

  6. win8 X64 未在本地计算机上注册“Microsoft.ACE.OLEDB.12.0”提供程序

    操作系统是Windows 8 64位,安装了Microsoft Office 2013,从SQL Server 2008中导入Excel文件时出现提示: 未在本地计算机上注册“Microsoft.AC ...

  7. WampServer安装环境

    今天在阿里云ESC服务器上,用的Window Server2012版本,安装WampServer时,报错msvcr100.dll缺失.上网下了好几次,也确定是64位的放到了C:\Windows\Sys ...

  8. oracle数据库表空间的创建与使用

     以下操作请使用sys系统账号操作! 1. 查询物理存储的位置 SELECT tablespace_name, file_id, file_name, round(bytes / (1024 * 10 ...

  9. QML vs WEB

    UI领域, 如果是桌面应用,QML可以更快速.如果是手机UI,H5绝对占优. 移动设备已经为各行业的HMI的响应性和用户友好性设定了标准.汽车,医疗设备,工业自动化系统和消费电子产品制造商现在希望为其 ...

  10. MongoDB(三):MongoDB概念解析

    在上一篇文章中讲解了如何安装MongoDB,这篇文章中讲解一些有关MongoDB的概念. 不管我们要学习什么数据库,都应该学习其中的基础概念,在MongoDB中基本的概念是文档.集合.数据库,下面挨个 ...