Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delphi - komponenttimatriisi...

0 views
Skip to first unread message

Erkki Latomaa

unread,
Nov 23, 2009, 12:25:00 PM11/23/09
to
Yritän korvata erästä StringGrid komponenttia TLabels arraylla, mutta
ei pelitä.
Createssa tökkää... Mikä neuvoksi?
Eki
==
esittely:
type TGrids = array[1..8, 1..15] of TLabel;

const MAXCOLS : Integer = 8 ;
const MAXROWS : Integer = 15 ;

-------- proceduuri ----
var row, column, count : integer;
Top, Left : integer;
Grids : TGrids;
tmp : TLabel;
begin

Left := 0; Top := 0; count := 0;

for row := 1 to MAXROWS do
begin
for column := 1 to MAXCOLS do
begin
Inc(count);
tmp :=Grids[column,row].Create(nil);
with tmp do
begin
Parent := Panel1;
Name := 'Grid'+IntToStr(count);
... jne.

Erkki Latomaa

unread,
Nov 23, 2009, 7:38:07 PM11/23/09
to

Vastaanpa itse itselleni jos vaikka jotakuta asia kiinnostaa.
Että miksikö näin... datamatriisissa sama struktuuri, joten
synkronointi TLabel komponentteihin käy vaivattomasti! (Koodikin
lyheni "huomattavasti")
esittely :
const
MAXCOLS = 8 ;
MAXROWS= 15 ;

type
TGrids = array[1..MAXCOLS , 1..MAXROWS] of TLabel;

=> var Grids : TGrids; // Ylös, pois paikallisesta proceduurista

TLabel objektien luonti:
count := 0;
for row := 1 to 15 do
begin
for column := 1 to 8 do
begin
Inc(count);
=> Grids[column,row] := TLabel.Create(Panel1);
with Grids[column,row] do


begin
Parent := Panel1;
Name := 'Grid'+IntToStr(count);

Transparent := false;
jne....

Vesa Lappalainen

unread,
Nov 25, 2009, 12:48:30 PM11/25/09
to
Erkki Latomaa <oh...@yahoo.se> wrote:
> tmp :=Grids[column,row].Create(nil);

Muista se omistaja!

Sitten
tmp := TLabel.Create(self);
Grids[column,row] := tmp;
tmp.Parent := ....
jne...

Vesa

Erkki Latomaa

unread,
Dec 6, 2009, 8:31:12 PM12/6/09
to

Juuri noinhan se piti mennä... tmp tarpeeton joten koodi on nyt aika
siisti.

Tämä olikin yllättävä löytö! TLabel komponentti on tuskin kovinkaan
arvostettu ja käytetty "normaalin" käytön ulkopuolella.
Yksinkertaisen TStringGrid komponentin korvaajana tällainen
komponenttimatriisi on todella käyttökelpoinen. TLabel'in
ominaisuuksista mm.Transparenssi, taustaväri, kirjaisinväri / tyyli,
tagi, ym. tekevät siitä mielestäni käyttökelpoisen! En sitten tiedä,
mitä mieltä muut ovat?
Kunhan vielä saisi raamin ominaisuuksineen ympärille (BorderStyle),
niin vielä parempi.
Eki

0 new messages