Microsoft KB Archive/92382

From BetaArchive Wiki
Knowledge Base


KeyUp Event On Menu Item Is Being Sent To Control

PSS ID Number: 92382

Article Last Modified on 1/8/2003



The information in this article applies to:

  • Microsoft Visual Basic for MS-DOS 1.0



This article was previously published under Q92382

SYMPTOMS

When using an Access Key sequence to select a menu item, the current control on the form with the focus will receive a KeyUp event.

STATUS

Microsoft has confirmed this to be a bug in the Standard and Professional Editions of Microsoft Visual Basic for MS-DOS, version 1.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The following steps will duplicate this problem:

  1. Start VBDOS.EXE.
  2. Form the File Menu select New Form... (Form1.FRM).
  3. Add a text box (Text1) to the Form (Form1).
  4. From the Window menu select the Menu Design Window...
  5. Create a top level menu, caption = &File, ctrlname = filem.
  6. Create a menu item within &File, caption = &Exit, ctrlname = exitm.
  7. Close the Menu Design Windows.
  8. From the File menu select Exit, save all changes.
  9. Press F12.
  10. Add the following code to the Text1_KeyUp event procedure:

            SUB Text1_KeyUp (KeyCode AS INTEGER, Shift AS INTEGER)
               MSGBOX(STR$(KeyCode))
            END SUB
                            
  11. Run the application (press F5).
  12. Press ALT+F+X.

The message box appears with the ASCII code of the key pressed.

To work around this problem, trap for the KeyDown event. Note that with this problem the KeyDown event is not triggered, therefore if you trap for the KeyDown event you will know if it was an actual key pressed intended for that control, or if no KeyDown event was detected before the KeyUp event, you will know that it was the result of the menu Access Key selection.


Additional query words: VBmsdos Buglist1.00 1.00

Keywords: KB92382
Technology: kbAudDeveloper kbVB100DOS kbVBSearch kbZNotKeyword3