FAQ (expopupmenu)
Exontrol.COM Software - Frequently Asked Questions - ExPopupMenu Component
1:
The control's release notes can be found on our web site, looking for the Release Notes column in the control's main page. Click here for direct link.
2:
The control provides two properties: Show and ShowAtCursor. The Show property requires x and y coordinates where the popup menu will be displayed. The ShowAtCursor property doesn't require any additional parameters. Both properties return the identifier of selected item. The Command property can be used to retrieve the selected item. For instance:
Dim i As Long
i = PopupMenu1.ShowAtCursor()
3:
The Items property of control retrieves the collection of items. The Items property gets an object of Menu type. The EXPOPUPMENULibCtl.Menu object exports methods like Add, Remove, Clear to add or remove items at runtime. For instance, the following sample adds a separator item:
With PopupMenu1.Items
        .Add "", Separator  ' Adds a separator item
End With
The following sample adds a new sub menu to the control:
With PopupMenu1.Items
        With .Add("Popup", SubMenu).SubMenu
            .Add "Item 1", Default, 1001
            .Add "Item 2", Default, 1002
            .Add "Item 3", Default, 1003
        End With
End With

The following sample adds a new item and associates an image to it:

With PopupMenu1.Items
        With .Add("Item 1", Default, 1001)
            .Image = 1
        End With
End With 
4:
In VB environment, the F2 opens the object browser. Select the EXPOPUPMENULibCtl item, and you have the entire list of exported objects, properties and methods.
5:
Yes. The control can be used in a script environment such as IE. The setup installs a WEB folder where you can find the sample.htm file. The sample shows how ExPopupMenu and ExMenuButton controls work.
6:
Yes. The control's library provides a MenuButton object that helps you to attach a popup menu to a command button. The following code associates a popup menu object to the menu button control:
Set MenuButton1.Menu = PopupMenu1

The menu button's caption is not changed automatically when the user selects a new item from the popup menu, so you have to handle the Click event like in the following sample:

Private Sub MenuButton1_Click()
    If (MenuButton1.LastID > 0) Then
        MenuButton1.Caption = PopupMenu1.Command(MenuButton1.LastID).Caption
        MenuButton1.Picture = PopupMenu1.Command(MenuButton1.LastID).Image
    End If
    Debug.Print "Apply the changes for ... " & MenuButton1.Caption
End Sub
You can notice that LastID property of the MenuButton object retrieves the last identifier selected by the user. 
7:
More than that, the version 1.0.1.4 adds the ability to use built-in HTML format in item's caption. The built-in HTML tags supported are:
  • <b>  bold </b>
  • <u> underline </u>
  • <s> strikeout </s>
  • <i> italic </i>
  • <fgcolor = FF0000> fgcolor </fgcolor>
  • <bgcolor = FF0000> bgcolor </bgcolor>
  • <br> breaks a line. 
  • <solidline> draws a solid line
  • <dotline> draws a dotted line
  • <upline> draws the line to the top of the text line
  • <r> aligns the rest of the text line to the right side

The following sample bolds an item:

PopupMenu1.Command(1).Caption = "<b>" & PopupMenu1.Command(1).Caption & "</b>"
8:
Open the control's menu editor ( by selecting 'Properties...' from object's context menu ), select an item using the mouse, and then press CTRL + arrow key to move the selected item to a new position.
9:
Open an Windows Explorer window and drag icon files, or files that contains icons as internal resource to the images list panel.
10:
Yes. The control provides a method Attach that helps you to attach a menu to a window. When you don't need anymore the menu bar, the Detach method should be called. If you are using the VB environment, make sure that you have the NegociateMenus property of the Form to False. By default it is True. The following sample attaches a menu bar to the form's window:
PopupMenu1.Attach Me.hWnd
11:
Please check the ForeColor and BackColor properties. They will help you to customize the general foreground and background color used. If you are trying to change the foreground or background property for a specific item you should look at the "It would be nice to have the ability to mark some items using bold or italic font attribute. Is this possible?". Using the built-in HTML feature you can specify whatever you want for an item.
12:
The control provides a CloseOnClick property. The CloseOnClick property specifies whether the control is closed when the user clicks. If the CloseOnClick property is True, the control will be automatically closed when the user clicks the mouse. If the CloseOnClick property is False, the popup menu is closed when the mouse cursor leaves the client area of the popup menu. The CloseOnClick property should be called at run time, just before ShowAtCursor or Show method.
13:
Unfortunately you cannot add new items to the popup menu, while it is shown ( opened ). You can add new items only if the popup menu is not opened.
14:
The Gray and Highlight properties of Item object helps you to specify how the item appear when it is disabled and selected. For instance, the following sample adds an unselectable item:
With PopupMenu1
        With .Items.Add("My <b>title</b>", Default, 1234)
            .Highlight = False
            .Enabled = False
            .Gray = False
        End With
End With
15:
Use a syntax like follows:
axMenuButton1.Menu = ( axPopupMenu1.GetOcx() as EXPOPUPMENULib.PopupMenu );
16:
The differences between exMenu and exPopupMenu components include:
  • the exPopupMenu displays a shortcut, vertical or context menu, since the exMenu displays a top level menu for a form or dialog.
  • the exPopupMenu uses the system context menu to display items, the exMenu doesn't subclass any window or system menu.
  • only one exPopupMenu can be shown at one time, since a form may display multiple exMenu instances in the same time.
  • the exMenu provides the ability to host ActiveX controls, the exPopup can't display ActiveX inside.
  • the exPopupMenu can be assigned to a button using the MenuButton object, since the exMenu has not such of an option.
  • At runtime, the exPopupMenu is a modal window and can't be a child window of a form or dialog, since the exMenu component is a child of a form or dialog.
  • the exMenu can use accelerator keys, the exPopupMenu doesn't use accelerator keys.
  • and more.
17:
The Command event is fired only if the menu is attached to a form using the Attach method. The Command event is never fired if you display the control using the Show or ShowAtCursor properties. Use the Attach method to attach a menu bar to a dialog or a form. The Command event is fired when user clicks or selects an item from the dialog/form's menu bar.
General Questions