Link to home
Start Free TrialLog in
Avatar of AnswerTheMan
AnswerTheMan

asked on

Globalizing the StausBar

I'm a VisualBasic expert. i Used to be a CPP expert when DOS was around.
now, trying MFC - i found that unlike VB - the Statusbar is not a GLOBAL resource (or whatever u call it....).
in VB you can address and change the StatusBar text from anywhere in your code because it's a PUBLIC control of the
form it belongs to which is PUBLIC itself.
is there a way in MFC to simplify usage of the code from
anywhere to change text in statusbar panels ?
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

For a SDI and MDI appwizard generated application the status bar control is a data member of the CMainFrame class. To access it globally you can:

CStatusBar* pStatusBar =
  ((CMainFrame*) AfxGetMainWnd())->GetStatusBar();

I hope this helps.
Avatar of AnswerTheMan
AnswerTheMan

ASKER

tnx SteveGTR, but your answer is not an answer to the question i asked.
here is MSDN page reffering to the function you suggested :
-------------------------------------------------------------
CHtmlView::GetStatusBar
BOOL GetStatusBar( ) const;

Return Value

Nonzero if the status bar can be displayed; otherwise zero.

Remarks

Call this member function to determine whether the WebBrowser control displays a status bar.

Applies to Internet Explorer. If you use this call with a WebBrowser control, it will return no error, but it will ignore this call.

----------------------------------------------------------------------
1) who talked about the CLASS CHtmlView ???
2) i did not asked for a Boolean to know if the StatusBar can be displayed.
3) i did not mentioned WebBrowser control in my question.
4) Internet Explorer ???
ASKER CERTIFIED SOLUTION
Avatar of kenghwang
kenghwang

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
CHtmlView??? I wasn't referring to CHtmlView... I was referring to CMainFrame::GetStatusBar(). Remember in C++ that you may have functions with the same name... Try out my original code and see that it will work. It is the same as that proposed by kenghwang.

Good Luck,
Steve
Ok, kenghwang. it was all my mistake.
what you suggested is exactly what i did before i put the question here, but
i was sure that the CMainFrame header is called MainFrame.h....so that's
why my #include raised errors.....
only in your answer i've noticed that the file name is MainFrm.h... and then
my privius code worked fine.