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!

Finding that status bar

Status
Not open for further replies.

HyperEngineer

Programmer
May 8, 2002
190
US
A continuation of the Status Bar in a dialog app. I put the following code in a button click function on a dialog app.

Code:
  CClientDC dlgDC(this);
  CWnd* clientWindow = dlgDC.GetWindow();
  RECT MyRect;
  RECT MyStatusRect;
  clientWindow->GetWindowRect(&MyRect);
  m_wndStatusBar.GetWindowRect(&MyStatusRect);
  CString MyWindowRect;
  MyWindowRect.Format("Top = %ld\nBottom = %ld\nLeft = % d\nRight = %ld",
               MyRect.top, MyRect.bottom, MyRect.left, MyRect.right);
  MessageBox(MyWindowRect);
  MyWindowRect.Format("Top = %ld\nBottom = %ld\nLeft = %ld\nRight = %ld",
               MyStatusRect.top, MyStatusRect.bottom,
               MyStatusRect.left, MyStatusRect.right);
	MessageBox(MyWindowRect);

What I get for the client window is:

Top = 186
Bottom = 785
Left = 276
Right = 1005

and for the status bar window is:

Top = 208
Bottom = 208
Left = 279
Right = 279


So it appears that I need a way to positon and size the status bar. Any body know how to do that?

I sure would appreciate some help on this.

HyperEngineer
If it ain't broke, it probably needs improvement.
 
I figured it out.

This is the code:

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
  }
	
  // Show the status bar

  m_wndStatusBar.SetWindowText("Ready");

  CClientDC dlgDC(this);
  CWnd* clientWindow = dlgDC.GetWindow();
  RECT MyRect;

  clientWindow->GetWindowRect(&MyRect);

  int Status_x, Status_y, Status_cx, Status_cy;
  Status_x = 10;
  Status_y = MyRect.bottom - MyRect.top - 30 - 30;
  Status_cx = MyRect.right - MyRect.left - 20;
  Status_cy = 30;

  m_wndStatusBar.SetWindowPos(clientWindow,Status_x, Status_y,
          Status_cx, Status_cy, SWP_NOZORDER | SWP_SHOWWINDOW);



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

Part and Inventory Search

Sponsor

Back
Top