Solved

Disable Ctrl-Esc

Posted on 1998-10-13
6
1,096 Views
Last Modified: 2008-03-04
I need a way to disable the shortcut Ctrl-esc. I have ways to disable all system keys, but I'm not interested in disableling the other system keys, such as Alt-Tab

I must also be able to reenable them again !
0
Comment
Question by:carceri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Expert Comment

by:JPiispa
ID: 1342700
Put on your form keypreview = True

then

procedure TAsrekForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
 If Key=#13 then
  if (Activecontrol is TDBEdit) or (Activecontrol is TEdit) then
  begin
   Key:=#0;
   Perform(WM_NextDlgCtl, 0, 0);
  end
end;

This one makes Enter key look like Tab key. Now you just have to look if CTRL and Esc has been presses and put it Key:=#0;

Enabling/disablign like this
if prevent then Key:=#0;

where prevent is boolean variable.


0
 
LVL 1

Expert Comment

by:Roadrunner100598
ID: 1342701
Does this really work?

I think windows will intercept the shortcut before your form gets it.
This code should not work...!
0
 
LVL 1

Expert Comment

by:Roadrunner100598
ID: 1342702
Hello carceri,

that's a good question... gave me two hours of fun with API and hooks...

After playing with some API functions I finally have a solution that seems to work on my system (NT4). It involves using a hook function and intercepting via WH_CBT the WM_SYSCOMMAND only for the ProgMan window.

I will mail in the code as well, if you need it...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:carceri
ID: 1342703
Well... thanks JPiispa, but as Roadrunner says, Windows will intercept the shortcut before the form gets it.

And to Roadrunner: Yes I had the feeling that it needed some API coding. If you have some code, I'll would appreciate it a lot if you could mail it in as an answer here, so others can benefit from it as well

Thanks
0
 
LVL 1

Accepted Solution

by:
Roadrunner100598 earned 70 total points
ID: 1342704
Hello carceri,

here it comes...
----------------------------------------------------
library HookDll;

{$C FIXED PERMANENT PRELOAD}

uses
  WinProcs,
  SysUtils;

const
  hHookCBT : THandle = 0;

function CBTHookFunc(nCode: Integer; wparam: WPARAM; lparam: LPARAM): LRESULT stdcall;
begin
  if nCode=HCBT_SYSCOMMAND then begin
    messagebeep(-1);
    Result:=1; { removes message }
    end
  else
    { call next hook in chain }
    Result:=CallNextHookEx(hHookCBT, nCode, wParam, lParam);
end;

procedure InstallCBTHook; EXPORT;
var
  hLib : THandle;
  hProgMan : HWnd;
begin
  hLib:=GetModuleHandle('HookDll');
  if (hHookCBT=0) then begin
    hProgMan:=FindWindow('Progman', NIL);
    hHookCBT:=SetWindowsHookEx(WH_CBT, @CBTHookFunc, hLib,
                               GetWindowThreadProcessId(hProgMan, nil));
  end;
end;

procedure RemoveCBTHook; EXPORT;
begin
  if (hHookCBT<>0) then begin
    UnhookWindowsHookEx(hHookCBT);
    hHookCBT:=0;
  end;
end;

EXPORTS
  InstallCBTHook,
  RemoveCBTHook;

end.
----------------------------------------------------

Use this DLL within your program. InstallCBTHook enables the hook function.
All messages to the ProgMan class (I hope that classname stayed the same for Win95/98) are intercepted and if the message was a WM_SYSCOMMAND it will not be handed on to the ProgMan Window.

Therefore the ctrl-ESC and [Win95] shortcuts are disabled, but taskswitching via alt-TAB or the mouse still works.

If anyone has additional information about the PrgMan-class please comment.


Roadrunner
0
 

Author Comment

by:carceri
ID: 1342705
Thanks, that was just what I needed !
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question