Click here to Skip to main content
Licence 
First Posted 21 Sep 2001
Views 90,841
Bookmarked 56 times

CXInfoTip - Information Tooltip

By | 21 Sep 2001 | Article
CXInfoTip is an enhanced information tooltip control.

Sample Image - XInfotip.jpg

Introduction

If you use Windows 2000, you may have noticed a special tooltip that is used in some instances. At least one spot where it is displayed is after making a dial-up network connection.

CXInfoTip is a simple control that attempts to reproduce this tooltip. It supports multi-line text (separated with a '\n') and an icon. The control can be used as a normal tooltip for controls or as an immediate popup data tip. It is not a direct replacement for CTooltip. The control itself is in the source files: CXInfoTip.h and CXInfoTip.cpp.

To use the control, create it and either call the immediate Show() method or add tools using AddTool(). If AddTool() is used then the RelayEvent() method must be called from the parent window's overridden PreTranslateMessage().

To use the control, add a CXInfoTip member variable to the class.

CXInfoTip m_Tip;

For dialogs, create it in OnInitDialog(). For other windows create it in OnCreate().

m_Tip.Create(this);

To show an immediate tooltip, call the Show() method.

m_Tip.Show(_T("This is a toolip!"), CPoint(100, 100));

To show normal tooltips, use AddTool() for each control and call RelayEvent() from PreTranslateMessage().

m_Tip.AddTool(GetDlgItem(IDOK), 
        _T("This is the OK button!"), m_TooltipIcon);
....
BOOL CInfoTipTestDlg::PreTranslateMessage(MSG* pMsg) 
{
    m_Tip.RelayEvent(pMsg);
    ...
}

Methods

  • CInfoTip::Create

    BOOL Create (CWnd * pParentWnd)

    Creates the tooltip control.

    Return value

    TRUE on success, FALSE otherwise

    Parameters

    • pParentWnd

      Pointer to the parent window.

  • CInfoTip::AddTool

    void AddTool(CWnd *pWnd, LPCTSTR szTooltipText, HICON hIcon = NULL)

    Adds a tool.

    Return value

    None

    Parameters

    • pWnd

      Pointer to the tool window.

    • szTooltipText

      Text to display in the tooltip for the window. Separate multiple lines with a '\n'.

    • hIcon

      Icon to display in the tooltip or NULL for no icon.

  • CInfoTip::RemoveTool

    void RemoveTool(CWnd *pWnd)

    Removes a tool.

    Return value

    None

    Parameters

    • pWnd

      Pointer to the tool window to remove.

  • CInfoTip::SetIcon

    void SetIcon(HICON hIcon)

    Sets the icon to show for immediate tooltips.

    Return value

    None

    Parameters

    • hIcon

      Handle to the icon to display.

  • CInfoTip::SetShowDelay

    void SetShowDelay(int nDelay)

    Adjusts the delay before a tooltip is displayed.

    Return value

    None

    Parameters

    • nDelay

      Delay in milliseconds.

  • CInfoTip::SetFont

    void SetFont(CFont *pFont)

    Sets the tooltip text font.

    Return value

    None

    Parameters

    • pFont

      Pointer to the font.

  • CInfoTip::RelayEvent

    void RelayEvent(LPMSG lpMsg)

    Relays mouse events to the control. If AddTool() is used, then this method must be called from PreTranslateMessage().

    Return value

    None

    Parameters

    • lpMsg

      Pointer to the message structure.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Mark Bozeman



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalyou are a gread fellow Pinmemberxfxty13:39 30 Dec '09  
GeneralThank you, very usefull. Pinmemberweeyu3:30 26 Apr '09  
Questionbug or feature? Pinmemberalex__b7:29 22 Mar '09  
QuestionHow can i use CXInfoTip for displaying tooltips for toolbar buttons? Pinmemberhitman_guy19:30 16 May '07  
QuestionCopy/paste from balloon Pinmemberevegnibmw21:15 3 Aug '06  
GeneralThank you, very usefull. Pinmembercaesten9:01 28 Apr '06  
GeneralMany thanks Pinmemberjrivero14:19 13 Nov '05  
GeneralSmall bug Pinmembertézé19:25 23 Feb '05  
GeneralReally nice work PinmemberJohn Norris4:14 1 Jul '04  
GeneralUpdate RelayEvent(LPMSG lpMsg) Pinmembertpchen21:20 12 Apr '04  
QuestionHow to make this work in ATL? PinmemberArvind Ganesan4:40 30 Jul '03  
GeneralNice work and how to use on TrayIcon tooptips PinsussAnonymous14:39 22 Sep '02  
GeneralNice work but small problem PinmemberAnonymous21:44 27 Sep '01  
GeneralRe: Nice work but small problem PinmemberKurt M. S.9:28 12 Aug '02  
GeneralRe: Nice work but small problem Pinmembershawkins14:25 31 May '06  
GeneralTwo minor bugs & Fixes PinmemberJason De Arte9:13 25 Sep '01  
GeneralCompile falure on CMAP PinmemberBob Eastman11:14 23 Sep '01  
GeneralRe: Compile falure on CMAP PinmemberPaolo Messina15:29 23 Sep '01  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 22 Sep 2001
Article Copyright 2001 by Mark Bozeman
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid