Add Status Bar to Property Sheet

How do you add a status bar to a property sheet?
Who is Participating?
naveenkohliConnect With a Mentor Commented:
Here is the sample code which will add and place status bar on a property sheet. See the code used to make room for placing the status bar. You can manipulate it to adjust the distance of bar from the bottom of sheet. Now you wil have to add the UPDATE handles for all the indicators urself..

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

BOOL CDemoPSheet::OnInitDialog()
      BOOL bResult = CPropertySheet::OnInitDialog();

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

      // Make a sunken or recessed border around the first pane
      m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0),
            SBPS_STRETCH, NULL );

      CRect sheetRect;
      CRect barRect;

      // Get the client coordinates of the propertysheet.
      GetClientRect (&sheetRect);

      // Query for the rectangle coordinates when the status bar will be placed. This
      // will help in determining the height of staus bar.
            0, reposQuery, barRect);

      int barHeight = (sheetRect.Height () -barRect.Height ());

      // Get the position of one of the buttons on sheet. Its coordinates will be used to
      // calculate the distance between the bottom of the sheet and buttons.
      CWnd *pWnd = GetDlgItem (IDOK);
      CRect okRect;
      pWnd->GetWindowRect (okRect);
      ScreenToClient (okRect);

      int heightOfBtnsFromBottom = sheetRect.bottom - okRect.bottom;

      // Now we will have to expand to propertysheet to make room for the status
      // bar. By default, the staus bar will be postioned at the bottom of the
      // property sheet window and it will overlap the buttons. So what we will do
      // is add the bar height and distance of buttons to calculate new position for
      // sheet.
      sheetRect.bottom += (2 * barHeight + heightOfBtnsFromBottom);
      MoveWindow (sheetRect, FALSE);

      // Now place the status bar.
      CenterWindow ();

      return FALSE;
the process is same as adding status bar to mainframe of aplication. In this case you will create and attach the status bar in OnInitDialog function of your property sheet, like they way it is done in mainframe's OnCreate function.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.