Autor Beitrag
Gerhard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Sa 04.10.03 23:40 
Hi,

ich schreibe ein Programm, welches einen weiteren Programmschritt ausführen sollte (Position: If Ord(key)=13 ......) bzw. bei entsprechendem Austieg (Position: If Ord(key) = 27 ...) nach einer Bestätigung (Prozedur Programm_Beenden...) das Programm beenden sollte.


Auszug aus dem Testprogramm:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Procedure Programm_beenden;
begin
  if MessageDLg('Programm benden?',mtConfirmation,[mbNO,MbYes],1)= mrYes then begin
     Form1.close;
  end
end;

procedure TForm1.ListBox1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if ord(key)=13 then begin
       Label1.Caption:='Jetzt wurde die Enter-Taste gedrückt!';
       //bzw. geht es hier zu einer Programmausführung ...
  end;
  if ord(key)=27 then begin
    Label1.Caption:='';
    Programm_beenden;
  end;
end;


Nun meine Problem: Wenn ich bei der Bestätigung für den Ausstieg den NEIN-Button mit ENTER bestätige, wird auch automatisch das Programm (1. Position) gestartet.
Meine Frage: Wie kann den automatischen Programmaufruf verhindern?

Danke Gerhard

Moderiert von user profile iconUGrohne: Delphi-Tags eingefügt
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: So 05.10.03 18:25 
Da du den Key, den du Auswertest anschließend nicht auf #0 setzt, wird deine Anwendung diesen Ausführen.
Du musst
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if Key=#32 then // leertaste 
begin
  ... // your code here
  key:=#0//<--- WICHTIG
end;


schreiben

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Gerhard Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Sa 11.10.03 08:48 
Danke!

Gerhard