Autor Beitrag
roka6803
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50


Delphi 5 Ent. & Delphi 7
BeitragVerfasst: Di 13.09.05 20:29 
Hallo alle zusammen,

ich habe ein Problem mit dem erschaffen einer Klasse. Ich habe eine (einige) Form mit einer ProgressBar und einem Label das nach je einem "Step" der ProgressBar seine Caption wechselt. Das funzt auch. Nachdem alle zehn Steps und damit alle zehn Captions durch die For-Do-Schleife "durchgelaufen" sind, wird dieser Vorgang gestoppt.

Dann sollen drei Instanzen einer eigenen Tochterklasse von TLabel erzeugt werden, die relativ mittig in der Form (387x640 (ClientHeight bzw. ClientWidth)) eine Art Menü ergeben.

Dabei soll jedes erzeugt Label gleich breit und ohne Autosize sowie Hintergrundtransparenz und einer eigenen Caption ausgestattet sein.

Ausserdem soll es möglich sein, das man jedes einzelne Label anklicken kann um eine neue modale Form anzeigen zu lassen.

Wie aber muss ich nun die "Tochterklasse" von TLabel deklarieren (mit type, private, public, protected und wie das alles heisst), und wie kann ich dann anhand der Deklaration die drei Label erzeugen, nachdem die For-Do-Schleife durchlaufen wurde ?

Hier mein aktueller (gekürzter) Quelltext der einzigen Form meines Projekts:

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:
53:
54:
55:
56:
57:
58:
interface

uses
  ...

type
  Tform_....



var
  form_loading_screen: Tform_loading_screen;
             ......

implementation

{$R *.DFM}

procedure Tform_loading_screen.FormCreate(Sender: TObject);
begin

Image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName)+'\gfx\bild_8.jpg');

loading_boolean := true;
end;

procedure Tform_loading_screen.Image1MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var i,n : integer;
begin

if loading_boolean = true then
        begin

        n := 10;

        loading_status[1] .......


        for i := 0 to n - 1 do
           begin
           loading_status_count := i+1;
           Label2.Caption := (loading_status[loading_status_count]);
           label2.Refresh;
           sleep(400);
           loading_progress.StepIt;
           sleep(400);
           end;

        loading_boolean := false;

//-------HIER!!!!!!!!!!!!! An dieser Stelle sollen drei labels anhand der neu erzeugten klasse erzeugt werden

        close;
        end;
end;

end.


Habt vielen Dank im Vorraus für die Hilfe und die hoffentlich vielen Antworten

MfG GtA roka6803

_________________
Signatur? Was ist das? Brauch ich nicht...
ManuelGS
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 173

Win XP HE, Suse Linux
D6, D7, D2005 Personal
BeitragVerfasst: Di 13.09.05 21:29 
Naja, das wird glaub kein Problem sein, das zu realisieren.
Such im Forum mal nach "Komponenten zur Laufzeit erstellen" o.Ä.

_________________
"Leben ist gänzlich Bühne und Spiel; so lerne denn spielen
und entsage dem Ernst - oder erdulde das Leid." - Palladas von Alexandria
Grishnak
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 221

Windows XP Home
Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Di 13.09.05 22:58 
ein paar Fragmente:

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:
type
  TForm1 = class(TForm)
    [...]
    procedure LabelClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    MenuLabel: array[0..2] of TLabel;
  end;

[...]

TForm1.FormShow    
var
  i: integer;
begin
  for i:=0 to 2 do
    begin
      MenuLabel[i]:=TLabel.Create(self);
      MenuLabel[i].Parent:=self;
      with MenuLabel[i] do
        begin
          Top:=20+i*16;
          Left:=100;
          Caption:='Menüpunkt '+IntToStr(i);
          Tag:=i;
          OnClick:=Form1.LabelClick;
        end; // with
    end; // for
end;

[...]

procedure TForm1.LabelClick(Sender: TObject);
begin
  ShowMessage('Menu-Label Nr. '+IntToStr((Sender as TLabel).Tag)+' gedrückt!');
end;


Hilft dir das weiter?

_________________
Mach' etwas idiotensicher und irgendjemand erfindet einen besseren Idioten!