Changing Status Bar prompts and tool tips

I would like to be able to dynamically change the text that is displayed in the staus bar when a menu option is selected, I would also like to change the text that is displayed in the tool tip of buttons on the tool bar.

Is there a way to do this?  Idealy the soulution would include recieving the text string for the prompt and tool tip, modifying it and then passing it on back to MFC.

I neead this ASAP, hence loads of points !!!

Thanks in advance.
LVL 2
r parkinsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tommy HuiEngineerCommented:
Yes, there is a way. If you look at the online help for WM_SETMESSAGESTRING, you'll see that this message gets sent to the frame when the status bar should be updated. Hence, you can catch this message and display any sort of text you want in the status bar. In fact, it doesn't even have to display text in the status bar. Note that this is done when the menu displayed.

Unlike the tooltip message, which can be changed whenever you want by calling CToolTipCtrl::UpdateTipText(). The tooltip owned by the toolbar can be retrieved by CToolBarCtrl::GetToolTips().

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
r parkinsonAuthor Commented:
This looks promising!!

However, I'm new to C++ and MFC (the app that I am writing has been ported from plain C, so I don't know how to trap the WM_SETMESSAGESTRING message !!

OK, so I can call CToolTipCtrl::UpdateTipText() to set the tool Tip text, but when should I call it and how do I know what the "default" (i.e. the text in the RC file) is?
0
Tommy HuiEngineerCommented:
In your message map for your particular window, define the following:

  ON_MESSAGE(WM_SETMESSAGESTRING, OnSetMessageString)

Then in the window header, define the OnSetMessageString function:

  afx_msg LRESULT OnSetMessageString(WPARAM, LPARAM);

Then define the function:

  LRESULT CMyWnd::OnSetMessageString(WPARAM wParam, LPARAM lParam)
  {
     // This function gets called whenever the status bar needs to be updated.
    // See WinFrm.cpp in \msdev\mfc\src to see how wParam and lParam are to be used.
  }

To decide when to call CToolTipCtrl::UpdateTipText() is entirely up to you. You should call this function whenever you decided that the tip text for the button has changed.


0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

r parkinsonAuthor Commented:
Nearly there !!

I still have 2 problems :

1) I cant get the UpdateTipText to work.

The Tool bar is defined with :

CToolBar  m_wndMainToolBar;

I have created the toolbar with :

m_wndMainToolBar.Create(....)

I then try to change the tip text in the OnSetMessageString with :

m_wndSequenceToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(string,this,wParam);

where string is a global string.

It just causes a GPF.

2) The status bar text basically works but :

  a) After highlighting any menu option I get WM_SETMESSAGESTRING messages continuously, it works fine for the tool bar buttons though its just as soon as you select any menu option.

  b) If you have a popup menu on the main menu then you dont get a message to tel you to change the text so you get the prompt for the previous non-popup menu option while the popup menu option is highlighted.
  e.g.
    A menu has the following structure :

   Option1
   Option2
   Popup ->Option3
                  Option4

If you move the mouse from Option1 to the Popup you still get the prompt text for Option 2.
0
r parkinsonAuthor Commented:
I have managed to get the status bar prompts to work by copying a chunk out of the winfrm.cpp source file, but I still cant get the tool tips to work.  The problem seens to be getting the Tool Tip with GetToolTip, it just returns NULL.
0
cnasarreCommented:
The source code for tooltip text is also in WINFRM.CPP :

(
0
cnasarreCommented:
The source code for tooltip text is also in WINFRM.CPP
0
cnasarreCommented:
sorry but it seems that I can't give you the tooltip answer
since my comments are truncated...

The source code for tooltip text is also in WINFRM.CPP
0
r parkinsonAuthor Commented:
OK, it all works now (I used ON_NOTIFY_EX(TTN_NEEDTEXT...), thanks anyway.


0
cnasarreCommented:
sorry but it seems that I can't give you the tooltip answer
since my comments are truncated... I'm getting crazy !
--> here is my email address nasarre@col.bsf.alcatel.fr

The source code for tooltip text handling is also in WINFRM.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.