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 toget the menu dimensions again after changing the menu text
int id2 = GetMenuItemID(id); //id in this caseis the position
if (id2 != 0 && id2 != -1)
ModifyMenu(id, MF_BYPOSITION, id2, ""); //no text needed as it's owner-drawn
//BK: endof changes</code>
}
else{
int uiLoc;
BCMenu* pMenu = FindMenuOption(id,uiLoc);
if(NULL!=pMenu) returnflag = pMenu->