We already had a formal introduction to Custom Tool Bar, Submenus & Shortcut Menus through the earlier posts: Animated Floating Calendar & Calendar and Toolbars. We have seen how to reference individual Button to enable/disable it based on situations that demands it.
Here, we will take a closer look at Custom Menu bars, Toolbars & Shortcut Menus. Since, it is a lengthy subject we are forced to split this into 2 or 3 Posts.
Windows based Applications have a Menu bar at the top with titles like File, Edit, View, Insert etc. When we click on them a long list of Options like Sub-menus, Items with Description alone or with Button Images and Description appears in a drop down list. When we click on any of them the designated action defined on the menu option runs and we will get our work done. We can create a Custom Menu bar with our Application specific Menu Descriptions like Data Files to open Forms linked to Tables/Queries, Reports to preview and print Reports, Utilities for other common tasks etc., add menu items into them and assign Actions to each of them. Initially we will concentrate on designing the Menu Bar alone. When this is understood the task of designing Toolbars and Shortcut Menus become easier, because the approach is same and you will be able to do it yourself with little guidance.
- Select Customize command from Toolbars submenu of View Menu.
- Select New from the Toolbars Tab.
- Type MyMenuBar in Toolbar Name: control and click OK. The new Toolbar Item is added in the Toolbars List and a small empty Toolbar appears in the Application surface, not necessarily at the top.
You may be wondering that we have started discussing Menu bars then why we have to deal with Toolbars. We need to create a Toolbar first and then define it as a Menu bar, that’s how it goes. For Shortcut Menu, create a Toolbar and define it as a Popup Menu (Shortcut Menu). So, the starting point is Toolbar. The Toolbar’s name alone will not change its class, except referencing it in programs, and we must see that the new name is not clashing with any of the other Built-in Menus. Let us define our MyMenuBar Toolbar into a real Menu bar.
- Click on the MyMenuBar item in the Toolbars List in the Customize Dialogue Control, if it is not already selected.
- Click Properties
- The Selected Toolbar & Toolbar Name Controls already filled with the menu name. In the Type Property drop down list we can see three options: Menu Bar, Toolbar & Popup(Shortcut Menu). To define our Toolbar into a Menu Bar select Menu Bar from the list.
Leave the other properties as it is. While installing your Application for the Users you can change these properties to determine how to behave the Menu Bar. Click Close to come out of the Toolbar Properties Sheet. It is likely that the small empty toolbar that we have seen earlier while creating it, is now disappeared and wondering where it went. To find out remove the check mark on MyMenuBar item in the Toolbars Tab and put the check mark back again and repeat this process a few times in quick succession and you can see an empty Menu bar is playing hide and seek on the top. Once we have spotted our celebrity we can continue our work.
First we must create some meaningful menu headings with dropdown facility where we can add our Menu Options. Click on the Commands Tab of the Customize Control. Here, we have two set of List: Categories & Commands. In the Categories List the File item is already selected, if it is not select it now. In the Commands List we will be using the first two items: Custom & New for building our Menu Options. The Custom item is used for creating a single menu item with description only and New is used for creating single option with a Button Image and Description, which can be displayed with Image only, Text only or both. But both of these items will not work for a Drop-down List, which we see normally when we click on File, Edit, or View Menus. We have to use another control for that.
Move the Scrollbar down in the Categories List and you will find an item called New Menu at the bottom of the list, select it. After selecting it, in the Commands List at the right side you will find a New Menu option. This Menu is a drop-down list like control. We need all these three options to build our Custom Menu Bar.
- Click and drag the New Menu item from the Commands window and drop it on our new empty Menu Bar. After that click on it to display a small empty dropdown control where we will be adding our menu options.
- Right click on the New Menu to display the options to change its Name. Type &Main; (we need a different name in place of File we see everywhere) in place of New Menu in the Name: control and press Enter to close. The & (ampersand) symbol at the left side of M character of the word Main enables us to select the Main Menu by using Alt+M Keyboard shortcut instead of clicking. You can put the & symbol left side of any character in the name to use that character as a keyboard shortcut. The character that you have chosen will appear with an underline in the Menu Name. If you look at the Built-in Menu descriptions at the top you can see one character in each Menu Name is underlined. But you must be very careful while selecting the character and see that you are not setting up a clash with the built-in keyboard shortcuts.
For example: Assume that you have given & symbol at the left side of D in Data Files Menu and you are in the database window and the Forms Tab or Report Tab is active, if you execute the Alt+D keyboard shortcut, the selected Form, Report or whatever object currently have the focus on will open up in Design View. For safer side we will not give ampersand symbol in any of the other menu options for now.
We will create three more Menu headings: Data Files, Process, Reports, Utilities (another name for Tools). Follow the same steps explained above under 8 & 9 and create the Menu Headings.
We will mainly concentrate on Data Files, Process and Reports options for our own program/macro driven methods and in Main & Utilities Menus we will copy and add some essential built-in Options.
We will do the easier part first, adding built-in options into the Main & Utilities menu. For easy handling of our MyMenuBar we need to push it up above the Built-in Menubar so that we can easily copy and drop (I didn’t say drag and drop and you guessed it right) the Submenus or Options into our Menu. If you are not already in Customize option select Customize from Toolbars Submenu from View Menu. We will introduce four sample options: Close, Page Setup, Print and Exit into our Main menu from the Built-in File Menu.
There are too many references to use for creating Custom Menus/Toolbars. First time anything is difficult or may find too cumbersome, but further on you will find them easy and rewarding too.
- Click on the built-in File menu to display the drop-down list. Click and hold the mouse button on the Close menu item and press Ctrl key with the other hand. When you press the Ctrl key, a plus (+) symbol will appear next to the selection indicating that a copy of the selected option is going to be made rather than drag the option out and leave that area empty for the built-in File Menu. Now, drag the mouse up and point to the Main item of our Menu Bar to display the empty dropdown control. Drop the Close option there.
- Follow the same procedure for Page Setup, Print & Exit options to make a copy of each and place it one below the other, or in between wherever you prefer.
After dropping the menu items, if you prefer to define the option as part of a Group (for example: Page Setup & Print can be members of a common group) then right click only on the top item within the group and select Begin a Group from the displayed options menu. A horizontal line will appear above the selected option.
NB: Any changes that you have made in any of the Built-in MenuBars (for example: If you have dragged the Print option out of the File Menu rather than copying an instance of it, it will not be available in File Menu), Toolbars or Shortcut Menus can be restored to its original state. Select Menu Bars in the Toolbars Tab of the customize control and click the Reset Button.
- Follow the same procedure to introduce two options from the built-in Tools Menu into Utilities Menu: Spelling, User and Group Accounts from Security Submenu. The User and Group Accounts option is used by Users for changing their Login Password in a secured Application.
We will continue our discussion shortly on Data Files, Process & Reports Menu options where we plan to introduce our own simple Programs & and Macros to open Forms, Reports etc.