BUG: GP Fault When KEYSTAT.VBX Used in Two or More Apps

Last reviewed: June 21, 1995
Article ID: Q121681
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows,

  version 3.0

SYMPTOMS

When the KEYSTAT.VBX control is used in more than one application, and the parent window is minimized, the application causes a general protection (GP) fault.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft product listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

WORKAROUND

To work around this problem, use the Windows API GetKeyboardState function directly as in the following example:

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add the following code to the (general) (declarations) section

       Declare Sub GetKeyboardState Lib "User" (ByVal lpKeyState As String)
       Const VK_SHIFT = &H10
       Const VK_CAPITAL = &H14
       Const VK_NUMLOCK = &H90
    
    

  3. Place a command button (Command1) on Form1, and add the following code to the Command1 Click event:

       Sub Command1_Click ()
          Dim keys As String
          keys = Space$(256)
          GetKeyboardState keys
          If &H1 = (Asc(Mid(keys, VK_CAPITAL + 1, 1)) And &H1) Then
             Debug.Print "Caps lock"
          Else
             Debug.Print "non caps"
          End If
          If &H1 = (Asc(Mid(keys, VK_NUMLOCK + 1, 1)) And &H1) Then
             Debug.Print "Num lock"
          Else
             Debug.Print "non lock"
          End If
       End Sub
    
    

  4. Run the application.


Additional reference words: 3.00 buglist3.00 gpf
KBCategory: kbprg kbbuglist kbcode
KBSubcategory: PrgCtrlsCus


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.