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

Overriding default Message handling

469 views
Skip to first unread message

Kurt Barthelmess

unread,
Nov 8, 2000, 3:00:00 AM11/8/00
to
Justin -

Try looking for WM_KEYDOWN in your application message handler.

Good luck.

Kurt

Justin Holloway

unread,
Nov 8, 2000, 4:06:03 PM11/8/00
to
Subject
Overriding default Message handling
Description
For an acccessibility application I need to override the functions of many
keys in all the windowed controls, including the windows navigation keys
(Tab, BackTab, the Left/Right arrow keys), these mentioned ones don't
generate keyboard events so I can't uses the control's KeyDown functions.
However they should all be propogating thru the delphi components/controls
as messages I can catch and do my own handling of, but for some reason I'm
not having any joy, even at the Application.Onmessages level, although all
keys are still being processed. Does anyone know (better than the help
system) where I can catch and handle these for all TWinControls in my entire
delphi app?

type
TForm1 = class(TForm)
Edit1: TEdit; Edit2: TEdit; Label1: TLabel;
procedure FormCreate(Sender: TObject);
file://Application.OnMessage intercept
procedure AppMessage(var Msg: TMsg; var Handled: Boolean); file://From
Delphi Help example, but nothing caught
procedure GenerateOnKeyDown(var Message: TMessage); message WM_KEYDOWN;
file://Nothing caught
procedure WndProc(var Message: TMessage); override; file://Only mouse
events caught!
end;

var
Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.WndProc;
begin
if (Message.Msg = WM_KEYUP) or (Message.Msg = WM_CHAR) then
label1.caption:='WM_KEYUP in WndProc' file://NOTHING
else
if Message.Msg = WM_MOUSEMOVE then
label1.caption:='mouse' file://IT CATCHES MOUSE EVENTS OK
else
inherited WndProc(Message);
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := AppMessage;
end;

procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
edit2.text := 'in appmsg'; file://IT NEVER EVEN GETS HERE
if (Msg.message = WM_IME_KEYDOWN) or (Msg.message = WM_KEYUP) then
begin
case (Msg.wParam) of file://SO IT COULDN"T GET HERE
VK_TAB : begin Edit1.Text := 'Tab';
SelectNext(Sender As TWinControl, False, True);
Handled := True;
end;
end;
end;

procedure TForm1.GenerateOnKeyDown(var Message: TMessage);
begin
edit1.text:= 'in keydn'; file://NOTHING
end;

end.

Peter Below (TeamB)

unread,
Nov 9, 2000, 3:00:00 AM11/9/00
to
In article <8ucfc0$e3...@bornews.inprise.com>, Justin Holloway wrote:
> For an acccessibility application I need to override the functions of many
> keys in all the windowed controls, including the windows navigation keys
> (Tab, BackTab, the Left/Right arrow keys), these mentioned ones don't
> generate keyboard events so I can't uses the control's KeyDown functions.

Application.OnMessage will work, but you should look for
WM_KEYDOWN/WM_SYSKEYSDOWN messages. The handler will see WM_KEYUP/WM_SYSKEYUP,
however. If the event handler is not called then you have something in your
app that disconnects it again after your statement in the forms OnCreate
handler. Do you have a TApplicationEvents object on any of your forms. Even if
not, do you have the AppEvnts unit in any of your uses clauses? If so, try to
remove it.


Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!


Dr John Stockton

unread,
Nov 9, 2000, 3:00:00 AM11/9/00
to
JRS: In article <8ucfc0$e3...@bornews.inprise.com> of Thu, 9 Nov 2000
08:06:03 seen in news:borland.public.delphi.objectpascal, Justin
Holloway <joo...@geocities.com> wrote:

>procedure TForm1.WndProc;
>begin
> if (Message.Msg = WM_KEYUP) or (Message.Msg = WM_CHAR) then
> label1.caption:='WM_KEYUP in WndProc' file://NOTHING
> else
> if Message.Msg = WM_MOUSEMOVE then
> label1.caption:='mouse' file://IT CATCHES MOUSE EVENTS OK
> else
> inherited WndProc(Message);
>end;

If you EITHER always put whitespace after "//", OR get yourself
respectable News software, then we will not be afflicted with those
unwanted "file:" and my newsreader will not display them as URLs.

--
© John Stockton, Surrey, UK. j...@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL: http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Plaintext, quoting : see <URL: http://www.usenet.org.uk/ukpost.html>
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)

0 new messages