Solved

Changing Status Bar prompts and tool tips

Posted on 1997-06-24
10
511 Views
Last Modified: 2013-11-19
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.
0
Comment
Question by:r parkinson
[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
  • 4
  • 4
  • 2
10 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 300 total points
ID: 1302278
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
 
LVL 2

Author Comment

by:r parkinson
ID: 1302279
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
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1302280
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:r parkinson
ID: 1302281
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
 
LVL 2

Author Comment

by:r parkinson
ID: 1302282
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
 
LVL 1

Expert Comment

by:cnasarre
ID: 1302283
The source code for tooltip text is also in WINFRM.CPP :

(
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1302284
The source code for tooltip text is also in WINFRM.CPP
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1302285
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
 
LVL 2

Author Comment

by:r parkinson
ID: 1302286
OK, it all works now (I used ON_NOTIFY_EX(TTN_NEEDTEXT...), thanks anyway.


0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1302287
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

719 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