unit uMessageTest;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data;
type
frmMessageTest =
class(System.Windows.Forms.Form)
{$REGION 'Vom Designer verwalteter Code'}
strict private
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
Components: System.ComponentModel.Container;
Dummy: System.Windows.Forms.
Label;
/// <summary>
/// Erforderliche Methode zur Unterstützung des Designers -
/// ändern Sie die Methode nicht mit dem Quelltext-Editor
/// </summary>
procedure InitializeComponent;
procedure frmMessageTest_Activated(sender: System.
Object; e: System.EventArgs);
procedure Dummy_Click(sender: System.
Object; e: System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Ressourcen nach der Verwendung bereinigen
/// </summary>
procedure Dispose(Disposing: Boolean);
override;
private
{ Private-Deklarationen }
public
constructor Create;
end;
TMyLabel = System.Windows.Forms.&
Label;
var
MyLabel : TMyLabel;
LabelArray :
array[1..5,1..6]
of TMyLabel;
[assembly: RuntimeRequiredAttribute(TypeOf(frmMessageTest))]
implementation
{$AUTOBOX ON}
{$REGION 'Vom Windows Form-Designer erzeugter Code'}
/// <summary>
/// Erforderliche Methode zur Unterstützung des Designers --
/// ändern Sie die Methode nicht mit dem Quelltext-Editor
/// </summary>
procedure frmMessageTest.InitializeComponent;
begin
Self.Dummy := System.Windows.Forms.
Label.Create;
Self.SuspendLayout;
//
// Dummy
//
Self.Dummy.Location := System.Drawing.Point.Create(24, 24);
Self.Dummy.
Name := '
Dummy';
Self.Dummy.TabIndex := 0;
Self.Dummy.Text := '
Dummy';
Self.Dummy.Visible := False;
Include(Self.Dummy.Click, Self.Dummy_Click);
//
// frmMessageTest
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 15);
Self.ClientSize := System.Drawing.Size.Create(688, 568);
Self.Controls.Add(Self.Dummy);
Self.
Name := '
frmMessageTest';
Self.Text := '
MessageTest';
Include(Self.Activated, Self.frmMessageTest_Activated);
Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure frmMessageTest.Dispose(Disposing: Boolean);
begin
if Disposing
then
begin
if Components <>
nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor frmMessageTest.Create;
begin
inherited Create;
//
// Erforderlich für die Unterstützung des Windows Forms-Designers
//
InitializeComponent;
//
// TODO: Fügen Sie nach dem Aufruf von InitializeComponent Konstruktorcode hinzu.
//
end;
procedure frmMessageTest.Dummy_Click(sender: System.
Object; e: System.EventArgs);
var
i,j : integer;
begin
if Sender
is &
Label
then (Sender
as &
Label).BackColor := System.Drawing.Color.Red;
////////////////////////////////////////////////////////////////////////////
// Hier passiert's: nach
MessageBox.Show('
TEST!');
// wird das nicht mehr ausgeführt:
for i := 1
to 5
do
for j := 1
to 6
do
if (i = 3)
AND (j = 3)
then LabelArray[i,j].Text := '
OK';
// und das wird wieder ausgeführt:
Self.BackColor := System.Drawing.Color.LightBlue;
end;
procedure frmMessageTest.frmMessageTest_Activated(sender: System.
Object;
e: System.EventArgs);
var
i,j,n : integer;
begin
n := 0;
for i := 1
to 5
do
for j := 1
to 6
do
begin
inc(n);
MyLabel := System.Windows.Forms.&
Label.Create;
With MyLabel
do
begin
Height := 30;
Width := 30;
Left := 10 + i*40;
Top := 10 + j*40;
Text := n.ToString;
BackColor := System.Drawing.Color.White;
end;
Self.Controls.Add(MyLabel);
LabelArray[i,j] := MyLabel;
Include(LabelArray[i,j].Click, Self.Dummy_Click);
end;
end;
end.