Solved

Changing Status Bar prompts and tool tips

Posted on 1997-06-24
10
499 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
  • 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now