|
|
Comments and Discussions
|
|
 |

|
BCMenu cMenu;
BCMenu cPopUp;
int i=1000;
cMenu.CreatePopupMenu();
cMenu.AppendMenu(MF_STRING, i++, "Test 1");
cMenu.AppendMenu(MF_STRING|MF_CHECKED, i++, "Test 2");
cPopUp.CreatePopupMenu();
cMenu.AppendMenu(MF_POPUP,(UINT)cPopUp.GetSafeHmenu(),"PopUp");
cPopUp.AppendMenu(MF_STRING,i++,"Test 4");
cPopUp.AppendMenu(MF_STRING,i++,"Test 5");
//cPopUp.Detach(); if not comment crash in other function
CRect rect;
GetDlgItem(IDC_BUTTON1)->GetClientRect(&rect);
ClientToScreen(&rect);
cMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON ,
rect.left,rect.bottom,this);
cMenu.DestroyMenu();
/*
if "cPopUp.Detach();" is comment crash in "BOOL BCMenu::DestroyMenu()"
if "cPopUp.Detach();" is not comment crash in "void BCMenu::SynchronizeMenu(void)"
*/
|
|
|
|

|
Hi there,
first of all thanks for your contribution.
But I have a problem I can't handle.
In Debug-mode the menu works fine, but delivers X messages in the output box like
"Warning: unknown WM_MEASUREITEM for menu item 0xYYYY", with X being the number of menu items.
If I compile in Release-mode, the menu is just a vertical stripe of about 15px width, so the width could not be estimated correctly.
What I did:
I overrode OnMeasureItem in my class and did an explicit MeasureItem, which doesn't fail (while debugging, I see values, that should be correct), but the menu is still just a vertical stripe.
So I debugged a little more and got to the OnMeasureItem of CWnd, where the warning is generated (wincore.cpp#1297).
Noteworthy is that the method is called twice for each item-id. First, the item is not recognized as menu in #1316 (_AfxFindPopupMenuFromID delivers NULL). Then, the second time, it is recognized, and gets through the MeasureItem call (#1318).
I don't know what to do now...
Any help would be appreciated
Regards..
Addendum: the menu is implemented as a context menu in an ActiveX control (CListCtrl subclassed), embedded in a dialog based window.
modified on Monday, December 13, 2010 5:29 AM
|
|
|
|

|
Problem is more or less solved..
I still get the warnings that confuse me, but the visualisation error is gone.
What went wrong: mixing release-mode compilation of my application with a debug-mode compilation of the OCX-control doesn't do any good
After registering the release-mode comp. everything works fine..
|
|
|
|

|
Hmm... Well, the problem is still existant, but vice versa:
I compiled the ocx in release mode and gave it for implementation to a colleague. He - of course - compiles his program in debug mode. But if he tries to open the context menu, he gets a debug assertion..
Any hint would be appreciated!
|
|
|
|

|
Can't work in VS 2008, crashed when m_menu.LoadMenu(IDR_MYTYPE);
|
|
|
|

|
Hi
this is a very nice class. My icons appear very nicely. However, I want to use icon only, and remove the text, so I use:
menuView.SetMenuText(MY_MENU_COMMAND,"",MF_BYCOMMAND);
There are no more text, but there is a little gap on the right of the icon. How can I get ride of it?
Thanks!
Mat
|
|
|
|

|
I find the menu crops if I am using Russian text (in English windows).
Andrew
|
|
|
|

|
Hi, when i tried this owner draw menu, why did the DrawItem function are not being triggered??
Because when i tried other owner draw menu, even if i did not click the menu item[on the menu bar] it will trigger the DrawItem.
I'm trying to change the font's color of the menu item text[on the menu bar]
I already succeeded to change the font color of the submenu items.. which it will trigger DrawItem function when i click it.
is that a bug or ??
Regards,
KH
good
|
|
|
|

|
I used the BCMenu in my application, and it worked great. That was until I changed the menu text. My application can change languages on the fly.
I start my application in one language and set all the menu text. OnMeasureItem gets called to get the size of each menu as I use it. It will never be called again. I then change languages and change all the menu text. The problem is the menu sizes don't fit the new text.
I figured a way to fool windows into thinking that the menu text changed. It requires three extra lines in BCMenu.cpp:SetMenuText function. I'm using BCMenu 3.036
Hopefully this will help if anyone else is having trouble with this problem.
BOOL BCMenu::SetMenuText(UINT id, CString string, UINT nFlags/*= MF_BYPOSITION*/ )
{
BOOL returnflag=FALSE;
if(MF_BYPOSITION&nFlags)
{
UINT numMenuItems = m_MenuList.GetUpperBound();
if(id<=numMenuItems){
#ifdef UNICODE
m_MenuList[id]->SetWideString((LPCTSTR)string);
#else
m_MenuList[id]->SetAnsiString(string);
#endif
returnflag=TRUE;
}
<code>//BK: this forces windows to get the menu dimensions again after changing the menu text
int id2 = GetMenuItemID(id); //id in this case is the position
if (id2 != 0 && id2 != -1)
ModifyMenu(id, MF_BYPOSITION, id2, ""); //no text needed as it //BK: end of changes</code>
}
else{
int uiLoc;
BCMenu* pMenu = FindMenuOption(id,uiLoc);
if(NULL!=pMenu) returnflag = pMenu->SetMenuText(uiLoc,string);
}
return(returnflag);
}
|
|
|
|

|
Your code makes my icon to disapear...
Mat
|
|
|
|
 |
|
|
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,297 |
| Downloads | 13,620 |
| Bookmarked | 263 times |
|
|