Solved

Change VK_Left press key action into my VCL

Posted on 2004-04-21
3
796 Views
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.
0
Comment
Question by:ginsonic
  • 2
3 Comments
 
LVL 11

Accepted Solution

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

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


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


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
method.

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


Shane
0
 
LVL 9

Author Comment

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

Expert Comment

by:shaneholmes
ID: 10889096
<SMILE>
Your Welcome!

Shane
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now