Solved

Changing Status Bar prompts and tool tips

Posted on 1997-06-24
10
503 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 55
while loop over for loop 7 103
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 94
Problem to App source 6 40
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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