Autor Beitrag
SpeedyFighter1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: So 14.05.06 18:21 
Huhu,

weiß jmd. wie man in ein "ShowMessage" oder dgl. ein Bild mit laden kann.

Desweiteren sollte das Fenster, was durch "ShowMessage" geöffnet wird, keinen Button besitzen, aber nach einer bestimmten Zeit wieder verschwinden und das Script weiter ausgeführt werden.
Wäre nett, wenn mir da jmd. helfen könnte ;)

Schon mal Danke im Vorraus.

mfg SpeedyFighter1

Moderiert von user profile iconTino: Titel erweitert
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: So 14.05.06 18:30 
Hallo
so wie sich das anhört willst du ein Info-Fenster beim Start anzeigen lassen.
Nimm eine Form ,BorderStyle auf bsDialog, FormStyle auf StayOnTop,
bei der Gestaltung kannst du deiner Fantasie freien lauf lassen.
Jetzt noch ne Timer Komponente auf die Form mit Intervall = 5000 (=5 sek)
und in das OnTimer Ereigniss:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Hide;Free
end;


Gruß

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Do 18.05.06 16:27 
könntest du mir den Quelltext nochmal komplett hinschreiben ?
wäre echt nett...danke
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Do 18.05.06 19:17 
Den Quelltext für die Timerkomponente hab ich dir schon geschrieben(Siehe weiter oben)

alles andere kannst du im Objektinspektor einstellen

im OI
für das Formular:
[highlight]BorderStyle = bsDialog
FormStyle= StayOnTop[/highlight]

Für die Timer Komponente:
Intervall = 5000

Gruß

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Fr 19.05.06 20:37 
Okay...nun hab ich aber mal noch ne andere Frage :)

Wenn ich ne Form2 in den uses part der Form1 eintrage und dann das Prog starte, läd der automatisch gleich am Anfang die Form2, obwohl ich die ja noch nirgends aufgerufen haben.
Wäre nett, wenn mir da jmd. helfen könnte ... ;)

Mfg SpeedyFighter1
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Sa 20.05.06 12:03 
Setze mal im OI bei form2 visible:=False
gruß

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Sa 20.05.06 14:17 
noch eine Frage ... :)

Wie geht das, wenn ich vom HauptFenster (MainForm) eine Variable an die Form2 übergeben haben möchte ?

Danke nochmal ;)

mfg SpeedyFighter1
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Sa 20.05.06 15:54 
Deklariere die Variable in dem Public Abschnitt deiner MainForm
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  private
    { Private-Deklarationen }
  public
  DeineVariable:String;
    { Public-Deklarationen }
  end;

Jetzt mußt du in unit2 (Form2) die UnitMain (MainForm) einbinden.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
implementation

uses UnitMain;
{$R *.dfm}


Der Aufruf in Form2 ist dann:
ausblenden Delphi-Quelltext
1:
2:
  
FormMain.DeineVariable;

Gruß

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Sa 20.05.06 17:49 
Ok...wie kann ich eine ganze Prozedur mit dem Form2 aus dem MainForm aufrufen ?

Danke!!!

mfg SpeedyFighter1
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Sa 20.05.06 18:02 
Als erstes mal nen bischen darüber nachdenken über das was ich bisher gepostet habe. :evil:

Dann nach kurzem überlegen darauf kommen das man wieder die Unit aus der man was aufrufen will einbinden muß
und dann immer vor der aufzurufenden Procedure das entsprechende Form setzen e.g.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm3.Button1Click(Sender: TObject);
begin

Form1.Button1Click(self);
end;

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Sa 20.05.06 19:27 
Hatte ich mir schon gedacht, aber da kam irgendwie ein Fehler ...
----

Wenn ich in meinem "Quiz" (Haupt-Form) der public Variable 'correct' der "Info" (Neben-Form) einen Wert zuweise und den dann in beiden Forms ausgeben lassen, kommen unterschiedliche Inhalte raus.

Quelltext der Quiz-Form:
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:
unit quizUnit;

interface

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

type
  TQuiz = class(TForm)
    AntwortAuswahl: TRadioGroup;
    lfrage: TLabel;
    Bweiter: TButton;
    ltest: TLabel;
    procedure BweiterClick(Sender: TObject);
  private
    { Private-Deklarationen}
  public
  
  end;

var
  Quiz: TQuiz;

implementation

{$R *.DFM}

...

procedure TQuiz.BweiterClick(Sender: TObject);
    begin
         if AntwortAuswahl.ItemIndex=richtiges_ergebnis then begin
                                                              Info.correct:=1;
                                                              ltest.caption:=inttostr(Info.correct);
                                                             end
                                                        else begin
                                                              Info.correct:=0;
                                                              ltest.caption:=inttostr(Info.correct);
                                                             end;
         Info.show;
    end;
end.


Quelltext der Info-Form:
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:
unit infoUnit;

interface

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

type
  TInfo = class(TForm)
    lausgabe: TLabel;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen}
  public
  correct:integer;
  end;

var
  Info: TInfo;

implementation

{$R *.DFM}

procedure TInfo.FormCreate(Sender: TObject);
   begin
    lausgabe.caption:=(inttostr(correct));
   end;

end.


Wenn ich das Programm starte und ich es so mache, dass der Fall "AntwortAuswahl.ItemIndex=richtiges_ergebnis" in Kraft tritt, wird in dem Label "ltest" des Quiz-Forms die richtige Zahl für die Variable correct, nämlich "1", ausgegeben.
Im Label "lausgabe" des Info-Forms jedoch wird immer nur "0" als Inhalt der Variable correct ausgegeben.

Wäre nett, wenn du mir da nochmal helfen könntest.
Danke!!!

Mfg SpeedyFighter1
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Sa 20.05.06 20:02 
Das ist auch richtig so
weil du in der InfoUnit das Label schon beim erstellen des Formulares (TInfo.Create) anzeigen lässt
und da ist nun mal Correct noch 0
der Variablen wird ja erst ein wert zugewiesen wenn Antwort gleich richtig ist
aber da wurde ja das Label in der InfoForm schon angezeigt.

versuch mal folgendes:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TQuiz.BweiterClick(Sender: TObject);   
    begin   
         if AntwortAuswahl.ItemIndex=richtiges_ergebnis then begin   
                                                              Info.correct:=1;   
                                                              ltest.caption:=inttostr(Info.correct);
                                                              TInfo.lAusgabe.Caption:=(inttostr(Info.correct));
                                                             end   
                                                        else begin   
                                                              Info.correct:=0;   
                                                              ltest.caption:=inttostr(Info.correct); 
                                                              TInfo.lAusgabe.Caption:=(inttostr(Info.correct));  
                                                             end;   
         Info.show;   
    end;

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Sa 20.05.06 20:49 
ich habs mal ausprobiert und es erscheint mir auch logisch, so wie du es erklärt hast, aber der bringt jetzt immer eine Fehlermeldung..."Methodenbezeichner erwartet" und dabei verweist er auf "lAusgabe".

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TQuiz.BweiterClick(Sender: TObject);   
    begin   
         if AntwortAuswahl.ItemIndex=richtiges_ergebnis then begin   
                                                              Info.correct:=1;   
                                                              ltest.caption:=inttostr(Info.correct);
                                                              TInfo.lAusgabe.Caption:=(inttostr(Info.correct));
                                                             end   
                                                        else begin   
                                                              Info.correct:=0;   
                                                              ltest.caption:=inttostr(Info.correct); 
                                                              TInfo.lAusgabe.Caption:=(inttostr(Info.correct));  
                                                             end;   
         Info.show;   
    end;
Watsch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 97

Win98 SE
D3 Prof, D4 C/S
BeitragVerfasst: Sa 20.05.06 20:57 
user profile iconSpeedyFighter1 hat folgendes geschrieben:
ich habs mal ausprobiert und es erscheint mir auch logisch, so wie du es erklärt hast, aber der bringt jetzt immer eine Fehlermeldung..."Methodenbezeichner erwartet" und dabei verweist er auf "lAusgabe".


Versuchs mal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TQuiz.BweiterClick(Sender: TObject);   
begin   
  If AntwortAuswahl.ItemIndex=richtiges_ergebnis Then 
    begin   
    Info.correct := 1;   
    ltest.caption := IntToStr(Info.correct);
    Info.lAusgabe.Caption := IntToStr(Info.correct));
    end   
  else 
    begin   
    Info.correct := 0;   
    ltest.caption := IntToStr(Info.correct); 
    Info.lAusgabe.Caption := IntToStr(Info.correct);  
    end;   
  Info.show;   
end;
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Sa 20.05.06 21:04 
Danke !!!!!!!!!

Es geht ;)
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Sa 20.05.06 21:17 
Ja Stimmt mein Fehler....man sollte nicht so viel mit copy und Paste arbeiten :wink:
Gruß

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: So 21.05.06 14:41 
Was müsst ich denn noch für einen Befehl in die If-Schleife einfügen, wenn in dem Info-Form für das jeweilige Ereignis ein Bild angezeigt werden soll.
Also z.b. hab gfx1, was beim Fall AntwortAuswahl.ItemIndex=richtiges_ergebnis angezeigt werden soll und gfx2, was erscheinen soll, wenn der Fall nicht eintritt.

Angenommen ich habe ein TImage Komponente Namens ("Image1") auf dem Info-Form, in der die Bilder dann nach jeweiligen Ereignis angezeigt werden sollen.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TQuiz.BweiterClick(Sender: TObject);   
begin   
  If AntwortAuswahl.ItemIndex=richtiges_ergebnis Then 
    begin   
    Info.correct := 1;   
    ltest.caption := IntToStr(Info.correct);
    Info.lAusgabe.Caption := IntToStr(Info.correct));
    ???....???
    end   
  else 
    begin   
    Info.correct := 0;   
    ltest.caption := IntToStr(Info.correct); 
    Info.lAusgabe.Caption := IntToStr(Info.correct);
    ???....???
    end;   
  Info.show;   
end;
Watsch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 97

Win98 SE
D3 Prof, D4 C/S
BeitragVerfasst: So 21.05.06 15:18 
user profile iconSpeedyFighter1 hat folgendes geschrieben:
Was müsst ich denn noch für einen Befehl in die If-Schleife einfügen, wenn in dem Info-Form für das jeweilige Ereignis ein Bild angezeigt werden soll.
Also z.b. hab gfx1, was beim Fall AntwortAuswahl.ItemIndex=richtiges_ergebnis angezeigt werden soll und gfx2, was erscheinen soll, wenn der Fall nicht eintritt.

Angenommen ich habe ein TImage Komponente Namens ("Image1") auf dem Info-Form, in der die Bilder dann nach jeweiligen Ereignis angezeigt werden sollen.


Zum Beispiel könntest Du es so machen. Du packst 2 Image-Komponenten auf das Info-Formular (Image1 = richtige Antwort, Image2 = falsche Antwort):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TQuiz.BweiterClick(Sender: TObject);   
begin   
  If AntwortAuswahl.ItemIndex=richtiges_ergebnis Then 
    begin   
    Info.correct := 1;   
    ltest.caption := IntToStr(Info.correct);
    Info.lAusgabe.Caption := IntToStr(Info.correct));
    Info.Image1.Visible := True;
    Info.Image2.Visible := False;
    end   
  else 
    begin   
    Info.correct := 0;   
    ltest.caption := IntToStr(Info.correct); 
    Info.lAusgabe.Caption := IntToStr(Info.correct);
    Info.Image1.Visible := False;
    Info.Image2.Visible := True;
    end;   
  Info.show;   
end;


oder Du lädst die Bilder während der Laufzeit (was meiner Meinung nach aber weniger elegant ist):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TQuiz.BweiterClick(Sender: TObject);   
begin   
  If AntwortAuswahl.ItemIndex=richtiges_ergebnis Then 
    begin   
    Info.correct := 1;   
    ltest.caption := IntToStr(Info.correct);
    Info.lAusgabe.Caption := IntToStr(Info.correct));
    Info.Image1.Picture.LoadFromFile('richtig.bmp');
    end   
  else 
    begin   
    Info.correct := 0;   
    ltest.caption := IntToStr(Info.correct); 
    Info.lAusgabe.Caption := IntToStr(Info.correct);
    Info.Image1.Picture.LoadFromFile('falsch.bmp');
    end;   
  Info.show;   
end;


Ich denke, da gibt's noch weitere Möglichkeiten


Zuletzt bearbeitet von Watsch am So 21.05.06 19:13, insgesamt 1-mal bearbeitet
SpeedyFighter1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: So 21.05.06 16:35 
Okay dank dir...das funzt, aber ich bekomms einfach nicht mit dem Timer bzw. Sleep hin...

Ich will ja, dass das Info-Fenster nur 5 Sek. aufbleibt und sich danach dann wieder schließt.
Ich habs jetzt schon mit dem sleep Befehl und einem Timer (Quelltext siehe weiter unten) ausprobiert.
Entweder er öffnet das Info-Fenster für 5 Sek., aber ohne Inhalt, und schließt es auch danach wieder, oder es wird nach 5 Sek ganz kurz geöffnet und im selben moment auch wieder geschlossen.

Wäre nett, wenn ihr mir da nochmal auf die Sprünge helfen könntet.

DANKE!

mfg SpeedyFighter1


Timer Quelltext:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure delay;
var start,stop:LongInt;
    begin
         start:=GetTickCount;
         Repeat begin
                     stop:=GetTickCount;
                     //application.processmessages;
                end;
         Until ((stop - start) >= 5000);
    end;
Watsch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 97

Win98 SE
D3 Prof, D4 C/S
BeitragVerfasst: So 21.05.06 16:54 
Versuch's mal so:

Timer im Objekt-Inspektor Enabled = False setzen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TInfo.FormShow(Sender: TObject);  
begin  
  Timer1.Enabled := True;
end; 

procedure TInfo.Timer1Timer(Sender: TObject);  
begin  
  PostMessage(Self.Handle, WM_CLOSE, 0, 0); 
end;