-
December 17th, 2008, 04:32 AM
#1
checkmark/icon in submenu[owner draw menu]
Hi, Is there any ways for me to add a check marks or icon into the submenu?
I'm currently creating owner draw menu.
So far, I only able to print out the text into the submenu... I failed to put the check mark/icon into it.. Any help will be appreciated
Currently all my drawing are done at:
DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
}
Regards,
KH
Last edited by karhong; December 17th, 2008 at 04:34 AM.
-
December 17th, 2008, 11:01 AM
#2
Re: checkmark/icon in submenu[owner draw menu]
See MSDN owner-drawn menu samples
-
December 17th, 2008, 07:17 PM
#3
Re: checkmark/icon in submenu[owner draw menu]
Check out the
ON_UPDATE_COMMAND_UI() macro. This allows you to update menu items dynamically, and enable/disable menu items as well as set the checkflag.
Here's a sample for a 'large view' menu item.
In your message map, add this line...
Code:
ON_UPDATE_COMMAND_UI(ID_EDIT_SHOWLARGE, OnUpdateCommand)
And here's a sample function...
Code:
void CMainFrame::OnUpdateCommand(CCmdUI* pCmdUI)
{
switch(pCmdUI->m_nID) {
case ID_EDIT_SHOWLARGE:
pCmdUI->SetCheck(m_large_view);
break;
}
}
The pCmdUI pointer passed in allows many different menu items to share the same OnUpdateCommand function, or you can use different functions for different menu items.
This OnUpdateCommand() function is called each time the menu is displayed, so it's a handy way to make sure your menu items are updated each time they are needed.
As for the icons, you might want to start using the new MFC classes in VS2008 - these support icons and everything else you need for nice menus. You just create a toolbar icon with the same ID as the menu item, and it picks up the toolbar icon and puts it in the menu bar. I'm using the old BCG classes from before Microsoft bought them, so I haven't used the Microsoft versions yet, but they are essentially the same functionality.
-
December 17th, 2008, 08:46 PM
#4
Re: checkmark/icon in submenu[owner draw menu]
oh thanks !!
it worked out now ! ^^
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|