2 comments. Current rating: (2 votes). Leave comments and/ or rate it.
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(varmessage: TMessage);
message WM_GETDLGCODE;
//..
end;
// request the arrow keys + characters
procedure TMyControl.WMGetDlgCode(varmessage: TMessage);
beginmessage.Result := DLGC_WANTARROWS or DLGC_WANTCHARS;
end;
Comments:
2007-01-19, 02:44:33
anonymous from Austria
2007-04-17, 06:06:15
anonymous from France
Very good tips ! helpful for Visual C++ MFC too !!