Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Forcing status bar message to update after settext

Posted on 1998-10-20
7
Medium Priority
?
568 Views
Last Modified: 2013-11-20
I have overridden the idle status bar message ("Ready") with my own text by subclassing the CStatusBar object and overriding the OnSetText function.  This is the code:

LRESULT CmStatusBar::OnSetText(WPARAM wParam, LPARAM lParam)
{
  CString strMessage = (LPCTSTR)lParam;
     if (strMessage == "Ready")
        return StatusBar::OnSetText(wParam,
            (LPARAM)m_sIdleMesg.GetBuffer(25));
     else
     {
        return CStatusBar::OnSetText(wParam, lParam);
     }
}

where m_sIdleMesg is a CString member variable that is previously set.  This function works fine, but doesn't force a redraw so the status bar text doesn't change until something else triggers it, such as tooltips coming on and going off.  I've tried UpdateWindow, Invalidate, etc. but how do you actually make the paint happen?
0
Comment
Question by:appleby
[X]
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
7 Comments
 
LVL 7

Expert Comment

by:psdavis
ID: 1323574
Use the CWnd::SetWindowText to set the status bar message instead!  The StatusBar should immediately update.  

Why did you have to override with the OnSetText?  What couldn't you do with the default?

Phillip
0
 

Author Comment

by:appleby
ID: 1323575
Using CWnd::SetWindowText changed and updated the text, but then set it right back to "Ready" again immediately.  It didn't stick.  I want a permanent override so it never says "Ready" but always says something that the program dictates according to its current state.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1323576
The 'Ready' and the toolbar messages should always update depending on the position of the mouse.  You might want to consider adding another pane to the status bar and manually changing that one, especially if it is state driven.

Phillip
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:appleby
ID: 1323577
That is an option but I'd really like to continue doing it this way if there is just a way to force the window to update afterwards.
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1323578
OnSetText is only called when somebody does SetWindowText (or similar) - i.e. the text of the bar is changed.   This is why you can't find another way to get this function called.

The trick relates to AFX_IDSIDLEMESSAGE and I think WM_SETMESSAGE, but I'm still thinking on this
0
 
LVL 3

Accepted Solution

by:
stefanr earned 200 total points
ID: 1323579
You may try this (a member function of CMainFrame is assumed):

int nIndex = m_wndStatusBar.CommandToIndex(ID_SEPARATOR);
if (-1 != nIndex)
{
   m_wndStatusBar.SetPaneText(nIndex, _T("Some other text"));
}

The main function here is CStatusBar::SetPaneText. You may call it directly from your derived CStatusBar class if you wish. It seems to update the text immediately.
0
 

Author Comment

by:appleby
ID: 1323580
Thank you - it was actually a combination of stefanr's answer and Answer2000's comment that gave me what I needed.  I have a function that sets the variable m_sIdleMesg of course.  And so I called the SetWindowText() function right after setting my idle text within the function that does so.  Voila, OnSetText() is called and it is updated immediately.  I didn't try it but I assume SetPaneText() would have acted the same way as SetWindowText()used here.  Thanks both of you.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

610 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