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!

get CTRL key-pressed event

Status
Not open for further replies.

rebShaul

Programmer
Jun 22, 2003
15
IL
Hi.
How can I get a CTRL key-pressed event while my Form is not in focus?
 
For Windows, when you press a key the system redirect this event to the active window and if that event is captured in that window then the corresponding handler will be called.
So, you cannot intercept in your Form the CTRL pressed key while it is not active.
A sample example. Let say you are running Windows 2000.
You have open Netscape, VS 2003 and IE.
If all three are inactive and you press F1 then the Windows 200 Help is displayed. If IE is active and press F1 then IE Help is displayed. If Netscape is active and press F1 then NetHelp Netscape is displayed.
-obislavu-
 
Then hoe come Windows can recognize CTRL+ALT+Del no matter which Form/window is active?
 
Just a Note...
CTRL + ALT + Del combination is filtered out before message is sent to active window. The code for this is in a system library (I think GINA.DLL which is to do with I/O routines).

Don't hate the player - hate the game
 
Yes, Ctrl+Alt+Del is the Secure Attention Sequence (SAS), and the operating system will filter it out before any user windows see it. Note that this only applies to real operating systems like XP Pro, Win2k, etc. The XP Home and Win 9x don't count, as they aren't secure.

Microsoft does, however, provide a way to capture this yourself -- you write a custom GINA DLL. Note that this is a difficult task. If you plan to develop one, you'll need VC++ (NOT C#!), and a copy of VirtualPC (If you make any mistakes, you can't log in, so best to do your testing in a environment you can easily restore).

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top