AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

If Key = #107

Ein Thema von Luckner · begonnen am 16. Mai 2019 · letzter Beitrag vom 21. Mai 2019
Antwort Antwort
Seite 1 von 3  1 23      
Luckner

Registriert seit: 28. Nov 2006
Ort: Berlin
418 Beiträge
 
Delphi 7 Enterprise
 
#1

If Key = #107

  Alt 16. Mai 2019, 14:14
Hallo,
habe eine Abfrage gebastelt, die jedoch nur teilweise funktioniert.
Delphi-Quellcode:
if Key = #13 then //RETURN-Taste
begin
  ShowMessage('Bin hier 1');
  usw.
end
else if Key = #107 then //+-Taste auf dem Num-Block.
begin
  ShowMessage('Bin hier 2');
  usw.
end
Die Return-Taste funktioniert, die Plus-Taste jedoch nicht. Nach der Recherche dürfte jedoch #107 für die +-Taste korrekt sein. Oder doch nicht. Ich bitte um Hilfe.

Danke, Luckner
  Mit Zitat antworten Zitat
DieDolly

Registriert seit: 22. Jun 2018
2.175 Beiträge
 
#2

AW: If Key = #107

  Alt 16. Mai 2019, 14:20
Nach meinem Test ist + die 43 und - die 45. Egal ob Nummernblock oder nicht.

Delphi-Quellcode:
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
 ShowMessage(Ord(Key).ToString);
end;
  Mit Zitat antworten Zitat
jsp

Registriert seit: 9. Aug 2003
50 Beiträge
 
#3

AW: If Key = #107

  Alt 16. Mai 2019, 14:21
Versuch mal

Delphi-Quellcode:
..........
else if Key = VK_Add then //+-Taste auf dem Num-Block.
begin
  ShowMessage('Bin hier 2');
  usw.
end
Gruss, Jörn
  Mit Zitat antworten Zitat
DieDolly

Registriert seit: 22. Jun 2018
2.175 Beiträge
 
#4

AW: If Key = #107

  Alt 16. Mai 2019, 14:22
VK_ADD ist auch die 107. + ist aber laut Windows 10 Bildschirmtastatur die 43.
  Mit Zitat antworten Zitat
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
10.995 Beiträge
 
Delphi 12 Athens
 
#5

AW: If Key = #107

  Alt 16. Mai 2019, 14:23
Im OnKeyPress kommt lediglich das +-Zeichen an. Willst du den Tastencode, dann musst du das im OnKeyDown machen.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#6

AW: If Key = #107

  Alt 16. Mai 2019, 14:26
Der Unterschied ist, das eine ist der Virtuelle Tastencode, das andere der ASCII-Wert des Zeichens.
Im KeyPress bekommt man die ASCII-Werte in KeyDown/KeyUp bekommt man die virtuellen Tastencodes.

Im KeyPress kann man dementsprechend einfach abfragen:
Delphi-Quellcode:
if Key = '+then
  ...
Im KeyDown/KeyUp:
Delphi-Quellcode:
if Key = VK_ADD then
  ...
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
DieDolly

Registriert seit: 22. Jun 2018
2.175 Beiträge
 
#7

AW: If Key = #107

  Alt 16. Mai 2019, 14:29
Der Unterschied ist, das eine ist der Virtuelle Tastencode, das andere der ASCII-Wert des Zeichens.
Im KeyPress bekommt man die ASCII-Werte in KeyDown/KeyUp bekommt man die virtuellen Tastencodes.

Im KeyPress kann man dementsprechend einfach abfragen:
Delphi-Quellcode:
if Key = '+then
  ...
Im KeyDown/KeyUp:
Delphi-Quellcode:
if Key = VK_ADD then
  ...
Ich kann ihm oder ihr da nur den Tipp geben auf 43 und 45 zu prüfen. Es gibt nichts schlimmeres als ein Programm, was auf einen Nummernblock angewiesen ist.
Es gibt tatsächlich Leute, die haben und wollen keinen Nummernblock
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#8

AW: If Key = #107

  Alt 16. Mai 2019, 14:33
Ich kann ihm oder ihr da nur den Tipp geben auf 43 und 45 zu prüfen. Es gibt nichts schlimmeres als ein Programm, was auf einen Nummernblock angewiesen ist.
Ist jetzt nicht wirklich so als könnte er sich das aussuchen.
Wenn er im KeyDown auf 43/45 abprüft funktioniert es weder mit noch ohne Nummernblock.
Umgekehrt bringt VK_ADD im KeyPress nichts.

Es gibt tatsächlich Leute, die haben und wollen keinen Nummernblock
Natürliche Selektion
Ohne Numblock geht gar nicht
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."

Geändert von Neutral General (16. Mai 2019 um 14:35 Uhr)
  Mit Zitat antworten Zitat
Luckner

Registriert seit: 28. Nov 2006
Ort: Berlin
418 Beiträge
 
Delphi 7 Enterprise
 
#9

AW: If Key = #107

  Alt 16. Mai 2019, 14:47
Danke für die Hinweise. 43/45 in KeyPress funktionieren nicht. Ebenfalls '+' nicht. Warum funktioniert #13 in KeyPress so gut?

Luckner
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#10

AW: If Key = #107

  Alt 16. Mai 2019, 14:48
Danke für die Hinweise. 43/45 in KeyPress funktionieren nicht. Ebenfalls '+' nicht. Warum funktioniert #13 in KeyPress so gut?

Luckner
Habs probiert, funktioniert.
Ggf. "KeyPreview" der Form auf true setzen?
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 3  1 23      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:31 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz