Home > Code Library > SmartMenuXP > Add

Last Update 01 Nov 2001

 


Search:



  

Options:

   

   

   

   



SmartMenuXP Reference

Add Method

Adds a new menu item and returns its ID.

Syntax

object.Add (Parent, [Key], [Style], [Caption], [Picture], [KeyMask], [KeyCode], [Value], [Enabled], [Visible] )

The Add syntax has these parts:

Part Description
object An object expression that evaluates to a SmartMenuList object.
Parent Required. A string or numeric expression that specifies the menu item parent. In order to specify the parent you can either use its key or its ID.
Key Optional. A string expression that specifies the menu item key. 
Style Optional. A numeric expression that specifies the menu item style as described in settings. 
Caption Optional. A string expression that specifies the text to be displayed on the menu item. 
Picture Optional. A StdPicture reference that specifies the image to be displayed on the menu item. 
KeyMask Optional. A numeric value that specifies the ShiftConstants for the menu item shortcut as described in settings.
KeyCode Optional. A numeric value that specifies the key code for the menu item shortcut.
Value Optional. A numeric value that specifies the status of the menu item as described in settings. This value has an effect only with checkboxes.
Enabled Optional. A boolean value that specifies whether the menu item will respond to events.
Visible Optional. A boolean value that specifies whether the menu item will be visible.

Settings

The settings for Style are:

Constant Setting Description
smiNone 0 (Default) None This style is equal to smiPicture.
smiPicture 1 The menu item will display a Picture on its left side.
smiCheckBox 2 The menu item will display a check box on its left side.
smiSeparator 3 The menu item will act as a separator.

The settings for KeyMask are:

Constant Value Description
vbShiftMask 1 SHIFT key bit mask.
VbCtrlMask 2 CTRL key bit mask.
VbAltMask 4 ALT key bit mask

The settings for Value are:

Constant Setting Description
smiUnChecked 0 (Default) None The checkbox is unchecked.
smiChecked 1 The checkbox is checked.

Remarks

If the function fails the return value will be 0. Otherwise it will return the ID of the new menu item.

With SmartMenuXP1.MenuItems
    .Add 0, "keyFile", , "&File"
    .Add "keyFile", , , "&Open...", GetPic(1), vbCtrlMask, vbKeyO
    .Add "keyFile", , , "&Save...", GetPic(2), vbCtrlMask, vbKeyS
    .Add "keyFile", , smiSeparator
    .Add "keyFile", , , "E&xit", , vbAltMask, vbKeyQ
End With

 

 
Copyright © 2001, Andrés Pons (andres@vbsmart.com). All rights reserved.