Autor Beitrag
Nano-Ware
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 7



BeitragVerfasst: So 20.03.11 20:28 
Hey,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure Tfrm_monitor.edit_ports_KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

  if Not ((Key in ['0'..'9']) Or (Key = VK_CLEAR)) then Key := #0;

end;


Wegen dem "Key = VK_CLEAR" sagt er mir, dass das nicht geht inkompatible Typen aber warum?
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: So 20.03.11 20:51 
VK_ sind virtuelle Tastencode= Word. AscII is char= Byte.
Du must die Char mit ord setzen also ord('1') zb.
So müsste es gehen.

ALf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: So 20.03.11 21:07 
Zeichengebende Tasten müssen in OnKeyPress unterdrückt werden, dort Key gegf. auf #0 setzen

Nicht Zeichengebende Tasten in OnKeyDown ....

In Deinem Beispiel macht nicht VK_Clear den Ärgern sondern Key in ['0'..'9']
wegen var Key: Word;

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS