Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keyboard Lock ... is it possible ???

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Hi guys,

Thanks for reading my post, what i am looking to do is this:
I want to stop windows, and all running programs from
recieing any keyboard events. now I have been thinking allot
about this and have come up with this theory:

If I could scan the Kernel for keyboard events (like Keyup,
KeyDown etc) and set a sort of handled flag for them when they occur, it should stop them from being passed onto
windows, but I have no clue on how to go about this.

Can you guys help me please ??? [bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
I would think that if you set your form to be always on top, you would get first shot at keyboard events. I can't remember offhand how to intercept alt/ctrl/tab keys, but there's an easy way to do it. If you want to prevent the user from using the mouse, maybe you could center it on the form at the beginning of your (hopefully benevolent) process, and move it back there anytime the mouse moved.
 
No its really just the keyboard events that I am looking
for. But thank you for your reply bbegley. [bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
hi,

The method below will show how you can disable any mouse/keyboard actions:

you may assign a handler to Application.OnMessage:

Application.OnMessage := yourOnMessageHandler
where

procedure TForm1.yourOnMessageHandler(var Msg: TMsg; var Handled: Boolean);
begin
case Msg.Message of
WM_KEYFIRST..WM_KEYLAST, WM_MOUSEFIRST, WM_MOUSELAST:
Handled := True
end;
end;

Very important: you must remove a handler when your data processing is completed (or in OnDestroy event of main form)

A basic scheme of data processing:

begin
Application.OnMessage := yourOnMessageHandler;

<your long calculation>
while <...> do
begin
<your calculations>

<update a progressbar/statistic>;

Application.ProcessMessages
end;

Application.OnMessage := nil;
end;


Steph [Bigglasses]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top