MenuItems' Icons are not Displaying properly in MFC
-
Hello Friends I was using code
void CMainFrame::OnInitMenuPopup(CMenu* a, UINT b, BOOL c)
{
FrameWnd::OnInitMenuPopUp( a,b,c);
}And this one displaying MenuItems correctly. Now,i trying to add icons to MenuItems.So for that I am using extenal CoolMenuManager to show up Icons with menuItems. Here is code for this :
void CMainFrame::OnInitMenuPopup(CMenu* a, UINT b, BOOL c)
{
if(m_menuManager.InitMenuPopup(a,b,c))
FrameWnd::OnInitMenuPopUp( a,b,c);
}
Now, in this case,If i use External fn then only icons are showing up. But as now, i am calling frameWnd::OnINitMenupopup too then icons are coming and strings are not coming properly and only for some menuItems and even menuList is coming Wider covering whle screen.Any Ideas? Regards Yogesh
-
Hello Friends I was using code
void CMainFrame::OnInitMenuPopup(CMenu* a, UINT b, BOOL c)
{
FrameWnd::OnInitMenuPopUp( a,b,c);
}And this one displaying MenuItems correctly. Now,i trying to add icons to MenuItems.So for that I am using extenal CoolMenuManager to show up Icons with menuItems. Here is code for this :
void CMainFrame::OnInitMenuPopup(CMenu* a, UINT b, BOOL c)
{
if(m_menuManager.InitMenuPopup(a,b,c))
FrameWnd::OnInitMenuPopUp( a,b,c);
}
Now, in this case,If i use External fn then only icons are showing up. But as now, i am calling frameWnd::OnINitMenupopup too then icons are coming and strings are not coming properly and only for some menuItems and even menuList is coming Wider covering whle screen.Any Ideas? Regards Yogesh
-
Without knowing what
CoolMenuManager
does it is impossible to even hazard a guess.One of these days I'm going to think of a really clever signature.
Hello I found something interesting tht icons and text of menuItem is coming fine Except the menuList. As i click on any menu,menuList pops up and that list is coming wider,covering almost full screen. I checked that OnMeasureItem which calculates ItemWidth and height is Having some Prob.As I Converted this from VC6 to VS2010.
BOOL CCoolMenuManager::OnMeasureItem(LPMEASUREITEMSTRUCT lpms)
{
ASSERT(lpms);
CMyItemData* pmd = (CMyItemData*)lpms->itemData;
ASSERT(pmd);
if (lpms->CtlType != ODT_MENU || !pmd->IsMyItemData())
return FALSE; // not handled by meif (pmd->fType & MFT\_SEPARATOR) { // separator: use half system height and zero width lpms->itemHeight = GetSystemMetrics(SM\_CYMENU)>>1; lpms->itemWidth = 0; } else { // compute size of text: use DrawText with DT\_CALCRECT CWindowDC dc(NULL); // screen DC--I won't actually draw on it CRect rcText(0,0,0,0); CFont\* pOldFont = dc.SelectObject(GetMenuFont()); dc.DrawText(pmd->text, rcText, DT\_MYSTANDARD|DT\_CALCRECT); dc.SelectObject(pOldFont); // height of item is just height of a standard menu item lpms->itemHeight= max(GetSystemMetrics(SM\_CYMENU), rcText.Height()); // width is width of text plus a bunch of stuff int cx = rcText.Width(); // text width cx += CXTEXTMARGIN<<1; // L/R margin for readability cx += CXGAP; // space between button and menu text cx += m\_szButton.cx<<1; // button width (L=button; R=empty margin) // whatever value I return in lpms->itemWidth, Windows will add the // width of a menu checkmark, so I must subtract to defeat Windows. Argh. // cx -= GetSystemMetrics(SM\_CXMENUCHECK)-1; lpms->itemWidth = cx; // done deal CMTRACE(\_T("OnMeasureItem for '%s':\\tw=%d h=%d\\n"), (LPCTSTR)pmd->text, lpms->itemWidth, lpms->itemHeight); } return TRUE; // handled
}
or u can refer to this link http://www.codeforge.com/read/89577/coolmenu.cpp__html[^] Regards Yogesh
-
Hello I found something interesting tht icons and text of menuItem is coming fine Except the menuList. As i click on any menu,menuList pops up and that list is coming wider,covering almost full screen. I checked that OnMeasureItem which calculates ItemWidth and height is Having some Prob.As I Converted this from VC6 to VS2010.
BOOL CCoolMenuManager::OnMeasureItem(LPMEASUREITEMSTRUCT lpms)
{
ASSERT(lpms);
CMyItemData* pmd = (CMyItemData*)lpms->itemData;
ASSERT(pmd);
if (lpms->CtlType != ODT_MENU || !pmd->IsMyItemData())
return FALSE; // not handled by meif (pmd->fType & MFT\_SEPARATOR) { // separator: use half system height and zero width lpms->itemHeight = GetSystemMetrics(SM\_CYMENU)>>1; lpms->itemWidth = 0; } else { // compute size of text: use DrawText with DT\_CALCRECT CWindowDC dc(NULL); // screen DC--I won't actually draw on it CRect rcText(0,0,0,0); CFont\* pOldFont = dc.SelectObject(GetMenuFont()); dc.DrawText(pmd->text, rcText, DT\_MYSTANDARD|DT\_CALCRECT); dc.SelectObject(pOldFont); // height of item is just height of a standard menu item lpms->itemHeight= max(GetSystemMetrics(SM\_CYMENU), rcText.Height()); // width is width of text plus a bunch of stuff int cx = rcText.Width(); // text width cx += CXTEXTMARGIN<<1; // L/R margin for readability cx += CXGAP; // space between button and menu text cx += m\_szButton.cx<<1; // button width (L=button; R=empty margin) // whatever value I return in lpms->itemWidth, Windows will add the // width of a menu checkmark, so I must subtract to defeat Windows. Argh. // cx -= GetSystemMetrics(SM\_CXMENUCHECK)-1; lpms->itemWidth = cx; // done deal CMTRACE(\_T("OnMeasureItem for '%s':\\tw=%d h=%d\\n"), (LPCTSTR)pmd->text, lpms->itemWidth, lpms->itemHeight); } return TRUE; // handled
}
or u can refer to this link http://www.codeforge.com/read/89577/coolmenu.cpp__html[^] Regards Yogesh
-
Hello Friends I was using code
void CMainFrame::OnInitMenuPopup(CMenu* a, UINT b, BOOL c)
{
FrameWnd::OnInitMenuPopUp( a,b,c);
}And this one displaying MenuItems correctly. Now,i trying to add icons to MenuItems.So for that I am using extenal CoolMenuManager to show up Icons with menuItems. Here is code for this :
void CMainFrame::OnInitMenuPopup(CMenu* a, UINT b, BOOL c)
{
if(m_menuManager.InitMenuPopup(a,b,c))
FrameWnd::OnInitMenuPopUp( a,b,c);
}
Now, in this case,If i use External fn then only icons are showing up. But as now, i am calling frameWnd::OnINitMenupopup too then icons are coming and strings are not coming properly and only for some menuItems and even menuList is coming Wider covering whle screen.Any Ideas? Regards Yogesh
-
I found tht Drawtext with parameter DT_CALCRECT is not returning right parameters of rectangle. Any Ideas ?