|
-
April 3rd, 1999, 07:44 PM
#1
How to Access MFC Status Bar from View class?
When I create a new MFC app, I get this status bar object in my CMainFrame class called "m_wndStatusBar." Is there any way I can access this from my View or Doc class? It would help greatly to be able to display text in it based on what happens in either class...
Thanks a lot,
- Chris.
-
April 3rd, 1999, 09:27 PM
#2
Re: From "Visual C++4.0 HOW-TO"
Hi,
Accroding as "Visual C++ 4.0 HOW-TO". p99
To show the caret postion of View to status bar
static UINT indicators[] =
{ ......
ID_INDICATOR_CARET,
};
//at the message map of CMyView
afx_msg void OnUpdateCaretPos(CCmdUI* pCmdUI);
void CMyView::OnUpdateCaretPos(CCmdUI* pCmdUI)
{
int nLine, nCol;
GetCaretPosition(nLine, nCol);//determine the position of caret.
CString str;
str.Format("Ln %d, Col %d", nLine, nCol);
pCmdUI->Enable(TRUE);
pCmdUI->SetText(str);
}
Hope for help.
-Masaaki Onishi-
-
April 6th, 1999, 04:47 AM
#3
Re: How to Access MFC Status Bar from View class?
your variable m_wndStatusBar is public, and you can access it from everywhere. So you may do:
BOOL CMyView::UpdateStatusBar(int iPosition, CString &strNewText)
{
CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
return pFrame->m_wndStatusBar.SetPaneText(iPosition, strNewtext);
}
If you want to be "cleaner", you may define m_wndStatusBar as protected, and write an inline method GetStatusBar() in your method.
HTH.
K.
Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.
We're talking ****, 'cause life is a 'biz
You know it is
Everybody tryin' to get rich
God ****!
All I wanna do is live !
KoRn, Children of the Korn
-
April 6th, 1999, 06:08 AM
#4
Re: How to Access MFC Status Bar from View class?
If you just want to display text on the status bar, use:
CFrameWnd::SetMessageText( LPCTSTR lpszText );
as in:
dynamic_cast < CFrameWnd > (AfxGetMainWnd())->SetMessageText("Status message");
Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|