Delphi 在TPanel中随机生成行列的子Tpanel处理方法

 1 unit Unit1;
 2 
 3 interface
 4 
 5 uses
 6   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
 7   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
 8 
 9 type
10   TForm1 = class(TForm)
11     Panel1: TPanel;
12     Button1: TButton;
13     Label1: TLabel;
14     Edit_Rows: TEdit;
15     Edit_Cols: TEdit;
16     Label2: TLabel;
17     Label3: TLabel;
18     procedure Button1Click(Sender: TObject);
19   private
20     { Private declarations }
21     function RetTPanel(Name: string; Width,Height: Integer): Tpanel;
22   public
23     { Public declarations }
24   end;
25 
26 var
27   Form1: TForm1;
28 
29 implementation
30 
31 {$R *.dfm}
32 
33 
34 procedure TForm1.Button1Click(Sender: TObject);
35 var
36   Bits: array of TPanel;
37   i,x,y,Rows,Cols,TpanelWidth,TpanelHeight: Integer;
38 begin
39   //3行 5列
40   Rows := StrToIntDef(edit_Rows.Text,2);
41   Cols := StrToIntDef(edit_Cols.Text,2);
42   TpanelWidth := Panel1.Width div Cols;
43   TpanelHeight := Panel1.Height div Rows;
44   SetLength(Bits,Rows*Cols);
45   for i := 0 to Length(Bits) - 1 do
46   begin
47     Bits[i] := RetTPanel('TPanel'+IntToStr(i),TpanelWidth,TpanelHeight);
48   end;
49 
50   { 绘制 }
51   x := 0;
52   y := 0;
53   for i := 0 to Length(Bits) - 1 do
54   begin
55     Bits[i].Parent := Panel1;
56     Bits[i].Left := x;
57     Bits[i].Top := y;
58 
59     Inc(x, Bits[i].Width);
60     if x >= Cols*Bits[i].Width then
61     begin
62       x := 0;
63       Inc(y, Bits[i].Height);
64     end;
65   end;
66 end;
67 
68 function TForm1.RetTPanel(Name: string; Width,Height: Integer): Tpanel;
69 begin
70   Result := Tpanel.Create(Application);
71   Result.Name := Name;
72   Result.Caption := Name;
73   Result.Color := clRed;
74   Result.Width := Width;
75   Result.Height := Height;
76   Result.Enabled := True;
77   Result.Visible := True;
78 end;
79 
80 end.

 

转载于:https://www.cnblogs.com/studycode/p/11622252.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一共2个部分,分别下载。 用过BSskin或者VCLskin的哥们 支持的开发语言 Borland Delphi 4/5/6 Borland Delphi 7 Borland Delphi 8 Borland Delphi 2005 Borland Delphi 2006 CodeGear Delphi 2007 支持的操作系统 Windows Vista Wndows 2000/XP/2003 Windows NT4.0 Windows Me Windows 98/98SE Windows 95 版本信息 当前版本:3.0 文件大小:24.9MB 更新日期:2006-12-6 下载次数:22670 软件概述 Skin++ For Delphi目前全面支持Delphi4、Delphi5、Delphi6、Delphi7、Delphi8、Delphi2005、Delphi2006。 迄今为止,Delphi支持4种类型的应用程序: 1、VCL Forms Application – Delphi for Win32 (该类型在Delphi4/5/6/7/2005/2006所有版本包含); 2、VCL Forms Application – Delphi for .Net (该类型在Delphi8/2005/2006包含); 3、Windows Forms Application – C# Builder (该类型在Delphi2005/2006包含); 4、Windows Forms Application – Delphi for .Net (该类型在Delphi8/2005/2006包含)。 Skin++对以上4种Delphi程序类型做了全面的支持。 试用版本描述与运行截图 1.在本安装盘,包含了Delphi的各个版本(D6,D7,D8,D2005,D2006)Skin++测试例; 2.关于如何使用Skin++,请参考文档《Skin++ For Delphi [All Edition]使用帮助》; 3.要查询Skin++所有的接口,请参考文档《Skin++接口描述》; 4.本安装盘提供一套试用皮肤PixOS.ssk,正式版用户将获得网站上更多更精美的皮肤。并可获得定期更新; 5.Skin++正式版提供强大的皮肤设计工具Skin++Builder。 该工具完成皮肤所有的设计工作,并可以全自动导入Windows主题、第三方主题; Skin++Builder使用详情请参考《Skin++Builder Help》; 6.案例说明: 我们以Delphi2006 VCL Win32的测试例为例,描述其组成。 打开\Delphi 2006\VCL Forms Application - Delphi For Win32\目录的MDIAPP.exe 该例是一个MDI类型的程序。主窗口部分演示Skin++在MDI方面处理的各个细节。 如:主菜单条、主弹出菜单、系统菜单、工具条、状态条、MDI客户区、MDI窗口、MDI窗口最大化后等各个部分的换肤细节。 Skin++ 3.0 可以对皮肤进行动态的色调设置 这个功能可以使您的程序可以瞬间拥有N套色调的皮肤。 更改色调样例1: 我们分以下几个页面对Delphi的全部控件进行了演示: Buttons、Static、Controls with ScrollBar(带滚动条的控件)、Splitter、TabControls、TrackBar & Progress、Misc Controls、Dialog、DataControls 6.1 Buttons 该部分我们演示了Skin++对Delphi的各种类型的按钮进行的换肤支持, 包括BitBtn按钮、SpeedButton、Tbutton、CheckBox、RadioBox 在该部分,还演示了对按钮进行多风格的换肤效果,“Style 2”按钮和其他按钮不同,呈现了其特有样式。 这种效果一般用在网络电话、多媒体软件、网络聊天等需要同时支持多种按钮风格的地方。 每个按钮具有其固定的5状态:正常、按下、高量、禁用、默认。在该窗体演示了每种按钮的5状态。 并且在Skin++ 3.0 ,支持Focus的效果。通过Tab或方向键可以看到焦点在每个按钮上移动。 6.2 Static 该部分演示了Skin++ 对Label、GroupBox、右键菜单、PanelFlowPanel、GridPanel等控件的支持。 值得一提的是,Skin++对Label的支持是彻底,并且不像其他的换肤软件需要在窗体

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值