CompuServe Thread

#Right-Justifed Menu Bar

3 messages in this thread
#3501From: Chris CalkinsOct 16, 1991 10:05 PM
I've found a way to Right-Justify a Menu Bar item for Visual Basic applications and thought some of you might like to know. If you already knew or don't care, sorry to bother you. I like the way many Win apps have thier HELP selection to the far right of the menu bar, as in: _________________________________________________________________ | File Edit Help | —————————————————————– but I could not figure out how to do it using the Menu Design Window. Here's what I did and it seems to work fine. Using the Menu Design Window, my final top-level menu item Caption: I named &HHelp. After saving and making an .EXE I then used PC Tools hex editor to change this caption. I changed the "&" to the BS character (HEX 08), and the first "H" to an "&". Saved it, ran it, and thats it. I hope you may find this useful. There are 2 Replies.
#3526From: Ted M. YoungOct 17, 1991 1:11 AM
Chris, Interesting…in fact, you don't even need to go through the trouble of using a hex sector editor, you can use the Windows menu API calls to accomplish the same thing: DefInt A-Z <– put in the Declarations section '– get the menu handle for the form hMenu = GetMenu(Form1.hWnd) '– get the handle to the submenu: nPos is the item number starting at 0 ' e.g., if &Help is the 3rd main menu item, nPos = 2 hSubMenu = GetSubMenu(hMenu, nPos) '– create the menu string (you can use GetMenuString if you don't ' want to create the menu string from scratch, but merely change ' what was previously there — see the Win Ref manual) Menu$ = Chr$(8) + "&Help" '– nPos is the same as above in hSubMenu ' MF_BYPOSITION = &H400 nResult = ModifyMenu(hMenu, nPos, MF_BYPOSITION, hSubMenu, Menu$) '– redraw the menu bar DrawMenuBar Form1.hWnd Don't forget to put in the declarations for GetMenu, GetSubMenu, ModifyMenu, and DrawMenuBar in your global declarations module. – Ted
#3529From: Rob HeymanOct 17, 1991 2:07 AM
Wow! Way cool! I just tried your tip….it works! (Not wanting to appear stupid.. but asking anyway) WHY does this work?? Rob