Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

hack the VK_LEFT or VK_Right keys

Posted on 2001-07-05
11
Medium Priority
?
363 Views
Last Modified: 2010-04-06
I have a component derived from TCustomControl . When I press left or right or up&down key the focus go to the next control .
But I wish to have this just for up or down keys .
How can I use left and right keys into my component to do something else?
0
Comment
Question by:ginsonic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6255220
you should catch the wm_keydown message

you could override the WMKEYDOWN-Method

do your stuff if the key is your one of your needed keys and set the key to null before doing an inherited call,
all other let process inherited

other possibilities may available

meikl ;-)
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6255355
Is there a reason you derived it from TCustomControl instead of TWinControl? If not then try TWinControl.
0
 

Expert Comment

by:felonious
ID: 6258377
like kretzschmar said, you could use the windows message for keydown, or just use the OnKeyDown event for the Control.  play around with this a bit..:

in an OnKeyDown event try:

case Key of
VK_Left : begin
            DoSomethingHere;
            Key := nil;
          end;
VK_Right: begin
            DoSomethingElseHere;
            Key := nil;
          end;
end;

setting key to nil after your code will insure that thats all that is executed for those key presses.  let me know if this helps.


felonious
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:felonious
ID: 6258381
like kretzschmar said, you could use the windows message for keydown, or just use the OnKeyDown event for the Control.  play around with this a bit..:

in an OnKeyDown event try:

case Key of
VK_Left : begin
            DoSomethingHere;
            Key := nil;
          end;
VK_Right: begin
            DoSomethingElseHere;
            Key := nil;
          end;
end;

setting key to nil after your code will insure that thats all that is executed for those key presses.  let me know if this helps.


felonious
0
 

Expert Comment

by:felonious
ID: 6258383
oops
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6262472
I have used this ... don't work .

procedure TMy.WMKeyDown(var Message: TWMKeyDown);
begin
  if Message.CharCode = VK_LEFT then
  Message.CharCode := null;
  inherited;
end;

But guys ... WMKeyDown and TCustomControl ?
0
 

Expert Comment

by:felonious
ID: 6263394
how bout changing the above code to:

begin
  if message.CharCode <> VK_LEFT then inherited;
end;
0
 

Expert Comment

by:felonious
ID: 6263400
hmm, you might also consider setting Message.Result = 0 (tells windows the message has been processed)

so, basicly, try your above code just adding Message.Result := 0;  if that doesn't work try


begin
 if message.CharCode <> VK_LEFT then inherited
 else
 begin
  message.CharCode := null;
  message.Result := 0;
 end;
end;


felonious
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6655627
I forgot to check this questions . Sorry .. anothers jobs .
I will give an answer soon .
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6674192
Not a comment work . I will delete this question , but already put a new one , with same content and with 200 point reward .
Thanks for suport ... and if you have new ideas then go to new request .
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 6832367
Per user request, points refunded and question closed.

Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question