Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TPanel and KeyDown

276 views
Skip to first unread message

Gürcan YÜCEL

unread,
Jan 25, 2004, 6:11:17 AM1/25/04
to
Hi,
Im trying to write something like designer. (like delphi form design) I need
different kind of components in a single panel. I created a class inherited
from a TPanel. When it gets focuse I need to catch key events. Here is the
simplified class;
///
interface
TDataField = Class(TPanel)
Protected
Procedure KeyDown(Sender: TObject; var Key: Word;Shift:
TShiftState);
public
constructor Create(aOwner: TComponent); override;
destructor Destroy;Virtual;

implementation

constructor TDataField.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
Self.OnKeydown:=KeyDown;
end;

destructor TDataField.Destroy;
begin
end;

Procedure TDataField.KeyDown(Sender: TObject; var Key: Word;Shift:
TShiftState);
Begin
if Shift=[ssShift] then
if key=VK_UP then Self.Top:=Self.Top-2;
end;

I used TPanel, because Im putting a label and for example editbox
dynamically. Here is the problem;

KeyDown event catchs the key strokes except arrow keys.(Imean
VK_UP,DOWN,LEFT and Right. What is the problem? Why I cant use them? I can
use all other keys. Is it true to use TPanel? or I had to use TWinControl or
something like that? I tried with TWinControl but the result is same.

Thanks.

Gürcan YÜCEL


Florent Ouchet

unread,
Jan 25, 2004, 6:49:25 AM1/25/04
to
You have to catch the WM_GETDLGCODE message and return a set or these values
:

DLGC_BUTTON Button.
DLGC_DEFPUSHBUTTON Default push button.
DLGC_HASSETSEL EM_SETSEL messages.
DLGC_RADIOBUTTON Radio button.
DLGC_STATIC Static control.
DLGC_UNDEFPUSHBUTTON Non-default push button.
DLGC_WANTALLKEYS All keyboard input.
DLGC_WANTARROWS Direction keys.
DLGC_WANTCHARS WM_CHAR messages.
DLGC_WANTMESSAGE All keyboard input (the application passes this
message in the MSG structure to the control).
DLGC_WANTTAB TAB key.


(from the platform SDK of microsoft)

I think you have to return DLGC_WANTALLKEYS or DLGC_WANTARROWS. Or if you
don't want the char keys just return DLGC_WANTARROWS.

Regards

Florent

"Gürcan YÜCEL" <gyu...@g-gsoft.com> a écrit dans le message de
news:4013...@newsgroups.borland.com...

0 new messages