|(Declarations)||Declarations||Declarations and private variables for the modMenus module.|
|AddBitmapToMenu||Procedure||Set the 'checked' and 'unchecked' bitmaps to be used with a form's menus.|
|SetEditMenuItemStates||Procedure||Tests a control (text box or rtf control) to set the Enabled property of an Edit menu's Cut, Copy, Paste, and Undo buttons appropriately. Call this function from the OnClick event of the top-level Edit menu. Normally this top-level menu item does not have any code associated with it. By placing this code here, it is possible to set the states of the Edit sub-menu items before they become visible after clicking on the Edit menu item.|
' Example of modMenus ' ' To try this example, do the following from Visual Basic 6: ' 1. Create a new form ' 2. Add a text box called 'txtTest' ' 3. Create the menu structure consisting of a top-level menu called 'mnuEdit' ' 4. Underneath this menu, create menu items called 'mnuEditCut', 'mnuEditCopy', 'mnuEditPaste' and 'mnuEditUndo' ' 5. Create another top-level menu item called 'mnuCustom' ' 6. Underneath this menu, create menu items called 'mnuCustomItem1', and 'mnuCustomItem2' ' 7. The complete menu structure should look something like this in the VB6 Tools, Menu Editor Dialog: ' ' Caption Menu Control Name ' ----------------------------------- ' &Edit mnuEdit ' ....Cut mnuEditCut ' ....Copy mnuEditCopy ' ....Paste mnuEditPaste ' ....Undo mnuEditUndo ' Custom mnuCustom ' ....Item 1 mnuCustomItem1 ' ....Item 2 mnuCustomItem2 ' 8. Add an image control named 'imgChecked' to the form. It may be invisible ' 9. Add an image control named 'imgUnchecked' to the form. It may be invisible ' 10. Paste all the code from this example to the new form's module. ' This example assumes that the sample files are located in the folder named by the following constant. Private Const mcstrSamplePath As String = "C:\Total Visual SourceBook 2013\Samples\" Private Sub Form_Load() imgChecked.Picture = LoadPicture(mcstrSamplePath & "Checked.bmp") imgUnchecked.Picture = LoadPicture(mcstrSamplePath & "Unchecked.bmp") ' Example of AddBitmapToMenu ' 'Set pictures for first subitem on second main menu AddBitmapToMenu Me.hWnd, CLng(imgUnchecked.Picture), CLng(imgChecked.Picture), 1, 0 'Set pictures for second subitem on second main menu AddBitmapToMenu Me.hWnd, CLng(imgUnchecked.Picture), CLng(imgChecked.Picture), 1, 1 End Sub Private Sub mnuCustomItem1_Click() mnuCustomItem1.Checked = Not mnuCustomItem1.Checked End Sub Private Sub mnuCustomItem2_Click() mnuCustomitem2.Checked = Not mnuCustomitem2.Checked End Sub Private Sub mnuEdit_Click() ' Example of SetEditMenuItemStates SetEditMenuItemStates txtTest, mnuEditCut, mnuEditCopy, mnuEditPaste, mnuEditUndo End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP