A Cool Looking Menu For Easier Navigation
Download Source Code and Demo
Features:
- Unlimited entries
- Displays 32X32 Icons with text
- Text wraps to multiple line
- Button pops up when the mouse is on the image
- Owner Drawn and easily customize the source!
- Can be used in SDI or MDI
Usage Instructions:
Open the project in which you want to add this feature. From the Project menu, select Add To Project and then Components & Controls. From Developer Studio Components, select Dialog Bar component and click insert. When prompted, change the name of the dialog bar to ContentMenu and the member variable to m_wndContentMenu.
Also change the default docking side to left and click OK and close all the Component Gallery windows.
Now, open the CG_IDD_CONTENTMENU from the dialog resource and replace the default TODO... static control with a new List Box (it is a list box and NOT list control). Change the default ID from IDC_LIST1 to IDC_LIST_CONTENTS in the property window. Also change the following style:
- Owner Draw - Variable
- No Sort
- Optionally - change the extended style to Modal Frame
- Add the provided ContentMenu.cpp to the project and include the ContentMenu.h in the mainfrm.h.
- Create a variable for the class CContentMenu in the CMainFrame object in mainfrm.h
CContentMenu m_ContentMenu;
- In the OnCreate function of CMainFrame, add the following code
m_ContentMenu.SubclassDlgItem (IDC_LIST_CONTENTS, &m_wndContentBar); m_ContentMenu.SetItems(ContentInfo, sizeof(ContentInfo) / sizeof(CONTENT_ITEMS));
ContentInfo is a regular C structure defined in the mainfrm.cpp which holds the information about the items to be displayed. It is created as
// Menu Information for the Content Bar static CONTENT_ITEMS ContentInfo[] = { {IDI_COMPOSE, "Main View"}, {IDI_FINISHED, "Another View"}, {IDI_FILED, "Another View"}, {IDI_CALENDAR, "Another View"}, };where IDI_... are the 32x32 icons.
Now, you should be able to compile and see how it works. To get the selection from the CMainFrame object, you have to add the code to handle the ON_LBN_SELCHANGE message. Normally, you would do this by using the Class Wizard, but in this case, you have to do it manually:
- Add the following prototype in the mainfrm.h
afx_msg void OnSelchangeListContents();
- Add the following in mainfrm.cpp
ON_LBN_SELCHANGE(IDC_LIST_CONTENTS, OnSelchangeListContents)
before the line
END_MESSAGE_MAP()
- Add the following function also in mainfrm.cpp
void CMainFrame::OnSelchangeListContents() { switch (m_ContentMenu.GetCurSel()) { case 0: AfxMessageBox("You have selected First Item"); break; case 1: AfxMessageBox("You have selected Second Item"); break; case 2: AfxMessageBox("You have selected Third Item"); break; case 3: AfxMessageBox("You have selected Fourth Item"); break; } }
NOTE: THIS SOURCE CODE IS PROVIDED AS IS AND I WILL NOT BE RESPONSIBLE FOR ANY DELAYS OR DAMAGES CAUSED BY USING IT. USE AT OWN RISK.
Last updated: 10 May 1998

Comments
GOOD ONE..IT WORKS IF THE CONTEXTMENU.CPP AND .H ARE ADDED TO PROJECT
Posted by Legacy on 09/11/2003 12:00amOriginally posted by: SIBILSALIM
hI FRIENDS
ReplyTHE LINKING ERROR CAN BE ELIMINTAED BY ADDING THE TWO FILE CONTEXTMENU.CPP AND .H TO PROJECT..
ITS EASY ..LOAD THE PROJECT FROM DSW...AND U GET A LINK ERROR WHEN U TRY TO RUN IT..TAKE PROJECT FORM MENU
SELECT ADD TO PROJECT..ADD FILES..SELECT THE TWO FILES...
NOW RUN IT..IT WORKS...HAVE A GOOD TIME..
DO FEEL FREE TO MAIL ME AT SIBILSALIM@OPERAMAIL.COM
BYE
link problems: read this
Posted by Legacy on 08/02/2002 12:00amOriginally posted by: Daniel L
If you can't link the demo application, add the ContentMenu.h and .cpp files to the project. Btw, nice menu.
Reply
A Cool Looking Menu For Easier Navigation
Posted by Legacy on 01/22/2002 12:00amOriginally posted by: OMAR VARGAS
I CANT FIND THE FILE RESOURCE.H
Reply!HELP ME
RE:article contributed by Shekar Narayanan,A Cool Looking Menu For Easier Navigation
Posted by Legacy on 10/29/2001 12:00amOriginally posted by: KC
HELP!!!!
ReplyWhen i downloaded the source code,unziped amd run in VC++,
there was an error: fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
Error executing cl.exe.
Help me please..and whats the difference between the source code and the Demo?
because when i unzipped the demo file,the folder contains the display icon but the source dosen't...
HElp PLEASE!!!
If possible email me to help me solve!
link error
Posted by Legacy on 01/04/2001 12:00amOriginally posted by: moon jung il
ReplyProblems making it work
Posted by Legacy on 11/01/2000 12:00amOriginally posted by: Neo
Replynewbie question
Posted by Legacy on 03/07/2000 12:00amOriginally posted by: Blind
I know this is an idiotic question but how can I call up
Replythe dialog and/or change view using these cool looking buttons...??? Please help!!!
Make it Resizeabe Easily!
Posted by Legacy on 07/26/1999 12:00amOriginally posted by: Viktor
What about resizeable menu based on Your ownerdrawn listbox? You can implement it simply with a help of a class found at
/docking/docking_window2.shtml
It'll be cooler!
Replyreal cool menu! but...
Posted by Legacy on 06/14/1999 12:00amOriginally posted by: tonio
How can I destroy and restore the ContentMenu before and after the Print Preview. Is there a way?
ReplyTIA.
Can't run in vc4
Posted by Legacy on 12/21/1998 12:00amOriginally posted by: dharry
Tried to use your app in vc4 but could not get it to run.
Reply