Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Globalizing the StausBar

Posted on 1999-07-23
Medium Priority
Last Modified: 2013-11-20
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 ?
Question by:AnswerTheMan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 30

Expert Comment

ID: 1311246
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.

Author Comment

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

Return Value

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


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 ???

Accepted Solution

kenghwang earned 100 total points
ID: 1311248
CMainFrm class from "MainFrm.h"  file  has a data member call "m_wndStatusBar" which declare privately. Declare it on public section and you can access it by this command anywhere of the code. eg, view.cpp

char temp[10] = "abc";
CMainFrame* pAppFrame = (CMainFrame *) AfxGetApp()->m_pMainWnd;
pAppFrame->m_wndStatusBar.SetWindowText( temp );

hopefully this is the answer u want
LVL 30

Expert Comment

ID: 1311249
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,

Author Comment

ID: 1311250
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 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.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question