Autor Beitrag
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mo 24.08.09 10:04 
Moin,

Neue VCL-Formularanwendung, mit folgdendem Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm3.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then
  begin
    showMessage('Enter');
  end;
end;


Dass die Messagebox erscheint, wenn man Enter drückt ist klar. Aber warum erscheint sie, wenn man STRG + M drückt, und wie kann man das ändern??

Danke,
Jens


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Mo 24.08.2009 um 14:43

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
spawn89
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 82
Erhaltene Danke: 7

Linux
CodeTyphon
BeitragVerfasst: Mo 24.08.09 10:33 
Delphi Hilfe hat folgendes geschrieben:
Verwenden Sie die Ereignisbehandlungsroutine für OnKeyDown oder OnKeyUp, um auf Nicht-ASCII-Tasten oder -Tastenkombinationen zu antworten.

Komisch, dass da auf Enter reagiert wird. Ich würd eh immer das KeyUp-Event verwenden.
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Mo 24.08.09 10:40 
Hi,

im Keyup reagiert er nicht mehr auf Strg + M.
Hab mal ein wenig geforscht warum er das als Enter nimmt hab aber noch nichts gefunden.
Klar ist das im OnKeyDown Key = #13 ist.

Wenn du es dennoch im KeyDown haben willst bleibt dir wohl nur folgendes:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
private
  procedure apmsg(var Msg: TMsg; var Handled: Boolean);

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMessage := apmsg;
end;

procedure TForm1.apmsg(var Msg: TMsg; var Handled: Boolean);
begin
  if msg.message = wm_keydown then
    if msg.wParam = vk_Return then
      //ShowMessage('ENTER');
end;


mfg nic
Nersgatt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mo 24.08.09 10:43 
Danke für die Tipps.
Ich habe es jetzt sowieso im Keydown gemacht, aber es interessiert mich trotzdem, warum er auf STRG+M reagiert. Finde ich sehr komisch.

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mo 24.08.09 10:54 
M ist der 13. Buchstabe. Deshalb wird aus Strg+M die 13.
Die Gründe dafür sind in den Tiefen der Zeit zu suchen. Leider bringe ich es nicht mehr ganz zusammen. Hat meiner Erinnerung nach was mit bgrenzter Zeichenanzahl (7 Bit) und Datenübertragung zu tun.

Vielleicht findet sich aber ncoh jemand mit besserem Erinenrungsvermögen.

Beste Grüße
jfheins
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 918
Erhaltene Danke: 158

Win 10
VS 2013, VS2015
BeitragVerfasst: Mo 24.08.09 10:58 
Da: en.wikipedia.org/wiki/Control_key

Wird gesagt, dass Strg+M auf Unix Systemen das gleiche ist, wie Enter ...
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: Mo 24.08.09 11:14 
Hallo,

user profile iconNersgatt hat folgendes geschrieben Zum zitierten Posting springen:
Dass die Messagebox erscheint, wenn man Enter drückt ist klar. Aber warum erscheint sie, wenn man STRG + M drückt

STRG = Steuerung
Die ersten Zeichen 0 - 31 des ASCII-Codes sind die sogenannten Steuerzeichen.
Wie Testaro sagte, in den Tiefen der Zeit begründet.
Mit Hilfe der STRG-Taste konnten diese Zeichen erzeugt werden.
de.wikipedia.org/wiki/Steuerzeichen
STRG + i = Tab
STRG + h = Backspace
...

user profile iconNersgatt hat folgendes geschrieben Zum zitierten Posting springen:
, und wie kann man das ändern??

indem Du abfragst ob [STRG] gedrückt ist. :wink:
ausblenden Delphi-Quelltext
1:
2:
if GetAsyncKeyState(VK_CONTROL) = 0 then
  //reagiere entsprechend

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Mo 24.08.09 12:24 
Oder einfach im OnKey -Up/-Down Ereigniss.

ausblenden Delphi-Quelltext
1:
if (Key = ord(#13)) then ...					
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mo 24.08.09 12:43 
user profile iconthepaine91 hat folgendes geschrieben Zum zitierten Posting springen:
Oder einfach im OnKey -Up/-Down Ereigniss.

ausblenden Delphi-Quelltext
1:
if (Key = ord(#13)) then ...					


äh:
ausblenden Delphi-Quelltext
1:
if (Key = 13) then ...					


oder noch besser

ausblenden Delphi-Quelltext
1:
if (Key = VK_RETURN) then ...					


man kann natürlich auch schreiben
ausblenden Delphi-Quelltext
1:
if (Key = ord(chr(ord(chr(ord(#13)))))) then ...					


:-)

Beste Grüße
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Mo 24.08.09 12:46 
Och was hat mich denn da geritten. :nut:

Natürlich hast du recht das war sinnfrei. ^^
Flüchtigkeitsfehler ist daraus entstanden das man z.B.
ausblenden Delphi-Quelltext
1:
 ord('A')					

sagen kann.

Hab nur in dem Moment nicht drüber nachgedacht was ich da schreibe....