|
|
Comments and Discussions
|
|
 |

|
Great Job Man!
This is one of the most awsome tutorials iv seen..
Its Very cool. Has alota features. and is so dam simple.
Thx alot.
Keep up the good work
www.Static-Code.com
|
|
|
|

|
I have some menus that have been loaded from resource that then go through a routine to merge menu items from default menu. Since I have no resource with all the items, I'd like to take that HMENU and import it into a BCMenu. Does this seem doable? I took a stab at it but I'm still having problems getting it to work. Here's what I have.
BOOL BCMenu::ImportMenu(HMENU hMenu, BOOL bTopLevel)
{
if (!Attach(hMenu))
return false;
int count = GetMenuItemCount();
for(int i=0; i < count; ++i) {
CString str;
CMenu *pSub = GetSubMenu(i);
UINT nFlags = GetMenuState( i, MF_BYPOSITION );
int nID = GetMenuItemID(i);
GetMenuString(i,str,MF_BYPOSITION);
nFlags &= ~MF_STRING;
if (bTopLevel)
nFlags |= MF_POPUP;
else
nFlags |= MF_OWNERDRAW;
if(nFlags & MF_POPUP){
if (!pSub) {
pSub = new CMenu;
}
nID = (int)((HMENU)pSub->m_hMenu);
m_AllSubMenus.Add((HMENU)pSub->m_hMenu);
m_SubMenus.Add((HMENU)pSub->m_hMenu);
}
BCMenuData *mdata = new BCMenuData;
m_MenuList.Add(mdata);
mdata->SetString(str);
mdata->menuIconNormal = -1;
mdata->xoffset=-1;
mdata->nFlags = nFlags;
mdata->nID = nID;
if (bTopLevel) {
CMenu::ModifyMenu(i,nFlags | MF_BYPOSITION, nID, str);
} else {
CMenu::ModifyMenu(i,nFlags | MF_BYPOSITION, nID, (LPCTSTR)mdata);
}
if (pSub) {
if (pSub->m_hMenu) {
BCMenu *pMenuNew = new BCMenu();
pMenuNew->ImportMenu((HMENU)pSub->m_hMenu, FALSE);
}
}
}
Detach();
return(TRUE);
}
Thanks for your help!
Kim
|
|
|
|

|
The problem with this is that the HMENU is most likely associated with a CMenu object, not a BCMenu object. So the only real way to do this, is have your function create a BCMenu object, return its handle, then use this new handle by substituting it for the old handle. This is the only way you can get it to call BCMenu's DrawItem and MeasureItem functions when you make it ownerdrawn. It is possible to call BCMenu's functions for CMenu objects but this is more much more difficult and error prone. You basically got to intercept the DrawItem and MeasureItem messages and process them yourself.
Yuk.
Brent
|
|
|
|

|
I can't add bitmaped checkmark in popup menu. Ideas?
Also when use somthing like this:
BCMenu popup;
popup.LoadMenu(IDR_POPMENU);
BCMenu *pSub = ( BCMenu * ) popup.GetSubMenu(0);
CPoint pos;
GetCursorPos(&pos);
popup.CheckMenuItem( ID_P1, MF_BYCOMMAND | MF_CHECKED );
popup.ModifyODMenuW( NULL, ID_P1, &bmp ); //loaded in init();
pSub->TrackPopupMenu(0, pos.x, pos.y, this, NULL);
popup.DestroyMenu();
popup menu display a dark rect before ID_P1 menu item.
|
|
|
|

|
I'm using your menu in a dialog. When I use "Styles->Border->Thin" and "Extended Styles->Static edge" in the dialog properties and using a menuitem as a non-popup item (like a button in the menu), the icon is to big and is drawed into the dialog frame. How to fix this?
|
|
|
|
|
|

|
I want to add a popup menu
so as follow
BCMenu Menu,*pSub, *pSelect;
Menu.LoadMenu(IDR_TRAY_MENU);
pSub = (BCMenu *)Menu.GetSubMenu(0);
pSelect = (BCMenu *)pSub->GetSubMenu(6);
pSelect->AppendMenu(MF_POPUP, i, (LPCTSTR)Temp.strAccountName);
but debugging I find the address of Variant pSelect is NULL
Why? Can you help me?
|
|
|
|

|
Duplicate the problem in the example application and send it to me.
Brent
|
|
|
|

|
Leona,
Here's an example similar to what you want to do. Just replace the code in the below function with the code in member function by the same name in the example that comes with the class.
void CMymenuView::OnRButtonDown(UINT /*nFlags*/, CPoint point)
{
popmenu.LoadMenu(IDR_RIGHT_CLICK);
popmenu.LoadToolbar(IDR_TOOLBAR);
popmenu.LoadToolbar(IDR_MAINFRAME);
ClientToScreen(&point);
BCMenu *psub = (BCMenu *)popmenu.GetSubMenu(0);
BCMenu *pSelect = (BCMenu *)psub->GetSubMenu(1);
if(pSelect){
pSelect->AppendMenu(MF_STRING,ID_WINDOW_TILE_HORZ,_T("&Tile"));
pSelect->ModifyODMenu(NULL,ID_WINDOW_TILE_HORZ,IDB_WINDOW_TILE);
}
psub->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,AfxGetMainWnd());
popmenu.DestroyMenu();
}
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
This class implements an owner drawn menu class that mimics the menu style used in XP, Office and Visual C++
| Type | Article |
| Licence | CPOL |
| First Posted | 18 Nov 1999 |
| Views | 758,269 |
| Downloads | 13,613 |
| Bookmarked | 263 times |
|
|