Autor Beitrag
whitef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 202
Erhaltene Danke: 1

Windows X
Delphi XE X
BeitragVerfasst: Fr 02.02.07 22:34 
hi, ich wollte mal hier nachfragen wie ich den eine Form mittels der ESC Taste beenden/schliessen kann.

ich habe schon folgendes ausprobiert:

ausblenden Delphi-Quelltext
1:
2:
type
procedure FormKeyPress(Sender: TObject; var Key: Char);

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if (Key = #27then
  begin
    close
    end;


und im Objektfenster in der der Form habe ich "KeyPreview" auf "TRUE" gesetzt.

Allerdings passiert bei meinem programm nichts. Es schliesst sich einfach nicht... könnt ihr mir da weiterhelfen?


grEEtz whiteF
Clemens L.
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 158

Win Xp SP3
D6 Enterprise, Turbo Delphi Explorer
BeitragVerfasst: Fr 02.02.07 22:37 
ausblenden Delphi-Quelltext
1:
if key = #27 then Close;					


So gehts bei mir!
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 02.02.07 22:45 
Oder...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key=VK_ESCAPE then Form1.Close; //Schließen wenn Escape gedrückt
end;

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
whitef Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 202
Erhaltene Danke: 1

Windows X
Delphi XE X
BeitragVerfasst: Fr 02.02.07 23:38 
Titel: kein erfolg
mh, sorry jungs, kann leider eben nach prüfung kein erfolg feststellen... muss ich den noch irgendetwas besonderes deklarieren?
insgesamt hab ich 6 forms... diese sind allerdings nicht aktiv bzw. geöffnet, muss ich dort auch was einstellen/einfügen?

i dont know!
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Fr 02.02.07 23:40 
Stell im ObjectInspector die Eigenschaft "KeyPreview" von der Form auf true. Wenn es die nicht gibt, musst du uns deine Delphiversion sagen ;)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
whitef Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 202
Erhaltene Danke: 1

Windows X
Delphi XE X
BeitragVerfasst: Fr 02.02.07 23:44 
oh ja sorry, ich vergass... ich habe delphi 7...

dass habe ich in der ersten Form auf True gesetzt... das müsste ja reichen, will ja schliesslich erstmal die eine form mittels ESC beenden.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Fr 02.02.07 23:46 
KeeyPreview sorgt dafür, dass die Tastendrücke nicht in komponenten, die grad den Fokus haben, verloren gehn. Wenn du ein Edit angeklickt hast, würde nix passieren, ohne Keypreview. Wenn aber eine andere Form den Fokus hat, dann musst du das KeyDown event auch bei dieser Form einfügen und KeyPreview auf True setzen.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
whitef Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 202
Erhaltene Danke: 1

Windows X
Delphi XE X
BeitragVerfasst: Fr 02.02.07 23:49 
nene is keine andere form offen bzw. aktiv. nur die eine in der ich all das was oben genannt wurde shcon eingefügt wurde.

ich verzweifle echt...
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Fr 02.02.07 23:53 
user profile iconwhitef hat folgendes geschrieben:
nene is keine andere form offen bzw. aktiv. nur die eine in der ich all das was oben genannt wurde shcon eingefügt wurde.

ich verzweifle echt...
Bei mir gehts.. Häng doch mal das Projekt an.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
whitef Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 202
Erhaltene Danke: 1

Windows X
Delphi XE X
BeitragVerfasst: Sa 03.02.07 00:08 
ok... vielen dank schonmal im vorraus dass du dir das ansehen möchtest...
hab mal zip genommen, weiss net ob du/ihr rar habt...


datei anbei
Einloggen, um Attachments anzusehen!
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 03.02.07 00:11 
Der Eventhandler ist nicht mit der Prozedur verbunden. Einmal im Objektinspektor unter Ereignisse auf onKeyPress doppelklicken, fertig ;)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
whitef Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 202
Erhaltene Danke: 1

Windows X
Delphi XE X
BeitragVerfasst: Sa 03.02.07 00:17 
ah meine fresse.... :D

ich muss euch echt danken... ich hoffe diese kleinen dummen patzer werden mir nicht mehr vorfallen...
ich entschuldige mich hiermit mal aufrichtig dass ich euch hierdurch die zeit geraubt habe...


:CLOSE:
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 03.02.07 00:22 
Solche Patzer passieren jedem mal ;)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.