Re: Intercepting Key Events in TCustomControl
From: IElite (holmesshane_at_charter.net)
Date: 01/30/04
- Next message: Maarten Wiltink: "Re: Is this a wrong approach?"
- Previous message: John Dammeyer: "Re: re-installing Delphi Application"
- In reply to: news.charter.net: "Intercepting Key Events in TCustomControl"
- Next in thread: Rob Kennedy: "Re: Intercepting Key Events in TCustomControl"
- Reply: Rob Kennedy: "Re: Intercepting Key Events in TCustomControl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 30 Jan 2004 12:50:30 -0500
ahh, i solved it. Need to override CreatWnd and call the setfocus...
"news.charter.net" <holmesshane@charter.net> wrote in message
news:101kufajuav5k02@corp.supernews.com...
>
>
> I have a CustomControl Component that I am deriving from, which has
no
> controls as its children. All I do is some drawing on the control using
the
> Canvas. Can I intercept the Arrow keys? I need to draw on the canvas based
> on what arrow key is pressed.
>
> I have tried the following with no success....
> (code fragment of my control)
>
> TSAHDAK = class(TCustomControl)
> private
> { Private declarations }
> procedure WMGetDlgCode(var Message: TWMGetDlgCode); message
> WM_GETDLGCODE;
> protected
> { Protected declarations }
> procedure KeyDown(var Key: Word; Shift: TShiftState);
> override;
> public
> { Public declarations }
> published
> { Published declarations }
> end;
>
> procedure Register;
>
> implementation
>
> procedure TSAHDAK.WMGetDlgCode(var Message: TWMGetDlgCode);
> begin
> Message.Result := DLGC_WANTARROWS;
> end;
>
>
>
> procedure TSAHDAK.KeyDown(var Key: Word; Shift: TShiftState);
> begin
> // inherited KeyDown(Key, Shift);
> SetFocus;
> case Key of
> VK_UP : begin
> {Do something}
> end;
> VK_DOWN : begin
> {Do something}
> end;
> end;
> inherited KeyDown(Key, Shift);
> Invalidate;
> end;
>
>
- Next message: Maarten Wiltink: "Re: Is this a wrong approach?"
- Previous message: John Dammeyer: "Re: re-installing Delphi Application"
- In reply to: news.charter.net: "Intercepting Key Events in TCustomControl"
- Next in thread: Rob Kennedy: "Re: Intercepting Key Events in TCustomControl"
- Reply: Rob Kennedy: "Re: Intercepting Key Events in TCustomControl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]