首页 > 其他 > 详细

动态创建Ⅱ

时间:2014-05-05 21:45:53      阅读:516      评论:0      收藏:0      [点我收藏+]

//动态创建数组控件;和动态绑定它的事件、 (这里为了在Panel画颜色,引用了Raize里面的RzPanel)

interface

uses

 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

 Dialogs, StdCtrls, ExtCtrls, Buttons, PanelGroup, RzPanel, RzButton,RzComMon;

type

  TForm1 = class(TForm)

   Button1: TButton;

   BitBtn1: TBitBtn;

   Image1: TImage;

   Bevel1: TBevel;

   RzPanel1: TRzPanel;

   procedure FormCreate(Sender: TObject);

 private

    { Private declarations }

  public

   procedure PanelOnEnter(Sender: TObject);

   procedure PanelOnClick(Sender: TObject);

  end; 

var

  Form1: TForm1;

 RzPanel : array[0..31,0..6] of  TRzPanel;

implementation

 

{$R *.dfm}

 

 

 

  

//创建色板

procedure TForm1.FormCreate(Sender: TObject);

var

         I,j : integer;

    str,R,G,B: string;

begin

    for i:=0 to 31 do

    begin

       for j:=0 to 6  do

        begin

            RzPanel[i][j]:= TRzPanel.Create(nil);

            RzPanel[i][j].Parent :=Form1;

            RzPanel[i][j].Top := j*(RzPanel[i][j].Top +30)+15;

            RzPanel[i][j].Height := 23;

            RzPanel[i][j].Width :=23;

            RzPanel[i][j].Left := i* (RzPanel[i][j].Width+5) + 60;

            RzPanel[i][j].ShowHint := true;

            RzPanel[i][j].BorderOuter := fsNone;

            RzPanel[i][j].BorderColor := clActiveBorder;

            RzPanel[i][j].BorderWidth := 1;

            RzPanel[i][j].OnMouseEnter := PanelOnEnter;

            RzPanel[i][j].OnClick := PanelOnClick;

        end;

        RzPanel[i][0].Color := RGB(255,255,255-i*2);

       str := ‘$‘;

       R := format(‘%0x‘,[ord(255)]);

       G := format(‘%0x‘,[ord(255)]);

       B := format(‘%0x‘,[ord(255-i*2)]);

        RzPanel[i][0].Hint := Str + R +G +B;

        RzPanel[i][1].Color := RGB(255,255-i*2,255);

       R := format(‘%0x‘,[ord(255)]);

       G := format(‘%0x‘,[ord(255-i*2)]);

       B := format(‘%0x‘,[ord(255)]);

        RzPanel[i][1].Hint := Str + R +G +B;

        RzPanel[i][2].Color := RGB(255,255-i*2,255-i*2);

       R := format(‘%0x‘,[ord(255)]);

       G := format(‘%0x‘,[ord(255-i*2)]);

       B := format(‘%0x‘,[ord(255-i*2)]);

        RzPanel[i][2].Hint := Str + R +G +B;

        RzPanel[i][3].Color := RGB(255-i*2,255,255);

       R := format(‘%0x‘,[ord(255-i*2)]);

       G := format(‘%0x‘,[ord(255)]);

       B := format(‘%0x‘,[ord(255)]);

        RzPanel[i][3].Hint := Str + R +G +B;

        RzPanel[i][4].Color := RGB(255-i*2,255,255-i*2);

       R := format(‘%0x‘,[ord(255-i*2)]);

       G := format(‘%0x‘,[ord(255)]);

       B := format(‘%0x‘,[ord(255-i*2)]);

        RzPanel[i][4].Hint := Str + R +G +B;

        RzPanel[i][5].Color := RGB(255-i*2,255-i*2,255);

       R := format(‘%0x‘,[ord(255-i*2)]);

       G := format(‘%0x‘,[ord(255-i*2)]);

       B := format(‘%0x‘,[ord(255)]);

        RzPanel[i][5].Hint := Str + R +G +B;

        RzPanel[i][6].Color := RGB(255-i*2,255-i*2,255-i*2);

       R := format(‘%0x‘,[ord(255-i*2)]);

       G := format(‘%0x‘,[ord(255-i*2)]);

       B := format(‘%0x‘,[ord(255-i*2)]);

        RzPanel[i][6].Hint := Str + R +G +B;

        end;

end;

 

 

动态创建Ⅱ,布布扣,bubuko.com

动态创建Ⅱ

原文:http://www.cnblogs.com/lingzhiwen/p/3705001.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!