Autor Beitrag
Michrael
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mi 30.05.07 18:36 
Hallo zusammen,
ich hab ein Problem und zwar schreibe ich Morgen (31.05.07) eine Informatik-Klausur und weiß nicht, wie man es bei einem einfachen Programm, das Icons bei einem Klick auf einen Button sichtbar macht und beim Klick auf einen anderen Button andere Icons sicht bar macht.

Das Programm heißt Tag 1 und besteht aus zwei Schaltern und einem Sichtfeld. Beim Klick auf dem ersten Button "Tag" werden Sonne und Wolken angezeigt und beim Klick auf den zweiten Button "Nacht" der Mond und ein Blitz.
Die Icons habe ich eingefügt und auch die einstellungen mit "visible" habe ich korrekt ausgeführt und beim Klicken auf die Buttons werden die richtigen Icons angezeigt, aber wie schaffe ich es, dass nicht beim Start des Programmes ALLE eingefügten Icons sichtbar sind sondern nur die für Tag?

Hier ist der Quelltext, ich wäre dankbar, wenn ihr mir schnell antworten könntet!


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:
59:
60:
61:
62:
63:
64:
65:
66:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TForm1B = class(TForm)
    BtTag: TButton;
    BtNacht: TButton;
    Image1: TImage;
    ImMond: TImage;
    ImHund: TImage;
    ImSonne: TImage;
    ImWolke2: TImage;
    ImWolke3: TImage;
    ImWolke1: TImage;
    ImWolke4: TImage;
    ImWolke5: TImage;
    ImBlitz: TImage;
    procedure BtTagClick(Sender: TObject);
    procedure BtNachtClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1B: TForm1B;

implementation

{$R *.DFM}

procedure TForm1B.BtTagClick(Sender: TObject);
begin
ImSonne.visible :=true;
ImWolke1.visible :=true;
ImWolke2.visible :=true;
ImWolke3.visible :=true;
ImWolke4.visible :=true;
ImWolke5.visible :=true;
ImHund.visible :=true;
ImMond.visible :=false;
ImBlitz.visible :=false;
Form1B.color :=clBlue
end;

procedure TForm1B.BtNachtClick(Sender: TObject);
begin
ImSonne.visible :=false;
ImWolke1.visible :=true;
ImWolke2.visible :=false;
ImWolke3.visible :=true;
ImWolke4.visible :=true;
ImWolke5.visible :=true;
ImHund.visible :=false;
ImMond.visible :=true;
ImBlitz.visible :=true;
Form1B.color :=clBlack;
end;

end.


Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Moderiert von user profile iconTino: "Hilfe" und "Panik" aus Titel entfernt.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 30.05.07 18:40 
Bitte benutze die Delphi-Tags. [delphi] [/delphi]
Zu deinem Problem:

Schau dir mal das OnCreate-Event deiner Form an.
Der Code, der im OnCreate steht, wird ausgeführt, wenn das Programm startet.
Heißt ja auch "on create" bzw. "beim Erstellen".

Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormCreate(Sender: TObject);
begin
 // dein code
end;

Ich denk, das sollte dir weiter helfen. ;)

grüße


//edit: Die Delphi-Tags funktionieren nicht mehr?
... wgn dem beispiel, ja :lol:
Michrael Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mi 30.05.07 19:36 
Titel: DANKE !!!!!!!
Vielen Dank für die schnelle Hilfe, aber jetzt hab ich nur leider das Problem, dass ich mir die Programmvorschau micht mehr ansehen kann und auch das Compilieren funktioniert nicht mehr.
Entweder sind die Schaltflächen grau hinterlegt, oder wenn ich die Datei über "Datei-> öffnen" öffne wird im Programmfenster nur grau angezeigt und beim Compilieren Passiert gar nichts....was jetzt???
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 30.05.07 19:46 
Dann hast du was falsch gemacht. :shock:
Zeig doch mal bitte deinen Code. ;)
Michrael Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mi 30.05.07 19:52 
Der Code ist der selbe wie oben ich hab noch nix verändert
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 30.05.07 20:15 
Hast du die Pas- anstelle der DCU-(Projekt)datei geöffnet?
Stefan-W
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mi 30.05.07 20:19 
vllt hat er statt dem gesammten Projekt nur die Formular *.Pas geladen
Michrael Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mi 30.05.07 20:37 
Es hat geklappt,
ich hab wirklich die Pas-Datei geöffnet, hätte aber die DPR- Datei öffnen müssen.
Ich hab das jetzt in "OnCreate" geändert und es funktioniert! :D

Ich danke euch vielmals, für die schnelle Hilfe, war echt super nett von euch D A N K E ! ! ! ! ! ! :)
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 30.05.07 20:42 
Kein Problem, das machen wir doch gerne. :)
Viel Glück morgen. ;)

grüße
Stefan-W
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mi 30.05.07 20:46 
ich wünsch dir auch viel Glück.