The new vbAccelerator Site - more VB and .NET Code and Controls
Source Code
1 VB 5 Custom Controls &nbsp
&nbsp

vbAccelerator PopMenu2 Object

The simplest way to get icons into VB menus. 100% support for VB's menuing features - add icons to any menu fast!



NOTE: this code has been superceded by the version at the new site.




PopMenu2 Object in Action

Download Code
VB5 code VB5 Component Binary (18kb) VB6 code VB6 Component Binary (18kb)
VB5 code VB5 Demonstration Project (66kb) VB6 code VB6 Demonstration Project (67kb)
VB5 code VB5 Full Source Code (99kb) VB6 code VB6 Full Source Code (99kb)
Required Files:
  • vbAccelerator SSubTmr.DLL for VB5
  • vbAccelerator VB5 ImageList control
  • Required Files:
  • vbAccelerator SSubTmr6.DLL for VB6
  • vbAccelerator VB6 ImageList control

  • Overview
    There are various controls for drawing menus with icons in at this site (and some code for doing the same sort of thing elsewhere). But so far these objects and code have been quite difficult to implement. This happens because these objects provide support for creating arbitrary menus at runtime - something VB has never been able to do. The downside to this extra functionality is that these menu controls must implement their own structures to hold the menu information.

    This object is introduced here for one reason: to make it possible to add icons to any type of VB project with almost no coding at all - and at the same time to ensure 100% compatiblity with VB's menuing features, including the Visible and WindowList properties.

    What's Here, What's Not
    This DLL might be easy to use, but it doesn't leave out features. You get the ability to add an icon to any menu item, to customise the colours and fonts shown in the menu, to set a background bitmap to appear tiled into the menu background and to set the highlight mode to either standard, gradient or button style. For the latest UI look, separators also draw in the new Office 2000 style.

    What you can't have with this release is the ability to create arbitrary menus at runtime. You can use VB's Load and Unload to increase the size of a menu array, but that does not allow you to create new menu levels that weren't there at design time. Another restriction is that when setting icons for menu items, you must key the icon against the menu item's caption property - and that means that if the caption changes, you must also change the menu item/icon association too.

    In Use
    Using this object is very simple. There are only four methods and properties which are used:

    • Attach
      Starts the Icon Menu processing for the form with the hWnd passed in as the first parameter.
    • ImageList
      Sets an ImageList to draw icons from.
    • IconIndex
      Associates the zero-based index of the image within the ImageList with any menu item having the caption passed in as the second parameter.
    • IconItemCaptionChanged
      If you change the caption of an item with an icon, you can inform the component of the change using this method. The component responds by changing its associate to reflect the new caption.
    And really, that's all you need to know to make the object work!

    Further properties are provided in the control primarily to allow you to change the appearance of your menus:
    • Colours
      MenuBackgroundColor, ActiveMenuForeColor and InActiveMenuForeColor can all be changed to any colour you want, or set them to -1 for the default behaviour.
    • Font
      You can set the font for the menu to any font you wish, or set this property to Nothing to get the default Menu font.
    • BackgroundPicture
      Set this property to a StdPicture object and VB will tile it into the background of all the menus. Setting it to Nothing removes the picture.
    • Highlight Styles
      The menu highlight style can be set to Standard, Gradient or Button using the HighlightStyle property.
    I've found this component a really simple way to add icon menus to my projects. Hope it helps you too!
    &nbsp
    &nbsp


    TopBack to top
    Source Code - What We're About!Back to Source Code

    &nbsp


    NOTE: this code has been superceded by the version at the new site.



    AboutContributeSend FeedbackPrivacy

    Copyright 2000, Steve McMahon ( steve@vbaccelerator.com). All Rights Reserved.
    Last updated: 21 March 2000