DelphiFAQ Home Search:
General :: Programming :: Delphi :: VCL
About the Delphi VCL (Visual Component Library)

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

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
 procedure TMyControl.WMGetDlgCode(var message: TMessage);
 begin
   message.Result := DLGC_WANTARROWS or DLGC_WANTCHARS;
 end;

Generated 20:01:33 on Feb 18, 2018