Autor Beitrag
jojo1991
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Do 01.03.07 20:00 
Hallo
Ich brauche für ein Programm einen Button,der solange wahr ist wie man ihn mit der Maus gedrückt hält.Geht das mit dem normalen Button oder ist das ein Spezialelement.
vielen Dank
Jojo
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Do 01.03.07 20:05 
Die wohl einfachste Lösung wäre das ganze mit einer (mir ehrlich gesagt unlieben) globalen Variable zu lösen:
Beim Buttonklick, sprich OnMouseDown, ist deine Variable TRUE und beim loslassen des Button, OnMouseUp, wird sie wieder FALSE.

Mfg
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Do 01.03.07 20:36 
Hallo,

vermute mal, das solange der Button gedrückt ist, soll etwas ausgeführt werden.
Wenn ich da richtig liege, dann kann das in etwa so aussehen(völlig sinnfrei):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
function Incrementiere: Integer;
var i : integer;
begin
  result := 0;
  while GetAsyncKeyState(VK_LBUTTON) <> 0 do//solage Maustaste gedrückt
    begin
    inc(result);
    end;
end;

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  showmessage('Maustaste losgelassen bei  : '+IntToStr(Incrementiere));
end;

Dann ist die gedrückte Maustaste die globale Variable :wink:

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )