• 动态创建Ⅱ


    //动态创建数组控件;和动态绑定它的事件、 (这里为了在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;

     

  • 相关阅读:
    window执行python文件
    百钱买百鸡
    牛的数量有多少
    如何实现杨辉三角
    怎样求解斐波那契数列
    php快速做外包后台开源产品
    如何实现洗牌算法
    如何获取规定的排列组合
    怎样才能得到阿姆斯壮数
    如何利用约瑟夫环来保护你与你的朋友
  • 原文地址:https://www.cnblogs.com/lingzhiwen/p/3705001.html
Copyright © 2020-2023  润新知