Owner Draw MenuItem Displaying large in Size in Debug but in release it is Ok
-
Hello friends I am using Owner Draw menuItem Icons in MFC application. Now, when I Run it in release build,menus are displaying fine But in Debug Build,MenuItem are large in size that covering full screen. Any IDeas ? Regards Y
-
yogeshs wrote:
Any IDeas ?
You have a bug in your program. Unless you provide some proper detail information it is impossible to guess; we have no idea what your code is doing.
Use the best guess
hello Sir I know that I didn't Post any Code and asking for Ideas. am Sorry for that. But I found tht in Fn Onmeasureitem ,we are using drawText to get height of Text which is returning wrong [>1] in debug build and 1 in rlease build.
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);
CSize size = dc.GetTextExtent(pmd->text);
dc.SelectObject(pOldFont);// height of item is just height of a standard menu item lpms->itemHeight= max(GetSystemMetrics(SM\_CYMENU), rcText.Height()+1); // 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
Now, Any Ideas. m compiling it on VS 2010. Regards Y
-
hello Sir I know that I didn't Post any Code and asking for Ideas. am Sorry for that. But I found tht in Fn Onmeasureitem ,we are using drawText to get height of Text which is returning wrong [>1] in debug build and 1 in rlease build.
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);
CSize size = dc.GetTextExtent(pmd->text);
dc.SelectObject(pOldFont);// height of item is just height of a standard menu item lpms->itemHeight= max(GetSystemMetrics(SM\_CYMENU), rcText.Height()+1); // 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
Now, Any Ideas. m compiling it on VS 2010. Regards Y