Problem with CStatusBar::GetItemRect method


  • I have Visual Studio 2008 development environment on Windows XP and Windows Vista both.

    The CStatusBar::GetItemRect is returning different values on different operating system (with same resolution) with same project. The rectangle returned on Vista is correct but in case of Xp it returns a rectangle of smaller width.

    The status bar is inherited in my project and this method is used to display text in panes.

    Is there any known problem with CStatusBar::GetItemRect method?

    Monday, August 25, 2008 6:22 AM

All replies

  • Did you use CStatusBar::SetPaneInfo to set the width of each pane? 

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, August 26, 2008 1:32 AM
  • Just to add further information. I have migrated existing VC++ 6.0 project to VC++ 2008.

    I am finding problem with following set of code:

    static UINT indicators[] =
        ID_SEPARATOR,           // status line indicator

        if (!m_wndStatusBar.Create(this) ||
            TRACE0("Failed to create status bar\n");
            return -1;      // fail to create

    I am fetching the value of rectangles created above.

        CRect rect;
        CString h;
        for(int i=0; i<m_wndStatusBar.GetCount(); i++)
            m_wndStatusBar.GetItemRect(i, rect);

            h.Format("Width: %d, Height: %d",rect.Width(), rect.Height());

    Now the value for last pane behvaes inconsistently on Vista and XP.  The width of last pane is 35 in XP and 53 in Vista.
    Just to add on, my project is using splitter windows.
    Tuesday, August 26, 2008 4:51 AM
  • No, CStatusBar::SetPaneInfo is not called anywhere in code. Only SetItemText is called.

    There is further finding, this problem occurs when ComCtl32.dll version 6 is used through manifest file in XP.
    The GetItemRect method behaves differently with and without manifest file.

    On Windows Vista there is no such probelm.
    Wednesday, September 03, 2008 9:20 AM