Autor Beitrag
theTJ
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 43

WIN XP: SP1
D7 enterprise
BeitragVerfasst: Mo 18.04.05 21:14 
hi@all

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:
unit Unit1;

interface

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

type
[...]
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zeit:Integer;

implementation

{$R *.dfm}

[...]

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
  zeit:=30000
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  timer1.Create();
end;

end.


Ich habe ein problem, und zwar möchte ich der Variable "Zeit" beim Click auf einen der RadioButtons ein Intervall zuweisen, dass beim click auf den Button2 ausgelößt wird und daach ein Signal(-Ton oder -Dialog) ausgibt...

ich hoffe ihr versteht was ich meine.

ich bin noch n ziehmlicher newbe obwohl ich schon seit 2Jahren immer mal wierder mit Delphi rumbastle... :oops:

_________________
theTJ
"Die Antwort auf die Frage nach dem Leben, dem Universum und dem ganzen Rest ist 42, aber was ist die Frage genau?" aus "Per Anhalter durch die Galaxis" von Douglas Adams
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Mo 18.04.05 21:24 
ausblenden Delphi-Quelltext
1:
Timer1.Interval:=30000;					
theTJ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 43

WIN XP: SP1
D7 enterprise
BeitragVerfasst: Mo 18.04.05 21:57 
Das ist nicht ganz was ich suche ich will erstmal ein bestimmtes Intervall in die Variable Zeitschreiben, und dieses dann an den timer übergeben...

aber das ist ein guter Ansatz - danke

[EDIT]

Mei neuer Code sieht jetzt so aus:
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:
unit mainfrm;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    Button2: TButton;
    Button3: TButton;
    Timer1: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zeit:Integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  close;
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
  zeit:=30000
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Timer1.Interval:=zeit;
  Timer1.Create;
{wie aktiviere ich hier den timer und löse danach:
begin
  beep beep
end;
      aus?}

end;

end.


nur ist da immernoch ein Fehler drin...

_________________
theTJ
"Die Antwort auf die Frage nach dem Leben, dem Universum und dem ganzen Rest ist 42, aber was ist die Frage genau?" aus "Per Anhalter durch die Galaxis" von Douglas Adams
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Mo 18.04.05 22:35 
Timer1.Enabled:=true;
in den Timer
Beep;
xasx
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 34

WinXP Pro, Win 2k3 ServEnt
D2k5 PE, VS 2005
BeitragVerfasst: Mo 18.04.05 22:51 
Die Methode, die ausgelöst wird, wenn der Timer sein Signal gibt, erstellst du automatisch, indem du auf den Timer doppelt klickst. Da kannst du nach Herzenslust rumbeepen. :D
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Mo 18.04.05 22:53 
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:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Timer1.Enabled:=true;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Timer1.Enabled:=false;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  If RadioButton1.Checked= true then Beep;
  If RadioButton2.Checked= true then Beep;
  If RadioButton3.Checked= true then Beep;
  If RadioButton4.Checked= true then Beep;
  If RadioButton5.Checked= true then Beep;
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
  Timer1.Interval:=1000;
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
  Timer1.Interval:=2000;
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
  Timer1.Interval:=3000;
end;

procedure TForm1.RadioButton4Click(Sender: TObject);
begin
  Timer1.Interval:=4000;
end;

procedure TForm1.RadioButton5Click(Sender: TObject);
begin
  Timer1.Interval:=5000;
end;

end.
theTJ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 43

WIN XP: SP1
D7 enterprise
BeitragVerfasst: Di 19.04.05 13:49 
Danke erst mal,

@xasx: das wusste ich auch schon vorher :wink:
@Blackheart: könntest du mir erklären was es mit dem SC auf sich hat?? - meinst du, dass ich über diese IFs jeder Zeit ein eigenes Signal zuweisen könnte oder?

eine Frage hätt ich noch welches Intervall entspricht 5(10/15/30/60)Minuten?

_________________
theTJ
"Die Antwort auf die Frage nach dem Leben, dem Universum und dem ganzen Rest ist 42, aber was ist die Frage genau?" aus "Per Anhalter durch die Galaxis" von Douglas Adams
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Di 19.04.05 13:57 
5 Min = 5*60*1000 = 300000
10 Min = 10*60*1000 = 600000 usw

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
theTJ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 43

WIN XP: SP1
D7 enterprise
BeitragVerfasst: Di 19.04.05 14:08 
Danke, ich hab beim rechnen wohl nen Tippfehler gemacht mir fehlte eine null...

_________________
theTJ
"Die Antwort auf die Frage nach dem Leben, dem Universum und dem ganzen Rest ist 42, aber was ist die Frage genau?" aus "Per Anhalter durch die Galaxis" von Douglas Adams
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Di 19.04.05 14:36 
Ich weiß nicht genau was du meinst ich hoffe das.
Verschiedene Töne.
Also If RadioButton1.Checked=true then Windows.Beep(750,100);
Bsp.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
var
Frequenz,Dauer:Integer;
begin
Frequenz:=StrToInt(Edit1.Text);
Dauer:=StrToInt(Edit2.Text);
Windows.Beep(Frequenz,Dauer);
end;
theTJ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 43

WIN XP: SP1
D7 enterprise
BeitragVerfasst: Do 21.04.05 17:09 
@Blackheart danke erstmal,

ich hätt jetzt noch ein kleines Problem, das hat zwar nicht mehr mit dem Ausgangsproblem zutun, aber es ist eine erweiterung.

Zur Zeit sieht der Code so aus:
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:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
unit mainfrm;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    Button2: TButton;
    Button3: TButton;
    Timer1: TTimer;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure RadioButton3Click(Sender: TObject);
    procedure RadioButton4Click(Sender: TObject);
    procedure RadioButton5Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zeit:Integer;
  Periode:String;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  close;
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
  Zeit:=300000;
  Periode:='5Min'
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
   Zeit:=600000;
   Periode:='10Min'
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
  Zeit:=900000;
  Periode:='15Min'
end;

procedure TForm1.RadioButton4Click(Sender: TObject);
begin
  Zeit:=1800000;
  Periode:='30Min'
end;

procedure TForm1.RadioButton5Click(Sender: TObject);
begin
  Zeit:=3600000;
  Periode:='60Min'
end;

procedure TForm1.Button2Click(Sender: TObject);

begin
 Timer1.Interval:=zeit;
 Timer1.Enabled:=true;
  
 Label1.Caption:= Periode
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  If RadioButton1.Checked= true then beep;
  If RadioButton2.Checked= true then Beep;
  If RadioButton3.Checked= true then Beep;
  If RadioButton4.Checked= true then Beep;
  If RadioButton5.Checked= true then Beep;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Timer1.Enabled:=false;
end;

end.


Es geht darum, dass die Prozedur des Button2 in einer Schleife ausgefuhrt werden soll, solange bis auf button3 gedrückt wird oder was ich mir auch vorstellen könnte, dass am ende der schelefe eine MessageBox geöffnet wird die [ok] und [abrechen]-Buttons hat. :arrow: auf abrechen wird die schleife beendet.

[EDIT]Das Problem ist warscheinlich, dass das ende der Schleife in der Timer Prozedur steht...[/EDIT]

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt.
Einloggen, um Attachments anzusehen!
_________________
theTJ
"Die Antwort auf die Frage nach dem Leben, dem Universum und dem ganzen Rest ist 42, aber was ist die Frage genau?" aus "Per Anhalter durch die Galaxis" von Douglas Adams
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Do 21.04.05 18:06 
Versteh nicht ganz was du meinst wenn der Timer an ist läuft er doch sozusagen in einer Schleife bis du ihn ausstellst.
Beschreib mal näher was du vorhast, was passieren soll wenn ?
theTJ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 43

WIN XP: SP1
D7 enterprise
BeitragVerfasst: Do 21.04.05 18:22 
Nach dem Beep bzw. der Messagebox soll der Timer wieder neu gestartet werden

_________________
theTJ
"Die Antwort auf die Frage nach dem Leben, dem Universum und dem ganzen Rest ist 42, aber was ist die Frage genau?" aus "Per Anhalter durch die Galaxis" von Douglas Adams
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Do 21.04.05 18:48 
Hier mal ein bsp.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Timer1.Enabled:=true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled:=false;
  Beep;
   if MessageDlg('Möchtest Du den Timer erneut starten ?', mtConfirmation,[mbYes, mbNo], 0) = mrYes
  then
  Timer1.Enabled:=true;
 end;
end.