Implementing Tooltips for Menus

Environment: VC6, NT4 SP3

Well, as you see the new Win2000 you may have wondered how to get those nice tool tips for menu bars in your own apps. Then you found the right place !

In my small demo application I implemented a very simple tooltip for menus which uses the status bar messages for its own display (informative though)

My implementation is probably quite preliminary, but it seems to work with NT 4.0, Win 98 and maybe Win 95, too.

All the changes to get the menu tip go to CMainFrame class. I first overrode both OnEnterMenuLoop and OnExitMenuLoop, furthermore OnEnterIdle and then FilterToolTipMessage. When a menu pops up, OnEnterMenuLoop is called, which then creates a WS_EX_TOPMOST style tooltip. The tooltip is updated by OnEnterIdle which passes fake WM_MOUSEMOVE messages to the tooltip using RelayEvent. I do need to override FilterToolTipMessage, because the MFC CWnd::FilterToolTipMessage does not create WS_EX_TOPMOST tooltips and therefore does NOT display the tooltip. It is important to define your own method !

Well, that4s it, I think. Just download the sample app and try it !

Downloads

Download demo project - 32 Kb


Comments

  • much simpler way

    Posted by Legacy on 01/05/2004 12:00am

    Originally posted by: booboo

    http://www.codeguru.com/controls/MenuItemToolTip.html

    Reply
  • Submenu?

    Posted by Legacy on 12/03/2003 12:00am

    Originally posted by: Dima

    It seems this code does not work with submenu... Any ideas?

    Reply
  • Interesting problem

    Posted by Legacy on 04/27/2003 12:00am

    Originally posted by: Eldon Zacek

    I have implemented your code in to my project and have run across an interesting problem. I have made the tool tips so that the user can enable or disable them. On a customer's Win 98 machine, if the tool tips are enabled, the only way you can select an item from the menu is to keep the left mouse button depressed. It will show the tool tip for each menu item and then when you release the left mouse button, the selected item will be executed. If you do not hold the left mouse button down, the menu will appear and always select the first menu item. If you disable the tool tip option, then everything works like normal.

    Any ideas!?

    Reply
  • Well, It's working pretty good

    Posted by Legacy on 08/07/2002 12:00am

    Originally posted by: Bae

    Thanks. It will be very helpful for me to study Menu Structure..

    Reply
  • Wow, interesting.

    Posted by Legacy on 07/25/2001 12:00am

    Originally posted by: Sin Jeong-hun

    Your program works well on my system. (Windows 2000 with
    service pack 1) I'd like to use this feature in my program.
    Thank you for your work.
    Bye.

    Reply
  • This code is wrong and will never work

    Posted by Legacy on 06/02/2001 12:00am

    Originally posted by: Igor

    Unfortunately it is not possible to implement
    tooltips for menus since they (menus) do not send any events.
    As soon as popup menu jumps out of the mainframe area
    the function stops working!
    Anyway, thanks for idea.
    Igor

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

  • When individual departments procure cloud service for their own use, they usually don't consider the hazardous organization-wide implications. Read this paper to learn best practices for setting up an internal, IT-based cloud brokerage function that service the entire organization. Find out how this approach enables you to retain top-down visibility and control of network security and manage the impact of cloud traffic on your WAN.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date