CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    Sep 2002
    Posts
    173

    How do I get rid of "Ready" in Status Bar

    Where do I put this,

    StatusBar->SetPaneText(0,"My Message");

    (StatusBar is a pointer to a CStatusBar object),

    to automatically overwrite "Ready" message that appears when a menu closes. Or, alternatively, how do I prevent that "Ready" message from overwriting "My Message?"

    BTW, I could never figure out what that "Ready" message is for.
    If the cursor isn't an hourglass, the program is ready.

  2. #2
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,917
    In resource editor change string with AFX_IDS_IDLEMESSAGE ID from ready to whatever you need.

    Ready (I think) is telling that app is ready to accept input.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201
    Here is another approach.

    Regards,
    Hal
    up·grade (up'gräd'),
    to take out old bugs
    and put in new ones.

  4. #4
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,917
    For simple replacement of Ready with another string that is overkill.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  5. #5
    Join Date
    Jan 2004
    Location
    Earth
    Posts
    567
    Hi,

    If you want to replace the default message replace the AFX_IDS_IDLEMESSAGE ID as JohnCz stated earlier. If you want to show text at runtime to indicate program functionality you can use the SetMessageText function. The text will be replaced again by the text specified by AFX_IDS_IDLEMESSAGE when the app re-enters the idle state.


    Code:
    ((CFrameWnd*)AfxGetApp()->GetMainWnd())->SetMessageText("Saving graph data");

    TDM

  6. #6
    Join Date
    Sep 2002
    Posts
    173
    Thank you all, particularly HalD. I forgot to mention that I want to replace "Ready" with a variable string.

    Your input has given me several ideas. If all else fails, I will try to replace "Ready" with "", make the first pane as small as possible, and move everything else one pane to the right.

  7. #7
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    See Microsoft Knowledge Base Article - 110505 (PRB: Setting First Pane of CStatusBar). Note that it does not list VC 6 as a product that it applies to, so there might be an easier way in VC 6. My guess is that the article does apply to VC 6 and they just have not revised the KB article.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  8. #8
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556
    When I want to set my own (variable) text in the status bar, I generally use the technique described by the MSDN article "Status Bars: Updating the Text of a Status-Bar Pane" at http://msdn.microsoft.com/library/de...d.bar_pane.asp

    Frankly, it's a giant P.I.T.A., and every time I do it, I can't believe that there's not a simpler way.

    -Mike

  9. #9
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    That MFC documentation page about status bars does not say much about the first pane but hopefully it does not need to. Hopefully they have fixed MFC so that the first pain is as easy as the other pains.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  10. #10
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556
    groan

    Best regards,
    Mike

  11. #11
    Join Date
    Jan 2004
    Location
    Earth
    Posts
    567
    When creating the status bar you could use a resource ID other than AFX_IDW_STATUS_BAR and the text is not updated. When used with SetPaneText you might be able to get the functionality you want. However, you lose other default functionality like tooltip text on the status bar.


    TDM
    Last edited by TDM; January 29th, 2004 at 04:50 PM.

  12. #12
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556
    A nice alternative to tooltip text in the status bar is pop-up tooltip text adjacent the menu, as described in Paul DiLascia's article entitled "Menu Tips in an MFC App" from the November 2003 MSDN magazine: http://msdn.microsoft.com/msdnmag/is...A/default.aspx

    -Mike

  13. #13
    Join Date
    Feb 2004
    Posts
    6

    Re: How do I get rid of "Ready" in Status Bar

    I know this is an ancient thread, but I had some similar issues in an old MFC application and solved it this way.

    Window class private members and method defined in header file:

    Code:
    	void setStatusBarText(const std::string& sbT);	//	call this to set the statusbar text
    	bool timerRunning;			//	is the timer running
    	std::string statusBarText;	//	the status bar text that needs to be set

    Implementation in the cpp file:

    Code:
    	
    	#define IDT_STATUSBAR_UPDATE_TIMER 0
    
    	.
    	.
    	.
    
    	CChildView::CChildView()
    	{	
    		timerRunning = false;	//	initially the timer is not running
    	.
    	.
    	.
    	}
    
    	//	See comments on setStatusBarText method
    	void CChildView::OnTimer(UINT_PTR nIDEvent)
    	{
    		CWnd::OnTimer(nIDEvent);
    
    		//	Try getting the status bar control and update the text
    		CStatusBar* p = (CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR);
    		if (p == NULL)
    			return;
    
    		p->SetPaneText(0, statusBarText.c_str());
    		timerRunning = false;	//	signal that the timer is no longer running
    		KillTimer(nIDEvent);	//	kill the timer
    	}
    
    	//	Due to some strange behaviour of the statusbar text, a timer is fired, when 
    	//	the status bar text needs to be update. The timer is killed, when the status
    	//	bar text has actually been updated.
    	void CChildView::setStatusBarText(const std::string& sbT)
    	{
    		statusBarText = sbT;
    		if (timerRunning)
    			return;	//	the timer is already running, bail out
    
    		timerRunning = true;
    		SetTimer(IDT_STATUSBAR_UPDATE_TIMER, 333, NULL);
    	}

    With the above implementation, one can set the statusbar text anywhere in the code, simply by calling setStatusBarText method.
    Code:
    setStatusBarText("This is a new message for the statusbar");
    Calling setStatusBarText will start a timer, that eventually will set the StatusBar text.

  14. #14
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,109

    Re: How do I get rid of "Ready" in Status Bar

    Quote Originally Posted by rudibr View Post
    I know this is an ancient thread, but I had some similar issues in an old MFC application and solved it this way.

    Window class private members and method defined in header file:

    Code:
    	void setStatusBarText(const std::string& sbT);	//	call this to set the statusbar text
    	bool timerRunning;			//	is the timer running
    	std::string statusBarText;	//	the status bar text that needs to be set

    Implementation in the cpp file:

    Code:
    	
    	#define IDT_STATUSBAR_UPDATE_TIMER 0
    
    	.
    	.
    	.
    
    	CChildView::CChildView()
    	{	
    		timerRunning = false;	//	initially the timer is not running
    	.
    	.
    	.
    	}
    
    	//	See comments on setStatusBarText method
    	void CChildView::OnTimer(UINT_PTR nIDEvent)
    	{
    		CWnd::OnTimer(nIDEvent);
    
    		//	Try getting the status bar control and update the text
    		CStatusBar* p = (CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR);
    		if (p == NULL)
    			return;
    
    		p->SetPaneText(0, statusBarText.c_str());
    		timerRunning = false;	//	signal that the timer is no longer running
    		KillTimer(nIDEvent);	//	kill the timer
    	}
    
    	//	Due to some strange behaviour of the statusbar text, a timer is fired, when 
    	//	the status bar text needs to be update. The timer is killed, when the status
    	//	bar text has actually been updated.
    	void CChildView::setStatusBarText(const std::string& sbT)
    	{
    		statusBarText = sbT;
    		if (timerRunning)
    			return;	//	the timer is already running, bail out
    
    		timerRunning = true;
    		SetTimer(IDT_STATUSBAR_UPDATE_TIMER, 333, NULL);
    	}

    With the above implementation, one can set the statusbar text anywhere in the code, simply by calling setStatusBarText method.
    Code:
    setStatusBarText("This is a new message for the statusbar");
    Calling setStatusBarText will start a timer, that eventually will set the StatusBar text.
    Well, why reinvent the wheel?
    Why not just use the WM_SETMESSAGESTRING?
    Victor Nijegorodov

  15. #15
    Join Date
    Feb 2004
    Posts
    6

    Re: How do I get rid of "Ready" in Status Bar

    Quote Originally Posted by VictorN View Post
    Well, why reinvent the wheel?
    Why not just use the WM_SETMESSAGESTRING?
    Well, in my specific case, I am already setting the status bar text before the status bar is even created ;-)
    That's why I need the timer to wait for the status bar to be ready.

    Once the application is fully up and running, I could simply use the build in SetPaneText, but since the statusbar isn't instantiated, it doesn't work in my case.

    Code:
    		CStatusBar* p = (CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR);
    		if (p != NULL)
    			p->SetPaneText(0, "What ever text needs to be set");
    So my implementation is a kind of delayed mechanism. Would WM_SETMESSAGESTRING also be able to handle this? Will the message stay in the queue untill the statusbar is created?

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured