AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Array aus Labeln mit Events

Ein Thema von wovo · begonnen am 3. Nov 2013 · letzter Beitrag vom 5. Nov 2013
 
wovo

Registriert seit: 3. Nov 2013
9 Beiträge
 
#8

AW: Array aus Labeln mit Events

  Alt 3. Nov 2013, 13:54
Hallo!
@Sir Rufo : Es sollen 48 einzele Label erzeugt werden mit 48 einzelnen Events. Später kommen noch mal 48 weitere ähnliche Label hinzu.
Das kann ich natürlich im Design einzeln erstellen. Funktioniert auch wie gewüscht. Ist nur nicht nur mühsam sondern auch recht unelegant.

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    Label10: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;

    procedure FormCreate(Sender: TObject);
    procedure Label10Click(Sender: TObject);
    procedure Label11Click(Sender: TObject);
    procedure Label12Click(Sender: TObject);
    procedure Label13Click(Sender: TObject);

  private
    { Private declarations }
{  protected
    procedure LabelsClick( Sender : TObject );} <== Hier kommt die
                                                    Fehlermeldung
  public
    { Public declarations }
    click : integer
  end;

type
  ptyp = record
          pcol : integer;
          ppos : integer;
         end;
  atyp = record
          apos : integer;
          alab : TLabel
         end;
var
  Form1: TForm1;

  ziel : array[1..4] of ptyp;
  probe : array[1..12] of ptyp;
  col  : array[1..6] of integer;

  plab  : array[1..4,1..12] of atyp;
  labs : array[1..4,1..12] of TLabel;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var i,j : integer;
begin
 for i := 1 to 4 do
  for j := 1 to 12 do
  begin
   labs[i,j]        := TLabel.Create(Form1);
   labs[i,j].Parent := self;
   labs[i,j].Left   := 144+(i-1)*48;
   labs[i,j].Top    := 160+(j-1)*48;
   labs[i,j].visible := true;
   labs[i,j].color  := clGray;
   labs[i,j].caption := '    ';
   labs[i,j].font.size := 15;

{   labs[i,j].OnClick := labels.click;}
  end;

 label1.color := clBlack;
 label2.color := clWhite;
 label3.color := clRed;
 label4.color := clYellow;
 label5.color := clLime;
 label6.color := clAqua;
 label7.color := clBlue;
 label8.color := clFuchsia;


 click    := 3;
end;

procedure TForm1.Label10Click(Sender: TObject);
begin
 if click = 3 then label10.color := clRed;
 if click = 4 then label10.color := clYellow;
 if click = 5 then label10.color := clLime;
 if click = 6 then label10.color := clAqua;
 if click = 7 then label10.color := clBlue;
 if click = 8 then label10.color := clFuchsia;
 inc(click);
 If click > 8 then click := 3
end;
procedure TForm1.Label11Click(Sender: TObject);
begin
 if click = 3 then label11.color := clRed;
 if click = 4 then label11.color := clYellow;
 if click = 5 then label11.color := clLime;
 if click = 6 then label11.color := clAqua;
 if click = 7 then label11.color := clBlue;
 if click = 8 then label11.color := clFuchsia;
 inc(click);
 If click > 8 then click := 3
end;
procedure TForm1.Label12Click(Sender: TObject);
begin
 if click = 3 then label12.color := clRed;
 if click = 4 then label12.color := clYellow;
 if click = 5 then label12.color := clLime;
 if click = 6 then label12.color := clAqua;
 if click = 7 then label12.color := clBlue;
 if click = 8 then label12.color := clFuchsia;
 inc(click);
 If click > 8 then click := 3
end;
procedure TForm1.Label13Click(Sender: TObject);
begin
 if click = 3 then label13.color := clRed;
 if click = 4 then label13.color := clYellow;
 if click = 5 then label13.color := clLime;
 if click = 6 then label13.color := clAqua;
 if click = 7 then label13.color := clBlue;
 if click = 8 then label13.color := clFuchsia;
 inc(click);
 If click > 8 then click := 3
end;

procedure init;
var z,p,c : integer;
 begin
  randomize;
  for z := 1 to 4 do
   begin
    c := random(5)+1;
    p := random(3)+1;
    ziel[z].pcol := c;
    ziel[z].ppos := p;
   end;

 end;

begin
 init;
end.
Ich danke für eure Mühe!
Gruß wovo
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz