Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Owner Draw MenuItem Displaying large in Size in Debug but in release it is Ok

Owner Draw MenuItem Displaying large in Size in Debug but in release it is Ok

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingquestionannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 0 Offline
    0 Offline
    002comp
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • 0 002comp

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      0 1 Reply Last reply
      0
      • L Lost User

        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

        0 Offline
        0 Offline
        002comp
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • 0 002comp

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          yogeshs wrote:

          Now, Any Ideas.

          Sorry, no. I can only suggest you use your debugger to check all the parameters and their values as you step through the code to see if any one or more value(s) may be incorrect.

          Use the best guess

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups