Autor Beitrag
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 17.01.06 19:00 
Hallo, angenommen ich habe einen Button, und in der onclick procedur steht inc(myvar); jetzt möchte ich, aber um nicht so oft klicken zu müssen, diesen button gedrückt halten können, sodass das ganze wiederholt wird, wie mache ich das ?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 17.01.06 19:14 
Auf Anhieb fällt mir da ein: Starte im OnMouseDown einen Timer, und im MouseUp stoppst du ihn wieder. Evtl. das OnMouseUp auch für die übrigen Komponenten nehmen, damit der Timer auch deaktiviert wird, wenn man die Maus beim gedrückt halten vom Button wegbewegt...

_________________
We are, we were and will not be.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Di 17.01.06 19:15 
schwerer (und sauberer bla :roll: ) gehts bestimmt, aber recht einfach, z.B. so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
var {global}
 bpressed : boolean = false; // gibt an ob der Button gedrückt ist
 value : integer = 0;


procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
bpressed := true;
 while  bpressed do
  begin
   application.ProcessMessages;
   sleep(50); // um die Geschwindigkeit des aufzählens zu variieren.
   inc(value);
  end;
end;

procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 bpressed := false;
end;


Viel Spass!
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 17.01.06 19:20 
danke, für meine 4 buttons mach ich dann ein array ;)

die aktion wird leider erst ausgeführt, wenn ich den button loslasse, also muss ich nen timer nehmen

Damit gehts super DANKE ;)