Link to home
Start Free TrialLog in
Avatar of bnz
bnz

asked on

Disable system keys

Hi
Can anybody show me an example of how to disable alt+tab, alt+shift+tab, alt+esc, ctrl+esc, windows keys.
NOT ctrl+alt+del it is ok

Under NT, 2000 and XP ?
And I just don't want to edit the policies. If you press thoose keys while my application has focus nothing should happend
Avatar of adrenalindx
adrenalindx

i am having the same difficulties u r having, i ended up using policies, i no trhere is a way, it has somethin to do with gina.dll i never really bthered to look into it, anyone else ?
i found this link, but it's for Win95.

http://www.delphicorner.f9.co.uk/articles/wapi12.htm

had a look at the API, there it says:

SystemParametersInfo

"SPI_SETFASTTASKSWITCH     This flag is obsolete. Previous versions of Windows use this flag to enable or disable ALT+TAB fast task switching. Beginning with Windows 95 and Windows NT version 4.0, fast task switching is always enabled."

which isn't good news, i guess

cu
keashF
ASKER CERTIFIED SOLUTION
Avatar of 123456
123456
Flag of Iran, Islamic Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Set your form KeyPreview = True.

OnKeyUp event on your form do the following....

//alt+tab
if ((Key = VK_TAB)and(ssAlt in Shift))
 then
  begin
   Exit;
  end;

//alt+shift+tab
if ((Key = VK_TAB)and(ssShift in Shift)and(ssAlt in Shift))
 then
  begin
   Exit;
  end;
//alt+esc
if ((Key = VK_ESCAPE)and(ssAlt in Shift))
 then
  begin
   Exit;
  end;
//ctrl+esc
if ((Key = VK_ESCAPE)and(ssCtrl in Shift))
 then
  begin
   Exit;
  end;
//windows keys
if ((Key = VK_LWIN)or(Key = VK_RWIN))
 then
  begin
   Exit;
  end;

This will cause the procedure to exit, if any of the Windows keys, or any of the above combinations are pressed.

Hope that this helps.  It is the easiest way that I have found to do it.  
Sorry forgot about something, and did not think it through.  Please disregard this answer as it does not work....
bnz:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to split points between 123456 and DaFox
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer