Autor Beitrag
stigge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 29.01.07 17:57 
Wenn ich die Taste D drücke, soll eine Box mit 'Test' erscheinen.
Ich habe schon folgenden Code probiert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
begin
if key = 'D' then
showmessage('Test');
end;

Warum funktioniert das nicht?
Kann mir jemand helfen?
Und bitte nicht sagen das ich die Suchfunktion benutzen soll,
da habe ich nichts gefunden was mir helfen könnte. :(


Moderiert von user profile iconGausi: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mo 29.01.2007 um 18:19
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 29.01.07 17:59 
drückst Du auch wirklich ein großes D,
wenn es die Taste d sein soll
ausblenden Delphi-Quelltext
1:
if (Key='d') or (Key='D') then ...					

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Bergmann89
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Mo 29.01.07 18:00 
Weil das ein Großes D ist! und da
musst du Shift+D drücken ^^
aber sonst geht das !
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 29.01.07 18:14 
Funktioniert mit großem und kleinem d nicht. :(
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 29.01.07 18:19 
Ich tppe auf: Ein anderes Control auf der Form hat gerade den Fokus und KeyPreview der Form steht nicht auf True.

_________________
We are, we were and will not be.
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 29.01.07 18:23 
Stimmt! Ich habe zum Spass nen Button auf die Fläche gesetzt.
Jetzt hab ich ihn einfach mal gelöscht und es funktioniert! Danke!
Wie mache ich es aber wenn ich einen button auf dem Feld habe?
Und gibt es eine Liste wie die Tasten heißen, z.B. wie die Tabulatortaste heißt usw.?
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 29.01.07 18:27 
Erste Frage hat sich geklärt. (KeyPreview der Form stand nicht auf True)
Zweite Frage besteht weiterhin. (Und gibt es eine Liste wie die Tasten heißen, z.B. wie die Tabulatortaste heißt usw.?)
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 29.01.07 18:38 
Schau mal hier. ;)
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 29.01.07 19:09 
Dann musste aber KeyDown und nicht KeyPress nehmen. :wink:

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 29.01.07 19:43 
Alles klar aber wie kann ich eine box erscheinen lassen, wenn ich ? drücke?
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 29.01.07 19:44 
Entweder mit ShowMessage oder indem du ein anderes Form mit xyz.Show anzeigst.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Mo 29.01.07 19:46 
user profile iconstigge hat folgendes geschrieben:
Zweite Frage besteht weiterhin. (Und gibt es eine Liste wie die Tasten heißen, z.B. wie die Tabulatortaste heißt usw.?)


ich hab hier ein kleines prog, damit findest du raus, welchen Tastencode (vk und char) du gedrückt hast. Der name ist bisschen irreführend...
Einloggen, um Attachments anzusehen!
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 29.01.07 20:04 
Danke dafür aber ich verstehe es immer noch nicht.
Wenn ich jetzt bei Fragezeichendruck eine Box zeigen will:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
begin
if (Key='#63') then
showmessage('Test');
end;

Warum geht das nicht?
Wenn ich #63 mit c ersetze, dann komm die Box wenn ich c drücke.
Muss ich da noch was mit Chr oder Ord machen?
Oder habe ich irgendwas ganz falsch?
Helft mir!
DarkLord05
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 449

WinXP Pro SP2
Opera; Delphi 3 Pro; Delphi 2005, Turbo Delphi, dev-c++, Eclipse, MS Visual Studio .NET 2003, MS Visual C++
BeitragVerfasst: Mo 29.01.07 20:14 
pack mal die ' da weg ;)

_________________
QBasic | Delphi | c++ | PHP | C# .NET | Java
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Mo 29.01.07 20:23 
genau, '' sind die Kennzeichnung für Strings (= Zeichenketten), # dagegen ist die Kennzeichnung für einen Character, ein zeichen im ASCII-Code.
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 29.01.07 20:35 
Genau, jetzt funktionierts! Aber ich habe schon die nächste Frage:
Wie viele Zeichen kann ein String aufnehmen und was passiert, wenn er sozusagen überläuft?
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 29.01.07 21:02 
Ich würd mal sagen: Neue Frage :arrow: neues Topic. :wink:

PS: Die Maximalgröße liegt bei ca. 2 GB. (Außer du nimmst ShortStrings, da sinds 255 Zeichen)

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.