Autor Beitrag
orakel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92

Win XP

BeitragVerfasst: Mi 22.10.03 21:08 
Durch den folgenden Code werden Memos erstellt. Wie finde ich bei OnClick heraus, in welches Memo geklickt wurde??? :?:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Unit2, Unit3, Unit4,
  Dialogs, Grids, StdCtrls;

type
    TForm1 = class(TForm)
       {...}
    private
    { Private declarations }
    M: array[1..10,1..10] of TMemo;
    procedure MemoClickHandler(Sender: TObject);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Anz,i,j: Integer;
  M: array[1..10,1..10] of TMemo;

implementation

{$R *.dfm}


procedure TForm1.MemoClickHandler(Sender: TObject);
begin
  Form3.show;
//Hier brauche ich die Indizes(i,j) des Memofelds, in das geklickt wurde.
end;



procedure TForm1.Button3Click(Sender: TObject);
begin
Anz:=StringGrid1.RowCount;
For i := 1 to Anz do
begin
 For j:=1 to Anz do
 begin
 M[i,j] := TMemo.Create(Self);
 M[i,j].Parent := Self;
 M[i,j].OnClick:=MemoClickHandler;
 end;
end;
end;

end.


Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.

_________________
Nicht verzagen, orakel fragen!
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mi 22.10.03 21:35 
Hi!

So wie's du jetzt implementiert hast, musst du glaub
TMemo(Sender) mit allen M[i,j] vergleichen, um das i,j zu bekommen.
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mi 22.10.03 21:59 
Du könntest dem memo einen Tag zuweisen (eigenschaft Tag) und das dann auslesen. (z.B. x+y*10)
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 23.10.03 10:22 
Na du gehst einfach das Array durch und prüfst ob Sender das entsprechende Memo ist:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.MemoClickHandler(Sender: TObject);
Var
  LoopI,
  LoopJ: Integer;
Begin
  For LoopI := 1 To 10 Do
    For LoopJ := 1 To 10 Do
      If Sender = M[I, J] Then
       Begin
         { ... }
       End;
End;


Gruß
Tino