Autor Beitrag
covhax
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mo 02.11.09 17:56 
Hi nochmal;D Ich klicke in ein Edit Feld tippe was ein und mit dem unten stehenden Code geschiet dann etwas wenn ich ENTER drücke. Genau dann kommt ein kurzer lauter Sound (habe ihn mal angehängt) durch die Lautsprecher. Hört sich nach einem Windows-Fehler an, es erscheint aber nichts. Delphi 2009 & Win XP.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key = VK_Return then


Woran liegt das und wie kann ich das verhindern?
Danke!

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Einloggen, um Attachments anzusehen!
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: Mo 02.11.09 18:00 
Füge in deine Prozedur noch ein key := 0; ein, dann sollte der Sound verschwinden.

_________________
We are, we were and will not be.
covhax Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mo 02.11.09 18:28 
Habe es einmal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key = VK_Return then
begin
  key := 0;
  edt_Search.text := edit1.text;


und einmal so:


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key = VK_Return then
begin
  edt_Search.text := edit1.text;
  key := 0;


Gemacht. Geht beides nicht :(
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 02.11.09 19:26 
AFAIK besteht das Problem darin, dass das OnKeyPress-Event, welches für den Beep verantwortlich ist, immer vor dem OnKeyDown-Event aufgerufen wird. Wenn meine These korrekt sein sollte, wird dir wohl nichts anderes übrig bleiben, als die Return-Taste (#13) über das OnKeyPress-Event abzufangen. ;)
covhax Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mo 02.11.09 20:12 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
begin
  key:=#0;


Gleiches Problem :(

EDIT: Gelöst :)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
begin
  key:=#0;