How to Drop Down a Menu on the Startup Form of an Application

ID: Q96099


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0


SUMMARY

Using a BIOS function to push a character into the keyboard type-ahead buffer, a menu can be dropped down on the startup form of a Visual Basic application on IBM AT and PS/2 class computers by using the Call Interrupt statement. This technique will not work on IBM PC class computers.

By pushing into the keyboard buffer the scancode of the access key for the menu you want to drop, you can show the menu dropped down when the form becomes visible. To push the scancode, call BIOS Interrupt &H16, Function 5 in the Form_Load event of the startup form. This technique may not work from procedures other than the Form_Load event because it works only if this interrupt is called prior to a situation where VB-DOS is going to check the keyboard buffer.


MORE INFORMATION

Here is a table of scancodes for access keys and an example showing how to push the scancodes into the keyboard buffer.

Table of access key scancodes:


Letter  Scancode       Letter  Scancode        Letter  Scancode
---------------------------------------------------------------
A       30             J        36             S       31
B       48             K        37             T       20
C       46             L        38             U       22
D       32             M        50             V       47
E       18             N        49             W       17
F       33             O        24             X       45
G       34             P        25             Y       21
H       35             Q        16             Z       44
I       23             R        19 

Step-by-Step Example

  1. Start VBDOS.EXE with the VBDOS.QLB quick library:
    
          VBDOS /l. 


  2. From the File menu, choose New Form (ALT, F, F). Form1 is created by default.


  3. From the Window menu, choose Menu Design Window (ALT, W, M).


  4. Create a top level menu with the following properties:
    
          Caption = &File
          CtlName = mFile 


  5. Create a menu item under &File with the following properties:
    
          Caption = &Exit
          CtlName = mFileExit 


  6. Press the Done button (ALT+D) to close the Menu Design Window.


  7. From the File menu, choose Exit (ALT, F, X). Save all changes.


  8. Add the following code to Form1's module level code:
    
          Rem $INCLUDE: 'VBDOS.BI' 


  9. Add the following code to the Form_Load event procedure:
    
          Sub Form_Load ()
             Dim r AS RegType
             r.ax = &H500        ' function to push character
             r.cx = &H100 * 33   ' scan code for ALT + 'F'
             Call Interrupt(&H16, r, r)
          End Sub 


  10. From the Run menu, choose Start (ALT, R, S) to run the program.


Form1 is loaded and shown with the top level menu with File dropped down.

Additional query words: VBmsdos 1.00

Keywords :
Version : MS-DOS:1.0
Platform : MS-DOS
Issue type :


Last Reviewed: December 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.