Autor Beitrag
mattl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77

Win Xp Pro
Deplphi 3 Pro,Delphi 2005 PE
BeitragVerfasst: Do 24.08.06 07:11 
Ich möchte das mein Programm beim drücken einer Pfeiltaste einen Vorgang ausführt
und habe das mit if key = chr(vk_up) then... im OnKeyPress versucht das funktioniert aber nicht.
deswegen habe ich einen Timer angelegt der in einem gewissen Intervall mit dieser Funktion die Tastenanschläge prüft if GetKeyState(VK_up) and $8000 = $8000 then das funktioniert zwar aber damit bin ich aber sehr unzufrieden
DaiweL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 27



BeitragVerfasst: Do 24.08.06 07:16 
Versuchs mal mit OnKeyDown

ausblenden Delphi-Quelltext
1:
if(Key = VK_UP)then showmessage('Geht Doch! :P');					
mattl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77

Win Xp Pro
Deplphi 3 Pro,Delphi 2005 PE
BeitragVerfasst: Do 24.08.06 07:22 
nein geht auch nicht
DaiweL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 27



BeitragVerfasst: Do 24.08.06 07:31 
Funktioniert ganz gut bei mir!

Wuerde mal sagen dass der Fokus bei dir auf anderen Komponenten ist, somit wird dessen OnKeyPress/KeyDown ausgeloest.

Eine Loesung waere die Events dieser Komponenten auf eine gemeinsame Keypress Funktion zu leiten.
mattl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77

Win Xp Pro
Deplphi 3 Pro,Delphi 2005 PE
BeitragVerfasst: Do 24.08.06 07:39 
ja wenn ich eine Pfeiltaste drücke wird automatisch ein Button fukusiert aber wie kann ich das verhindern
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Do 24.08.06 07:45 
Stell mal KeyPreview der Form auf True dann müsst es klappen.
mattl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77

Win Xp Pro
Deplphi 3 Pro,Delphi 2005 PE
BeitragVerfasst: Do 24.08.06 07:49 
nein
passiv
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 270

WIN XP Professional
Delphi 7 Enterprise, Java (Eclipse), Python 2.5, Django 1.1
BeitragVerfasst: Do 24.08.06 07:52 
dann musst du auch bei form den keyDown abfragen ;-)

_________________
Die Probleme, die es in der Welt gibt, sind nicht mit der gleichen Denkweise zu lösen, die sie erzeugt hat.
Albert Einstein
mattl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77

Win Xp Pro
Deplphi 3 Pro,Delphi 2005 PE
BeitragVerfasst: Do 24.08.06 07:55 
mach ich ja
uwewo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Do 24.08.06 08:01 
Zeig mal Deinen Quellcode, vielleicht werden wir dann schlauer!
mattl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77

Win Xp Pro
Deplphi 3 Pro,Delphi 2005 PE
BeitragVerfasst: Do 24.08.06 08:05 
den kompletten?
uwewo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Do 24.08.06 08:15 
Ich habe keine Ahnung wie groß der ist.

Den Source von Deinem Problemformular sollte allerdings reichen.
mattl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77

Win Xp Pro
Deplphi 3 Pro,Delphi 2005 PE
BeitragVerfasst: Do 24.08.06 08:32 
es funktioniert aber auch nur wenn der Cursor nach dem 7 mal drücken der Pfeiltaste in das Memofeld springt und von dort nicht mehr weg geht
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: Do 24.08.06 08:37 
Hallo,

user profile iconmattl hat folgendes geschrieben:
ja wenn ich eine Pfeiltaste drücke wird automatisch ein Button fukusiert aber wie kann ich das verhindern

Wenn ein Button den Focus hat bekommt die Form den Tastendruck nicht mit, da nützt es auch nichts KeyPreview auf True zu setzen.
Kann man auch in der Delphi-Hilfe zu KeyPreview nachlesen:
Zitat:
...Die Einstellung bezieht sich nicht auf Navigationstasten (TAB, Pfeiltasten usw.), da diese keine Tastaturereignisse auslösen.


Auch im OnKeyDown des Buttons wird z.B. VK_UP erkannt.
IMHO ist die einzige Möglichkeit die ensprechenden Windows-Messages abzufangen.

z.B dort wurde ein ähnliches Problem beschrieben und auch ein Code gepostet:
Buttonmatrix

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
passiv
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 270

WIN XP Professional
Delphi 7 Enterprise, Java (Eclipse), Python 2.5, Django 1.1
BeitragVerfasst: Do 24.08.06 08:38 
@mattl: und was soll das jetzt heißen??

_________________
Die Probleme, die es in der Welt gibt, sind nicht mit der gleichen Denkweise zu lösen, die sie erzeugt hat.
Albert Einstein
mattl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 77

Win Xp Pro
Deplphi 3 Pro,Delphi 2005 PE
BeitragVerfasst: Do 24.08.06 08:44 
ich lege bei jedem button klick einfach den Focus auf ein nicht sichtbares memofeld :lol: dann funktioniertes
werde mir aber den Link von lannes noch ansehen