Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Status Bar in a Dialog application

Status
Not open for further replies.

HyperEngineer

Programmer
May 8, 2002
190
US

I have a dialog based application and want to have a status bar at the bottom of the window. In the header file I have the definition:

Code:
protected:
  CStatusBar m_wndStatusBar;

At the beginning of the MyProgDlg.cpp file I have the following structure:

Code:
static UINT indicators[] =
{
   ID_SEPARATOR,           // status line indicator
   ID_INDICATOR_CAPS,
   ID_INDICATOR_NUM,
   ID_INDICATOR_SCRL,
};

Then in the OnInitDialog() I have the following code:

Code:
   m_wndStatusBar = new CStatusBar();
   if (!m_wndStatusBar.Create(this) ||
       !m_wndStatusBar.SetIndicators(indicators,
       sizeof(indicators)/sizeof(UINT)))
      {
         TRACE0("Failed to create status bar\n");
         return -1;      // fail to create
      }

It compiles fine, but when I run the program I don't see a status bar.


HyperEngineer
If it ain't broke, it probably needs improvement.
 
Try
Code:
m_wndStatusBar.ShowWindow (SW_SHOW);
 
xwb,

That didn't work either. I have a feeling that I'm not attaching this bar to the window. Been all over MSDN but they are not clear on how to actually show the bar. I did what they said to create it, but no success as of yet. Still trying things.


HyperEngineer
If it ain't broke, it probably needs improvement.
 
Update:

I have the following code in the OnInitDialog():

Code:
  if (!m_wndStatusBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM) || !m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
    {
      TRACE0("Failed to create status bar\n");
      return -1;      // fail to create
    }
    else
      MessageBox("Status bar created", "Debug");
	
  // Show the status bar
  m_wndStatusBar.EnableWindow(TRUE);
  m_wndStatusBar.ShowWindow(SW_SHOW);
  m_wndStatusBar.BringWindowToTop();
  m_wndStatusBar.UpdateWindow();
  if (!m_wndStatusBar.IsWindowVisible())
    MessageBox("Status Bar not visible");
  m_wndStatusBar.SetWindowText("Ready");

Here I get the message "Status bar created". This is good.
And I get the message "Status Bar not visible". This is expected since the Dialog is not yet visible.

Then I put a button on the dialog. This is the code for the button click.

Code:
  // See if status bar is visible
  if (!m_wndStatusBar.IsWindowVisible())
    MessageBox("Status Bar is not visible");
  else
    MessageBox("Status Bar is visible");
  CString PanelText = m_wndStatusBar.GetPaneText(2);
  UINT PaneID;
  UINT PaneStyle;
  int PaneWidth;
  m_wndStatusBar.GetPaneInfo(2, PaneID, PaneStyle, PaneWidth);

  CString sStatusBarInfo;
  sStatusBarInfo.Format("ID = %d\nStyle = %d\nWidth = %d\nPanelText = %s", PaneID, PaneStyle, PaneWidth, PanelText);

  MessageBox(sStatusBarInfo);

When I click the button I get the message "Status Bar is visible". But I can't see it. And I get the message:

ID = 59138
Style = 0
Width = 25
PanelText = NUM

This says that the Status Bar is truly created and has a width. I don't know how to get the height info. But I believe the height is greater than 0. Where is that status bar? How do I find the client x-y coordinates to see if it's on the dialog?



HyperEngineer
If it ain't broke, it probably needs improvement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top