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

x
?
Solved

Changing Status Bar prompts and tool tips

Posted on 1997-06-24
10
Medium Priority
?
523 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 900 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

604 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