Image Map of Navigational Panel to Home/Contents/ Search A SpyWorks-VB Case History

by Dan Appleman - Desaware

Image of line

Trapping and Blocking the Control-Escape Sequence.

When the user hits the Ctrl+Esc key, Windows sends a WM_SYSCOMMAND message to the active application. The information in the message tells the active application to bring up the Task List. You cannot use the Keyboard Hook to throw the Ctrl-Esc key message away because the WM_SYSCOMMAND message is sent before the key message.

The solution is to use the sbchook.vbx control to place a task or systemwide hook that detects the WM_SYSCOMMAND message (Set the HookType property to GetMessage).

In the WndMessage event, the lp parameter contains the cursor coordinate if the user selects the "Switch To..." command from the System menu.

When the user hits the Ctrl+Esc key, lp is set to 0. By blocking the WM_SYSCOMMAND message only when lp = 0. you can allow the user to bring up the Task List via the System menu.

In the WndMessage event place the following code:

  If msg = WM_SYSCOMMAND Then
    If wp = SC_TASKLIST Then
      If lp = 0 Then
        nodef = True
        msg = 0
      End If
    End If
  End If

Setting nodef to True prevents further hooks from being called, but in many cases you must also set the msg value to truly block the control-escape key.


Written by: Dan Appleman
June 94

Image of arrow linked to previous page Image of arrow linked to next page
Image of line
[HOME] [TABLE OF CONTENTS] [SEARCH]