key preview for all keys


Hi to all,
under D3/WIN98 i have the following problem:
in the main form is "key preview"=TRUE and i have
"on key down"-event = procedure "inputt" , but not
every keystroke is received in "inputt",
especially when the arrow keys are used.
It seems that mostly (!) only every second keystroke
is received.
In the help of "key preview" is written, that the
arrowkeys are not supported. But i need them.

Any idea what to do for receiving the arrow-keys too ?

thanks,
titz
LVL 1
titzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

markshifferCommented:
I have run into this problem before, if you use the following function on the KeyPress event it should wake up. Alter as needed for vk_down, etc....

function ArrowKeyPressed: boolean;
begin
  Result := (hibyte( GetKeyState (vk_Up)) <> 0);
end; //ControlPressed
0
intheCommented:
Arrow keys do not generate WM_KEYDOWN
Problem:
The KEYDOWN event does not get fired for the left/right arrow keys.
When placed on a form with more than one other control,
the left and right arrow keys move the focus, instead
 of firing an event.

Solution:
You need to handle WM_GETDLGCODE to tell Windows what
 keyboard messages you want to process.




   
 // based on a contribution from David Rifkind <drifkind@acm.org>
type
  TMyControl = class(TWinControl)
  private
    //..
    procedure WMGetDlgCode(var message: TMessage);
      message WM_GETDLGCODE;
    //..
  end;

// request the arrow keys + characters and tabs
procedure TMyControl.WMGetDlgCode(var message: TMessage);
begin
  message.Result := DLGC_WANTARROWS or DLGC_WANTCHARS or DLGC_WANTTAB;
end;
0
titzAuthor Commented:
hi markshiffer,

i adapted your idea to my problem and it works fine !
You will have the points ! throw in an answer!


Sorry inthe,
but markshiffer was quicker. i read your suggestion after testing the idea of markshiffer.

Thanks to you both and merry x-mas !
titz
0
markshifferCommented:
here you go... glad it worked for you...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.