Change VK_Left press key action into my VCL

Posted on 2004-04-21
Last Modified: 2008-03-03
I have a VCL derived from TCutomControl. When I press VK_UP, VK_Down, VL_Left or VK_Right the result is that my VCL change his focus and jump to next control. What to do to use these keys into my VCL and not to change the focus? I have tried untill now into keypress but no result.
Question by:ginsonic
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
  • 2
LVL 11

Accepted Solution

shaneholmes earned 500 total points
ID: 10885502
You need to handle the wm_GetDlgCode message as shown below:

TMyCustomControl = class(TCustomControl)
 { Private declarations }
 procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;

procedure TMyCustomControl.WMGetDlgCode( var Msg: TWMGetDlgCode );
  Msg.Result := dlgc_WantArrows;   // Control will handle arrow keys

You need to ensure that your control can receive the focus. Descending
from TCustomControl is the first step, which you've done. The next step is
publishing the TabStop & TabOrder properties, so users can navigate to your control
with the keyboard. The third step is calling SetFocus in the MouseDown

Just add the TabStop- and TabOrder-property to the published section
of your control and in the constructor you assign true to the


Author Comment

ID: 10889066
Thanks for support! Work now :)
LVL 11

Expert Comment

ID: 10889096
Your Welcome!


Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 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