[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Disable Ctrl-Esc

Posted on 1998-10-13
6
Medium Priority
?
1,116 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 280 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 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