Einzelnen Beitrag anzeigen

neolithos

Registriert seit: 31. Jul 2003
Ort: Dresden
1.386 Beiträge
 
Delphi 7 Architect
 
#11

Re: Wie Array mit Pointern auf Klassen-Instanzen füllen?

  Alt 25. Mär 2004, 16:11
Delphi-Quellcode:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, PWLists, ComCtrls, CommCtrl;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    fEdits : array of array of TObject;
  public
    procedure CreateEdits(aiWidth, aiHeight : Integer);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  CreateEdits(10, 10);
end;

procedure TForm1.CreateEdits(aiWidth, aiHeight: Integer);
var i,
    j : Integer;
begin
  LockWindowUpdate(Handle); // hat nix mit Array zu tun

  SetLength(fEdits, aiHeight);
  for i := 0 to aiHeight - 1 do
      begin
        SetLength(fEdits[i], aiWidth);
        for j := 0 to aiWidth - 1 do
            begin
              fEdits[i, j] := TEdit.Create(Self);
              with fEdits[i, j] as TEdit do
                begin
                  Parent := Self;
                  SetBounds(34 * j + 16, 25 * i + 16, 30, 21);
                  Text := Format('%d, %d', [i, j]);
                end;
            end;
      end;

  LockWindowUpdate(0);
end;

end.
- ciao neo -
Es gibt niemals dumme Fragen, sondern nur dumme Antworten!
  Mit Zitat antworten Zitat