Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

Environment: VC6 SP2,98

With this self drawing menu, replicating the Windows start menu is a snap. It can draw True color icons, a bitmap menu title and progress bars. The usage is similar to (if not simpler than MFC's CMenu class). If there is a pop up menu named IDR_MYPOPUP, the items can be made owner drawn with the following statements:

CEZMenu ezmenu;
CMenu* pmenu;
//for all items->call ezmenu.InsertOwnerDrawnMenu.

Various functions available for inserting menu items are,

void InsertOwnerDrawnMenuItem
UINT nID/*The Id of the menu item*/
,LPEZMENUITEMDATA lpez/*Data->Explained below*/
,int nPos=0/*Insert Where?*/

void AppendOwnerDrawnItem(UINT nID,LPEZMENUITEMDATA lpez);

void ModifyOwnerDrawnMenuItem(int nPos,UINT nID,int nTotalCheck,LPEZMENUITEMDATA lpez);//Doubtful->suggestions welcome

Menu Item Data->The properties of the menu item are received by a class called CEZMenuItemData whose members are self explainatory.

class CEZMenuItemData
HICON hItemIconLarge;//Large Icon Handle
HICON hItemIconSmall;//Small Icon Handle
CString strItemText;//Menu string
BOOL bChecked;//Is item checked?
BOOL bSeperator;.
//Why do you need an Owner drawn menu to draw a **seperator**?
BOOL bProgress;//Progressbar needed?
int nProgress; //if bProgress what is the percentage?
//Useful typedef

If a bitmap is needed, then there is a hitch. The number of items that would lay beside the bitmap should be specified as well as the size of the bitmap.

void SetTotalItems(int nItems);//necessary.
void SetMenuBitmap(HBITMAP hBitmap);
void SetBitmapDimension(CSize sz);
void SetExtensionColor(COLORREF clrExtend);
//if bitmap is shorter than menu height a rectangle whose width is same as that of the bitmap
//and whose height compensates for a shor bitmap is painted in clrExtend

It is fairly simple to modify the code to paint gradient rect by getting two colors from the user.In case a progressbar is needed the percentage unfilled part should be specified. I've done this because more often than not, we only have the unfilled percent rather than the filled ones.

Though the code works fine and I did not encounter any problems with it, there is a major bug which to my surprise does'nt show at all. I have not deleted objects and didn't free resource handles (I was unable to do it). I would like Codeguru regulars to clarify this point.

I think the demo project and comments in the code would do the rest of the explaination.


Download demo project - 27 Kb
Download source - 4 Kb


  • Memory Leak..!!!

    Posted by Legacy on 03/20/2001 08:00am

    Originally posted by: Dillip

    There is Memory leak in the programe ...!

  • Memory Leak..!!!

    Posted by Legacy on 03/20/2001 08:00am

    Originally posted by: Dillip

    There is Memory leak in the programe ...!

  • Bug fix memory leaks

    Posted by Legacy on 11/16/1999 08:00am

    Originally posted by: Gilestiel

    Add a member in CEZMenu :

    CPtrArray m_arrData ;

    When you create a CEZMenuDataItem ( new CEZMenuData ) , add the new item in m_parrData :

    m_parrData.Add( lpez ) ;

    And write the correct destructor of CEZMenu ;

    while( m_parrData.GetSize() != 0 )
    delete (CEZMenuItemData*) m_parrData.GetAt(0) ;
    m_parrData.RemoveAt(0) ;



  • Submenu needed for real application

    Posted by Legacy on 09/16/1999 07:00am

    Originally posted by: bob

    i try to modify your code to implement submenu.
    however, no progress till now.
    Could think about it for a while.

  • On Integration with Frame Windows

    Posted by Legacy on 07/28/1999 07:00am

    Originally posted by: Viktor

    Your menu likes cool. All the more it has the ability to contain non-standard elements like progress indicator from the sample code distributed. But the main idea is to integrate ownerdrawn menus into existing Windows GUI system with minimum changes to client classes. As I can expect Your menu can represent only popups or some other kind of menus being created explicitly, but not a menu within the main frame window of an application for instance. Unfortunately we cannot integrate such a menu into the frame without any support from it, a user should add some stuff into the frame class manually or derive it from one obtained from the developer. There are samples of both paradigms on CodeGuru.

    And next, I don't know how it can (or cannot) work with submenus. It's important for the most real applications.

    Thank You.

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date