Microsoft KB Archive/86772

{| = How to Right Justify Top-Level Menus in Visual Basic =
 * width="100%"|

Last reviewed: February 18, 1996

Article ID: Q86772 The information in this article applies to: - Standard and Professional Editions of Microsoft Visual Basic for

Windows, versions 2.0 and 3.0 - Microsoft Visual Basic programming system for Windows, version 1.0

SUMMARY
It is possible to right justify top-level menu items by including a CHR$(8) (backspace) as the first character of the caption for the left-most menu that you want to appear on the right side of the menu bar.

This article does not apply to Windows 95.

MORE INFORMATION
Microsoft publishes a book called &quot;The Windows Interface: An Application Design Guide,&quot; which contains standards and guidelines for Windows 3.1. The following guidelines for right-justified Help menu items is taken from that book:

&quot;Some applications currently place the Help menu at the extreme right of  the menu bar. The current recommendation is that the Help menu immediately follow the next-to-last menu item, for three reasons: (1) to  increase the accessibility of the help menu; (2) to decrease the likelihood of pressing the Maximize or Minimize buttons by mistake when trying to access Help; and (3) to make the space at the extreme right of  the menu bar available in MDI applications for a Restore icon for maximized child windows.&quot;

Source: &quot;The Windows Interface: An Application Design Guide&quot; by Microsoft Corporation 248 pages, plus two 3.5-inch disks ISBN: 1-55615-439-9 Publication Date: October 9, 1992

Step-by-Step Example
 Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. From the Window menu, choose Menu Design Window. Create a menu item with One as both caption and control name. Choose the Next button, and repeat step 3 with using Two as the name. Choose Done to exit the Menu Design Window. You now have two top-level menus.  Add the following code to the Form1 Form_Load event procedure: Sub Form_Load Two.Caption = Chr$(8) + Two.Caption End Sub  Press the F5 key to run the program.

The Two menu item appears on the right side of the menu bar. If you add the backspace to the One menu caption, both menus will be right-justified.

Special Trick for Design Time
The technique given above can be done only at run time. However, here's a trick you can use to do the same thing at design time:


 * 1) Make a text file with ASCII character 8 in it.
 * 2) Load the text file into NOTEPAD.EXE and copy the character to the clipboard.
 * 3) Then, when you're in the Menu Design window, Press SHIFT-INS (Paste) in the caption field to place CHR$(8) character in it.
 * }