Click here to Skip to main content
Click here to Skip to main content
Go to top

CPPToolTip v2.1

, 4 Mar 2005
Rate this:
Please Sign up or sign in to vote.
A class that allows you to display your data for a control as tooltip

Placing an anchor on any edge

Tooltip for the menu item

Tooltip for the toolbar item

Tooltip for the map item

Titletip for the different controls

Tooltip with hyperlinks and hot areas

<!------------------------------- STEP 3 ---------------------------> <!-- Add the article text. Please use simple formatting (

,

etc) -->

Contents

Features

  • Standard and balloon tooltip
  • Built-in HTML-lite language for a tooltip
  • Built-in support for CSS styles
  • Built-in support for menus and toolbars
  • Support for any size icons (max. 256 colors)
  • Support for bitmaps
  • Support for ImageList
  • Load icons, bitmaps and strings from resources, DLLs or files
  • Support Fade-in and Fade-out effects
  • Support for gradient shadow for tooltip and images
  • Support for applies miscellaneous effects over the any images (lighten, darken, grayed)
  • Support for hyperlinks
  • Support for hot areas
  • Support for tables
  • Support for CScrollView
  • Extended <br> and <t> tags
  • Extended resource strings for the menu and toolbars items
  • Every size can be customized
  • Change runtime a tooltip's text
  • Implemented a Debug Mode (an idea from www.tooltips.net site with Vitaly Tomilov's permission)
  • Support for an animation - NEW in v2.1
  • Support a text wrapping - NEW in v2.1
  • Full source code included!

How to integrate CPPToolTip in your application

To integrate PPToolTip control in your application you should add next files to your project:

Files
Description
PPTooltip.h
PPTooltip.cpp
CPPTooltip class

PPHtmlDrawer.h PPHtmlDrawer.cpp

CPPHtmlDrawer class. It's need to drawing HTML string in tooltip body

PPDrawManager.h
PPDrawManager.cpp

CPPDrawManager class is a set of methods to work with graphics.
CeXDib.h
CeXDib.cpp
CCeXDib class thanks to Davide Pizzolato and Davide Calabro. This class use for extend background's effect.

Extend background effects by Davide Pizzolato and Davide Calabro become available if defined USE_SHADE:

in PPDrawManager.h
#define USE_SHADE

Create a CPPToolTip object

Include PPTooltip.h in the header file where you want to use the CPPToolTip window and create a member variable for the window:

CPPToolTip m_tooltip;

Now create the window. For dialog-based applications, in your OnInitDialog:

// Call the base-class method
CDialog::OnInitDialog();

// Create the CPPToolTip object
m_tooltip.Create(this);

Now call AddTool function to register a tool with the tool tip control, so that the information stored in the tool tip is displayed when the cursor is on the tool:

m_tooltip.AddTool(GetDlgItem(IDC_BUTTON1), _T(
 "Tooltip to the control IDC_BUTTON1"));

or for rectangle area

m_tooltip.AddTool(this, _T("Tooltip for rectangle area"), 
 CRect (100, 100, 200, 200));

Now you must add RelayEvent function call to pass a mouse message to a tooltip control for processing.

BOOL ... ::PreTranslateMessage(MSG* pMsg)
{
    m_tooltip.RelayEvent(pMsg); 
}

 

Using a tooltip with a toolbar

1. Create CPPToolTip object in the header CMainFrame

CPPToolTip m_tooltip;

2. In CMainFrame::OnCreate() call a AddToolBar method.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...
    m_tooltip.Create(this);
    //Adds tooltip for toolbar
    m_tooltip.AddToolBar(&m_wndToolBar);
    return 0;
}

3. Add RelayEvent function call to pass a mouse message to a tooltip control for processing.
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
    m_tooltip.RelayEvent(pMsg);
}

Extended string from resources

Notice, that the text for tooltips are automatically loaded from resources.
The string format was expanded with the third parameter, used for disabled items of the the menu and the toolbar.

Format string in resource: Parameter1\nParameter2\nParameter3

,where :

  • Parameter1 - text for the normal menu items and status bar
  • Parameter2 - text for the normal toolbar items
  • Parameter3 - text for the disabled menu and toolbars items

Using a tooltip with a menu

1. Create CPPToolTip object in the header CMainFrame

CPPToolTip m_tooltip;

2. In CMainFrame::OnCreate() call a Create method.

m_tooltip.Create(this);

3. Uncomments a line to enable a work with menus.

in PPTooltip.h 
#define PPTOOLTIP_USE_MENU

4. Adds two handlers to CMainFrame.

void CMainFrame::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSubMenu)
{
     m_tooltip.OnMenuSelect(nItemID, nFlags, hSubMenu);
     CFrameWnd::OnMenuSelect(nItemID, nFlags, hSubMenu);
}


void CMainFrame::OnEnterIdle(UINT nWhy, CWnd* pWho)
{
     m_tooltip.OnEnterIdle(nWhy, pWho);
}
5. Add RelayEvent function call to pass a mouse message to a tooltip control for processing.
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
    m_tooltip.RelayEvent(pMsg); 
}

 

Class Members

Construction

 
CPPToolTip Constructs a CPPToolTip object.
Create Creates a tooltip control and attaches it to a CPPToolTip object.

Behaviour

 
SetBehaviour Sets the behaviour's tooltip
GetBehaviour Gets the behaviour's tooltip

Background

 
SetColorBk Specifies the color to use for the control.
SetEffectBk Sets the control colors to the default colors.

Tools

 
AddTool Adds the info of the tool.
AddToolBar Adds a toolbar to the tooltip control.
RemoveTool Removes specified tool.
RemoveAllTools Removes all tools.
ShowHelpTooltip Show the tooltip as help window
HideTooltip Hide the tooltip

CImageList

 
SetImageList Sets the image list to tooltip.

Border

 
SetBorder Sets the color and the width of the tooltip's border.
HideBorder Hides a border of the tooltip.

Notification

 
SetNotify Enable notification about changing the data or the view.
GetNotify Is enabled notification about changing the data or the view..

CSS Styles

 
SetCssStyles Sets the CSS styles of the HTML text
GetCssStyles Retrieves information about the CSS styles of the HTML text

Delays

 
SetDelayTime Sets the delay time for a tooltip control.
GetDelayTime Retrieves the initial, pop-up, and reshow durations currently set for a CPPToolTip control

Sizes

 
SetDefaultSizes Sets all sizes as default.
SetSize Sets the tooltip's sizes.
GetSize Retrieves the size of the specified value.

Direction

 
SetDirection Sets a placement of the tooltip's anchor.
GetDirection Retrives a placement of the tooltip's anchor.

Others

 
SetDebugMode Sets a debug mode for a tooltip control.
EnableEscapeSequences Enables or disables an escape sequences in the HTML string.
SetTransparency Sets a transparency of the tooltip.
GetTransparency Gets a transparency of the tooltip.
SetTooltipShadow Sets a tooltip's shadow.
SetImageShadow Sets a image's shadow.
SetMaxTipWidth Sets the maximum width for a tooltip window.
SetImageShadow Sets a image's shadow.

Hyperlinks

 
EnableHyperlink Associates name of resource with his ID.
SetCallbackHyperlink Search index of array by with specified name or ID resource.

Menus (availables if PPTOOLTIP_USE_MENU defined only)

MenuToolPosition Sets a position of the tooltip's anchor about menu item.
GetMenuToolPosition Gets a position of the tooltip's anchor about menu item..

Operations

 
RelayEvent Passes a mouse message to a tooltip control for processing.

Version

 
GetVersionI Get CPPToolTip version
GetVersionC Get CPPToolTip version

 

CPPToolTip::CPPToolTip

CPPToolTip ();

Remarks
Constructs a CPPToolTip object. You must call Create after that.

CPPToolTip Overview | Class Members

 

CPPToolTip::Create

BOOL Create (CWnd* pParentWnd, BOOL bBalloonSize = TRUE);

Parameters

  • pParentWnd - Points to the parent window of the tooltip control, usually a CDialog. It must not be NULL.
  • bBalloonSize - If TRUE CPPToolTip object will be sets to balloon size, otherwise to standard size.

Return Value

Nonzero if the CPPToolTip object is successfully created; otherwise 0.

Remarks
You construct a CPPToolTip in two steps. First call the constructor to construct the CPPToolTip object; then call Create to create the tool tip control and attach it to the CPPToolTip object.

CPPToolTip Overview | Class Members

CPPToolTip::SetBehaviour

void SetBehaviour(DWORD dwBehaviour = 0)

Parameters

  • dwBehaviour - The behaviour of the tooltip. This parameter can be one of the following values:
    • PPTOOLTIP_MULTIPLE_SHOW - This option sets multiple show of the tooltip for specified tool or all tools of tooltip object. With this option the tooltip will be shown for each stop of the mouse pointer.
    • PPTOOLTIP_CLOSE_LEAVEWND - If set this flag then tooltip will be hide when mouse pointer to leave the control.
    • PPTOOLTIP_NOCLOSE_OVER - If set this flag then tooltip will not hide if the mouse pointer over the tooltip
    • PPTOOLTIP_DISABLE_AUTOPOP - a tooltip with this flag will not hide from the autopop timer. This flag automatically adding for Help tooltip (see ShowHelpTooltip)

Remarks

Calls the function to set the tooltip's behaviour.

CPPToolTip Overview | Class Members

CPPToolTip::GetBehaviour

DWORD GetBehaviour()

Return value

The behavior of the tooltip. See the SetBehaviour function for the list of the available flags

Remarks

Retrieves the behavior of the tooltip.

CPPToolTip Overview | Class Members

CPPToolTip::SetColorBk

void SetColorBk(COLORREF color)
void SetColorBk(COLORREF crBegin, COLORREF crEnd)
void SetColorBk(COLORREF crBegin, COLORREF crMid, COLORREF crEnd)

Parameters

  • color - A COLORREF value that contains RGB information for the solid background
  • crBegin - A COLORREF value that contains RGB information for the first color.
  • crMid - A COLORREF value that contains RGB information for the middle color.
    Used with a following effects:
     

    CPPDrawManager::EFFECT_HGRADIENT 
    
            CPPDrawManager::EFFECT_VGRADIENT 
    
            CPPDrawManager::EFFECT_HCGRADIENT 
    
            CPPDrawManager::EFFECT_VCGRADIENT 
    
            CPPDrawManager::EFFECT_3HGRADIENT 
    
            CPPDrawManager::EFFECT_3VGRADIENT 
    
            CPPDrawManager::EFFECT_NOISE 
    
            CPPDrawManager::EFFECT_DIAGSHADE 
    
            CPPDrawManager::EFFECT_HSHADE 
    
            CPPDrawManager::EFFECT_VSHADE 
    
            CPPDrawManager::EFFECT_HBUMP 
    
            CPPDrawManager::EFFECT_VBUMP 
    
            CPPDrawManager::EFFECT_SOFTBUMP 
    
            CPPDrawManager::EFFECT_HARDBUMP 
    
            CPPDrawManager::EFFECT_METAL

  • crEnd - A COLORREF value that contains RGB information for the end color.

Remarks

Function sets the colors for gradient filling of background.

CPPToolTip Overview | Class Members

CPPToolTip::SetEffectBk

void SetEffectBk(UINT nEffect, BYTE nGranularity = 5)

Parameters

  • nEffect - This value sets the effect of the background bitmap. Can be one of the following values:
     

    CPPDrawManager::EFFECT_SOLID
    
            CPPDrawManager::EFFECT_HGRADIENT 
    
            CPPDrawManager::EFFECT_VGRADIENT 
    
            CPPDrawManager::EFFECT_HCGRADIENT 
    
            CPPDrawManager::EFFECT_VCGRADIENT 
    
            CPPDrawManager::EFFECT_3HGRADIENT 
    
            CPPDrawManager::EFFECT_3VGRADIENT 
    
            CPPDrawManager::EFFECT_NOISE 
    
            CPPDrawManager::EFFECT_DIAGSHADE 
    
            CPPDrawManager::EFFECT_HSHADE 
    
            CPPDrawManager::EFFECT_VSHADE 
    
            CPPDrawManager::EFFECT_HBUMP 
    
            CPPDrawManager::EFFECT_VBUMP 
    
            CPPDrawManager::EFFECT_SOFTBUMP 
    
            CPPDrawManager::EFFECT_HARDBUMP 
    
            CPPDrawManager::EFFECT_METAL

  • nGranularity - this parameter add an uniform noise to the background bitmap. A good value is from 5 to 20; 0 to disable the effect. The noise has a positive effect because it hides the palette steps. This parameter has no effect if the nEffect value is from CPPDrawManager::EFFECT_SOLID to CPPDrawManager::EFFECT_3VGRADIENT.

Remarks

Sets an effect for the background bitmap. Note that effect value from CPPDrawManager::EFFECT_NOISE to CPPDrawManager::EFFECT_METAL is available when

#define USE_SHADE //in PPDrawManager.h

only.

CPPToolTip Overview | Class Members

CPPToolTip::AddTool

void AddTool(CWnd * pWnd, DWORD dwIdString, LPCRECT lpRectBounds = NULL, DWORD dwIDTool = 0);

	void AddTool(CWnd * pWnd, LPCTSTR lpszString = NULL, LPCRECT lpRectBounds = NULL, DWORD dwIDTool = 0);

	void AddTool(CWnd * pWnd, PPTOOLTIP_INFO & ti);

To be compatible with old version of CPPToolTip ...
void AddTool(CWnd * pWnd, DWORD dwIdString, HICON hIcon, LPCRECT lpRectBounds = NULL, DWORD dwIDTool = 0);

	void AddTool(CWnd * pWnd, DWORD dwIdString, DWORD dwIdIcon, CSize & szIcon = CSize(0, 0), LPCRECT lpRectBounds = NULL, DWORD dwIDTool = 0);

	void AddTool(CWnd * pWnd, LPCTSTR lpszString, HICON hIcon, LPCRECT lpRectBounds = NULL, DWORD dwIDTool = 0);

  void AddTool(CWnd * pWnd, LPCTSTR lpszString, DWORD dwIdIcon, CSize & szIcon = CSize(0, 0), LPCRECT lpRectBounds = NULL, DWORD dwIDTool = 0);

Parameters

  • pWnd - Pointer to the window that contains the tool.
  • lpszString - Pointer to the text for the tool.
  • dwIdString - ID of string resource
  • hIcon - Handle of the icon
  • dwIdIcon - ID of icon resource
  • szIcon - Specifies the width and the height, in pixels, of the icon to load.
  • lpRectBounds - Pointer to a RECT structure containing coordinates of the tool's bounding rectangle.
    The coordinates are relative to the upper-left corner of the client area of the window identified by pWnd.
    NULL if bounding rectangle don't uses for specified window
  • dwIdTool - ID of the tool
  • ti - Reference to PPTOOLTIP_INFO structure containing the parameters of the tooltip
Remarks

A tooltip control can be associated with more than one tool. Call this function to register a tool with the tooltip control, so that the information stored in the tooltip is displayed when the cursor is on the tool.

CPPToolTip Overview | Class Members

CPPToolTip::AddToolBar

void RemoveTool(CToolBar * pBar)

Parameters

  • pBar - Pointer to the toolbar window.

Remarks

Call this function to register a toolbar in the collection of toolbars supported by a tooltip control. This method automatically remove CBRS_TOOLTIPS style from toolbar's style to disable standard tooltip.

CPPToolTip Overview | Class Members

CPPToolTip::RemoveTool

void RemoveTool(CWnd * pWnd, LPCRECT lpRectBounds = NULL)

Parameters

  • pWnd - Pointer to the window that contains the tool.
  • lpRectBounds - Pointer to a RECT structure containing coordinates of the tool's bounding rectangle.
    The coordinates are relative to the upper-left corner of the client area of the window identified by pWnd.
    NULL if bounding rectangle don't uses for specified window.

Remarks

Call this function to removes the tool specified by pWnd and lpRectBounds from the collection of tools supported by a tooltip control.

CPPToolTip Overview | Class Members

CPPToolTip::RemoveAllTools

void RemoveAllTools()

Remarks

Call this function to remove all tools from the collection of tools supported by a tooltip control.

CPPToolTip Overview | Class Members

CPPToolTip::ShowHelpTooltip

void ShowHelpTooltip (LPPOINT pt, DWORD dwIdText, HICON hIcon = NULL);
	

  void ShowHelpTooltip (LPPOINT pt, DWORD dwIdText, DWORD dwIdIcon, CSize & szIcon = CSize(0, 0));
	

  void ShowHelpTooltip (LPPOINT pt, LPCTSTR lpszString, HICON hIcon = NULL);
	

  void ShowHelpTooltip (LPPOINT pt, LPCTSTR lpszString, DWORD dwIdIcon, CSize & szIcon = CSize(0, 0));
	

  void ShowHelpTooltip (LPPOINT pt, PPTOOLTIP_INFO & ti);

Parameters

  • pt - Pointer to a POINT structure that receives the screen coordinates of the tooltip's anchor
  • lpszString - Pointer to the text for the help tooltip.
  • dwIdString - ID of string resource
  • hIcon - Handle of the icon
  • dwIdIcon - ID of icon resource
  • szIcon - Specifies the width and the height, in pixels, of the icon to load.
  • ti - Reference to PPTOOLTIP_INFO structure containing the parameters of the tooltip

Remarks

Shows the help tooltip in any place of screen.

CPPToolTip Overview | Class Members

CPPToolTip::HideTooltip

void HideTooltip ();

Remarks

Hides the tooltip.

CPPToolTip Overview | Class Members

CPPToolTip::SetImageList

void SetImageList(UINT nIdBitmap, int cx, int cy, int nCount, COLORREF crMask /* = RGB(255, 0, 255) */)

  void SetImageList(HBITMAP hBitmap, int cx, int cy, int nCount, COLORREF crMask /* = RGB(255, 0, 255) */)

Parameters

  • nIdBitmap - Resource IDs of the bitmap to be associated with the image list
  • hBitmap - Handle of the bitmap to be associated with the image list
  • cx - Dimensions of each image, in pixels.
  • cy - Dimensions of each image, in pixels.
  • nCount - Number of images that the image list initially contains.
  • crMask - Color used to generate a mask. Each pixel of this color in the specified bitmap is changed to black, and the corresponding bit in the mask is set to one.

Remarks

This function sets the image list to tooltip. After this function in body of the tooltip string you can to use the <ilst> tag which will be draw the image from image list in specified place.

CPPToolTip Overview | Class Members

 

CPPToolTip::SetBorder

void SetBorder(COLORREF color, int nWidth = 1, int nHeight = 1);
void SetBorder(HBRUSH hbr, int nWidth = 1, int nHeight = 1);

Parameters

  • color - A COLORREF value that contains RGB information to create a solid brush to be used to draw the border.
  • hbr - Brush handle that identifies the brush to be used to draw the border.
  • nWidth - Specifies the width of the border in vertical brush strokes in device units.
  • nHeight - Specifies the height of the border in horizontal brush strokes in device units.

Remarks

Call this member function to draws a border around the tooltip's region by using the specified brush.

CPPToolTip Overview | Class Members

CPPToolTip::HideBorder

void HideBorder()

Remarks

The function hides the border around the tooltip's region.

CPPToolTip Overview | Class Members

CPPToolTip::SetTooltipShadow

void SetTooltipShadow(int nOffsetX, int nOffsetY, BYTE nDarkenPercent /* = 50 */, BOOL bGradient /* = TRUE */, int nDepthX /* = 7 */, int nDepthY /* = 7 */)

CPPToolTip::SetImageShadow

void SetImageShadow(int nOffsetX, int nOffsetY, BYTE nDarkenPercent /* = 50 */, BOOL bGradient /* = TRUE */, int nDepthX /* = 7 */, int nDepthY /* = 7 */)

Parameters

  • nOffsetX, nOffsetY - The offsets of the shadow from the object.
  • nDarkenPercent - So far as colors under the shadow will be darken (0 - 100). For gradient shadow the best value is a 50 percent, for original - 25.
  • bGradient - TRUE to use a gradient shadow.
  • nDepthX, nDepthY - The gradient depths of the gradient shadow. For better result use odd value (3, 5, 7 ...).

Remarks

This function sets the shadow to the tooltip or the images on him.

CPPToolTip Overview | Class Members

CPPToolTip::SetNotify

void SetNotify(BOOL bParentNotify = TRUE)
void SetNotify(HWND hWnd)

Parameters

  • bParentNotify - If TRUE the control will send the notification to parent window. Otherwise the notification will not send.
  • hWnd - If non-NULL the control will send the notification to specified window. Otherwise the notification will not send.

Remarks

This function enables or disables the ability to send notification messages to destination window from the control. If user enabled notify message passing from tooltip to owner class then tooltip object sends the UDM_TOOLTIP_DISPLAY notification before displaying. In a handler of this notify owner class can change any parameters of tooltip displaying. With UDM_TOOLTIP_DISPLAY notification NM_PPTOOLTIP_DISPLAY structure is transferred, contained all necessary information.

Structure NM_PPTOOLTIP_DISPLAY looks as follows:

typedef struct tagNM_PPTOOLTIP_DISPLAY
{
    NMHDR hdr;
	   HWND hwndTool;       //HWND of the window to display a tooltip
    LPPOINT pt;          //The current screen coordinates of 
                          //the tooltip's anchor
    PPTOOLTIP_INFO * ti; //The pointer to the <a href="#PPTOOLTIP_INFO">PPTOOLTIP_INFO</a> 
                          //structure which contains parameters for 
                          //displaying tooltip
} NM_PPTOOLTIP_DISPLAY;

Owner object should process notification messages to have the ability to change tooltip appearance and placement by changing approppriate members of this structure.

Here example:

Add next lines to header and implementation files accordingly.

afx_msg void NotifyDisplayTooltip(NMHDR * pNMHDR, LRESULT * result);
ON_NOTIFY (UDM_TOOLTIP_DISPLAY, NULL, NotifyDisplayTooltip)
and
void CParentDlg::NotifyDisplayTooltip(NMHDR * pNMHDR, 
 LRESULT * result)
{
    *result = 0;
	NM_PPTOOLTIP_DISPLAY * pNotify = 
     (NM_PPTOOLTIP_DISPLAY*)pNMHDR;
	
     switch (CWnd::FromHandle(pNotify->hwndTool)
      ->GetDlgCtrlID())
	{
    case IDC_BUTTON1:
        //Changes the tooltip's text
        pNotify->ti->sTooltip = _T("Dynamically 
            changed text for BUTTON1");
        break;
    case IDC_BUTTON2:
        //Changes background color of the tooltip as RED
        pNotify->ti->crBegin = RGB (255, 0, 0); 
        break;
    }
}

CPPToolTip Overview | Class Members

CPPToolTip::GetNotify

BOOL GetNotify()

Return value

TRUE if the control notified the specified window.

Remarks

This function determines if  notification messages are passed to destination window from the control or not.

CPPToolTip Overview | Class Members

CPPToolTip::SetCssStyles

void SetCssStyles(LPCTSTR lpszCssString /* = NULL */);

Parameters

  • lpszCssString - Pointer to the string with CSS styles or NULL if sets the default CSS styles (like Codeproject).

Remarks
Call this method to customize the CSS styles used on HTML page. For more information look the description on CPPHtmlDrawer class.

CPPToolTip Overview | Class Members

 

CPPToolTip::GetCssStyles

LPCTSTR GetCssStyles();

Return Value

A const pointer to the string that contains the CSS styles.

Remarks
Call this method to retrive the CSS styles used on HTML page. For more information look the description on CPPHtmlDrawer class.

CPPToolTip Overview | Class Members

CPPToolTip::SetDelayTime

void SetDelayTime(DWORD dwDuration, DWORD dwTime)

Parameters

  • dwDuration - Flag that specifies which duration value will be retrieved. This parameter can be one of the following values:
     

    PPTOOLTIP_TIME_AUTOPOP

    Retrieve the length of time the tooltip window remains visible if the pointer is stationary within a tool's bounding rectangle.

     

    PPTOOLTIP_TIME_INITIAL

    Retrieve the length of time the pointer must remain stationary within a tool's bounding rectangle before the tool tip window appears.

     

    PPTOOLTIP_TIME_FADEIN

    Retrieve the length of time for each step of fade-in effect.

     

    PPTOOLTIP_TIME_FADEOUT

    Retrieve the length of time for each step of fade-out effect.

     

    PPTOOLTIP_TIME_ANIMATION

    Retrieve the length of time for each step of animation.

      For compatibility with 1.x versions of CPPToolTip a following values are available also:
     

    TTDT_AUTOPOP

    Same PPTOOLTIP_TIME_AUTOPOP

     

    TTDT_INITIAL

    Same PPTOOLTIP_TIME_INITIAL


    dwTime - The specified delay time, in milliseconds.

Remarks

Call this function to set the delay time for a tooltip control. The delay time is the length of time the cursor must remain on a tool before the tooltip window appears. The default delay time is 500 milliseconds.

CPPToolTip Overview | Class Members

CPPToolTip::GetDelayTime

DWORD GetDelayTime(DWORD dwDuration) const

Return Value

The specified delay time, in milliseconds

Parameters

  • dwDuration - Flag that specifies which duration value will be retrieved. See CPPToolTip::SetDelayTime for a description of the valid values.

Remarks

Retrieves the initial, pop-up, and reshow durations currently set for a CPPToolTip control

CPPToolTip Overview | Class Members

CPPToolTip::SetDefaultSizes

void SetDefaultSizes(BOOL bBalloonSize = TRUE)

Parameter

  • bBalloonSize - If TRUE CPPToolTip object will be sets to balloon size, otherwise to standard size.

Remarks

This function sets all sizes as default.

CPPToolTip Overview | Class Members

CPPToolTip::SetSize

void SetSize(DWORD dwSizeIndex, DWORD dwValue)

Parameters

  • dwSizeIndex - Index of the size. This parameter can be one of the following values:
     

    PPTTSZ_ROUNDED_CX
    PPTTSZ_ROUNDED_CY

    The width and the height of the ellipse used to draw the rounded corners.

     

    PPTTSZ_MARGIN_CX
    PPTTSZ_MARGIN_CY

    The left, right and top, bottom margins of the tooltip's text from the tooltip's edges.

     

    PPTTSZ_WIDTH_ANCHOR

    The width of the tooltip's anchor.

     

    PPTTSZ_HEIGHT_ANCHOR

    The height of the tooltip's anchor.

     

    PPTTSZ_MARGIN_ANCHOR

    The margin of the tooltip's anchor from his edge.

     

    PPTTSZ_OFFSET_ANCHOR_CX
    PPTTSZ_OFFSET_ANCHOR_CY

    The horizontal and vertical offset of the tooltip's anchor from the hot spot of a cursor

  • dwValue - The size in pixels.

Remarks

Call this member function to set the tooltip's sizes. For addition information see following picture:

CPPToolTip Overview | Class Members

CPPToolTip::GetSize

DWORD GetSize(DWORD nSizeIndex)

Return value

The size of the specified value.

Parameters

  • dwSizeIndex - Index of the size. See CPPToolTip::SetSize for a description of the valid values.

Remarks

This method returns the size of the specified value. See CPPToolTip::SetSize for addition information.

CPPToolTip Overview | Class Members

CPPToolTip::SetDirection

void SetDirection(DWORD dwDirection = PPTOOLTIP_BOTTOMEDGE_LEFT)

Parameters

  • dwDirection - mouse-pointer relative placement direction of the tooltip. This parameter can be one of the following values:
     

    PPTOOLTIP_TOPEDGE_LEFT

    A left corner of the top edge

     

    PPTOOLTIP_TOPEDGE_RIGHT

    A right corner of the top edge.

     

    PPTOOLTIP_TOPEDGE_CENTER

    By center of the top edge.

     

    PPTOOLTIP_BOTTOMEDGE_LEFT

    A left corner of the bottom edge

     

    PPTOOLTIP_BOTTOMEDGE_RIGHT

    A right corner of the bottom edge.

     

    PPTOOLTIP_BOTTOMEDGE_CENTER

    By center of the bottom edge.

     

    PPTOOLTIP_LEFTEDGE_TOP

    A top corner of the left edge

     

    PPTOOLTIP_LEFTEDGE_BOTTOM

    A bottom corner of the left edge.

     

    PPTOOLTIP_LEFTEDGE_VCENTER

    By center of the left edge.

     

    PPTOOLTIP_RIGHTEDGE_TOP

    A top corner of the right edge

     

    PPTOOLTIP_RIGHTEDGE_BOTTOM

    A bottom corner of the right edge.

     

    PPTOOLTIP_RIGHTEDGE_VCENTER

    By center of the right edge.

      For compatibility with 1.x versions of CPPToolTip a following values are available also:
     

    PPTOOLTIP_LEFT_TOP

    Same PPTOOLTIP_TOPEDGE_LEFT.

     

    PPTOOLTIP_RIGHT_TOP

    Same PPTOOLTIP_TOPEDGE_RIGHT.

     

    PPTOOLTIP_LEFT_BOTTOM

    Same PPTOOLTIP_BOTTOMEDGE_LEFT.

     

    PPTOOLTIP_RIGHT_BOTTOM

    Same PPTOOLTIP_BOTTOMEDGE_RIGHT.

Remarks

Sets a placement of the tooltip's anchor. For additional information above on this page.

CPPToolTip Overview | Class Members

CPPToolTip::GetDirection

DWORD GetDirection()

Return value

A placement of the tooltip's anchor. See CPPToolTip::SetDirection for a description of the valid values.

Remarks

Gets a placement of the tooltip's anchor.

CPPToolTip Overview | Class Members

CPPToolTip::SetTransparency

void SetTransparency(BYTE nTransparency = 0)

Parameters

  • nTransparency - A transparency value to be used on the tooltip. The default 0 assumes that your tooltip is opaque and 0xFF (255) for full transparency of the tooltip.

Remarks

Sets a transparency of the tooltip.

CPPToolTip Overview | Class Members

CPPToolTip::GetTransparency

BYTE GetTransparency()

Return value

A transparency value to be used on the tooltip.

CPPToolTip Overview | Class Members

CPPToolTip::SetDebugMode

void SetDebugMode(BOOL bDebug /*= TRUE*/)

Parameters

  • bDebug - Enables or disables a debug mode for the tooltip.

Remarks

Call this function to set a debug mode for a tooltip. In this mode tooltip will be displaying for any control of the parent window even if tool for this window not availabled in the tool's collection of the tooltip. Tooltip in a debug mode is a information about window under the mouse (owner, title, bounding rectangle, ID etc.).

CPPToolTip Overview | Class Members

 

CPPToolTip::MenuToolPosition

void MenuToolPosition(DWORD nPos /*= PPTOOLTIP_MENU_LEFT | PPTOOLTIP_MENU_TOP*/)

Parameters

  • nPos - A tooltip's position. This parameter can be any combination of single horizontal value and single vertical value of CPPToolTip:
      Horizontal position
     

    PPTOOLTIP_MENU_LEFT

     
     

    PPTOOLTIP_MENU_RIGHT

     
     

    PPTOOLTIP_MENU_CENTER

     
      Vertical position
     

    PPTOOLTIP_MENU_TOP

     
     

    PPTOOLTIP_MENU_BOTTOM

     
     

    PPTOOLTIP_MENU_VCENTER

     

Remarks

Sets a position of the tooltip's anchor about menu item.

CPPToolTip Overview | Class Members

 

CPPToolTip::EnableEscapeSequences

void EnableEscapeSequences(BOOL bEnable)

Parameters

  • bEnable - nables the escape sequences. If the escape sequences was disabled HTML-lite compiler will ignore the codes less then 0x20 (such \n, \r, \t).

Remarks

Call this function to enable or disable escape sequences in the HTML string.

CPPToolTip Overview | Class Members

 

CPPToolTip::SetMaxTipWidth

void SetMaxTipWidth(int nWidth);

Parameters

  • nWidth - The maximum tool tip window width to be set.

Remarks

Sets the maximum width for a tool tip window.

CPPToolTip Overview | Class Members

 

CPPToolTip::RelayEvent

void RelayEvent(MSG* pMsg)

Parameters

  • pMsg - Pointer to a MSG structure that contains the message to relay.

Remarks

Call this function to pass a mouse message to a tooltip control for processing. A tooltip control processes only the following messages, which are sent to it by RelayEvent:

WM_LBUTTONDOWN WM_MOUSEMOVE
WM_LBUTTONUP WM_RBUTTONDOWN
WM_MBUTTONDOWN WM_RBUTTONUP
WM_MBUTTONUP  

CPPToolTip Overview | Class Members

 

CPPToolTip::GetVersionI()

short GetVersionI()

Return Value

Number version of CPPToolTip.

Remarks

Returns the CPPToolTip version as a short number. Divide by 10 to get actual version.

CPPToolTip Overview | Class Members

 

CPPToolTip::GetVersionC()

LPCTSTR GetVersionC()

Return Value

Number version of CPPToolTip as string.

Remarks

Returns the CPPToolTip version as a string.

CPPToolTip Overview | Class Members

 

PPTOOLTIP_INFO Structure

struct PPTOOLTIP_INFO
{
    UINT nIDTool; 
    CRect rectBounds;
    CString sTooltip;
    UINT nMask;
    UINT nStyles;
    UINT nDirection;
    UINT nEffect;
    UINT nBehaviour;
    BYTE nGranularity;
    BYTE nTransparency;
    COLORREF crBegin;
    COLORREF crMid;
    COLORREF crEnd;
} PPTOOLTIP_INFO;
 

nIDTool

ID of the tool
 

rectBounds

Pointer to a RECT structure containing coordinates of the tool's bounding rectangle.
The coordinates are relative to the upper-left corner of the client area of the window identified by pWnd.
NULL if bounding rectangle don't uses for specified window
 

sTooltip

String containing the text for the tool
 

nMask

Mask of parameters not by default. This parameter can be any combination of following values:
  • PPTOOLTIP_MASK_STYLES
  • PPTOOLTIP_MASK_EFFECT
  • PPTOOLTIP_MASK_COLORS
  • PPTOOLTIP_MASK_DIRECTION
  • PPTOOLTIP_MASK_BEHAVIOUR
  • PPTOOLTIP_MASK_TRANSPARENCY
  •  

    nStyles

     
     

    nDirection

    This value sets a placement of the tooltip's anchor. See CPPToolTip::SetDirection for a description of the valid values.
     

    nEffect

    This value sets an effect of the background bitmap. See CPPToolTip::SetEffectBk for a description of the valid values.
     

    nBehaviour

    This value sets a behavior of the tooltip. See the CPPToolTip::SetBehaviour function for the list of the available flags .
     

    nGranularity

    This parameter add an uniform noise to the background bitmap. See CPPToolTip::SetEffectBk for a description of the valid values.
     

    nTransparency

     
     

    crBegin, crMid, crEnd

    The values sets the colors for gradient filling of background. See CPPToolTip::SetColorBk for a description of the valid values.

    History

     14 Feb 2003 First release
     17 Feb 2003

    Released version 1.1
    - Added new styles PPTOOLTIP_SHOW_DISABLED and PPTOOLTIP_SHOW_INACTIVE
    - Added new feature to Create() and SetDefaultSizes() methods for set the type of the tooltip's size.
    - Fixed bug with 0 TTDT_AUTOPOP value.
    - Fixed bug shows the tooltip after switch application on Alt+Tab

     19 Feb 2003

    Released version 1.2
    - Added support the tooltip for rectangles
    - Added new FindTool, IsExistTool and SetAtTool methods.
    - Many methods was updated.
    - New tool's collection basis on CArray instead CMap
    - Added three members to PPTOOLTIP_INFO structures
    - Removed the pointer to the window from NM_PPTOOLTIP_DISPLAY structure
    - Added new demo for implementation the tooltip with toolbars

     02 Apr 2003

    Released version 1.3
    - Added support the tooltip as help window (see ShowHelpTooltip)
    - Added the vertical aligns for the icon (see Styles)
    - Added support the icons with difference sizes (16x16, 32x32, 48x48 etc.)
    - Added new behaviours
    - Now the tooltip is not show if the PPTOOLTIP_INFO members as sTooltip is empty and hIcon is NULL.
    - Added two tags <img>, <ilst> to support draw a bitmaps and an icons inside a tooltip's text
    - A few minor update

     13 Apr 2003

    Released version 1.4
    - Added two tags <bmp> and <icon> to support draw a bitmaps and an icons inside a tooltip's text
    - Scales images which drawn with <img>, <bmp> and <icon> tags.
    - Added new behaviour (PPTOOLTIP_DISABLE_AUTOPOP)
    - A few minor update

     17 Apr 2003

    Released version 1.5
    - A few versions of the AddTool methods extended a new szIcon parameter
    - Added a feature to show a tooltip for child window (Thanks to Michael Ushakov).
    - A few minor update

     12 Mar 2004

    Released version 2.0
    - New core of a tooltip. More changes and new features. But so there are complexities at updating the programs using the version 1.х to version 2.0. Sorry!!! Frown | :(

     21 Nov 2004

    Released version 2.1
    - Added a support of animation in the tooltip (Look up SetDelayTime method and parameter "speed" of <ilst> tag)
    - Fixed some problems with UNICODE
    - Corrected a drawing for the some tooltip's directions and for the large tooltips
    - Changes a GetWndFromPoint mechanism
    - SetMaxTipWidth method was added

    Thanks to ...

    • Yaroslav Petrikevich for your help with writing this file.
    • Davide Calabro for his class CButtonST in which decisions of some questions have been found.
    • Chris Maunder for his articles devoted subclassing of the control.
    • Tomasz Sowinski for his help with Tooltip.
    • Michael Ushakov his help and advices on work with rectangles and toolbars.
    • Many people assisting to me the answers on CodeProject's forum.

    Known Problems

    • If you can help me, please let me know so that I can incorporate them into the next release.

    Planned Enhancements

    • If you have any other suggested improvements, please let me know so that I can incorporate them into the next release.

    Contacting the Author

    You are encouraged to use this class everywhere you want; there is no fee required for CPPTooltip. Freely add modifications and/or fix bugs, but please, send any of these to me!

    License

    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Share

    About the Author

    Eugene Pustovoyt
    Software Developer CBST
    Belarus Belarus
    No Biography provided

    Comments and Discussions

     
    Bugsome errors are shown we I use the code Pinmembernuaazdh5-Jun-14 16:30 
    GeneralRe: some errors are shown we I use the code Pinmemberamoreira6-Jun-14 5:09 
    GeneralMy vote of 5 PinmemberkissLife23-Dec-13 15:26 
    GeneralMy vote of 5 PinmemberNSA.getAllData();23-Jul-13 21:32 
    GeneralMy vote of 1 [modified] PinmemberMember 101379202-Jul-13 23:24 
    GeneralRe: My vote of 1 PinmemberEugene Pustovoyt4-Jul-13 4:16 
    SuggestionRe: My vote of 1 Pinmembermla15423-Jul-13 8:28 
    Questionchange text PinmemberBill Heitler3-Mar-13 1:06 
    GeneralMy vote of 4 Pinmemberzhanglipeng21-Dec-12 16:36 
    GeneralRe: My vote of 4 Pinmemberzhanglipeng21-Dec-12 16:37 
    GeneralRe: My vote of 4 PinmemberMember 1043801018-Dec-13 18:29 
    GeneralRe: My vote of 4 Pinmemberlanmanck7-Apr-14 22:27 
    Questionmouse event Pinmembertian_mao_chun11-Oct-12 7:05 
    QuestionNot Ascii Pinmemberkingwho27-Dec-11 16:33 
    QuestionHow to move the tooltip on CScrollView surface scroll? PinmemberPandele Florin28-Jun-11 1:23 
    QuestionCPPToolTip For CListCtrl Icon View Pinmembertssutha0327-Jun-11 16:19 
    General.Net version Pinmembermuharrem28-Mar-11 11:56 
    GeneralTo build this project with Unicode... PinmemberIain Clarke, Warrior Programmer9-Dec-10 8:24 
    BugRe: To build this project with Unicode... Pinmembermla15424-Apr-13 9:22 
    GeneralThank you for you work Pinmembersoxi20061014-Nov-10 20:29 
    GeneralPowerful Pinmemberxiangyongermian18-Oct-10 21:33 
    GeneralPageFaultCount rises Pinmemberhaisan31-Jan-10 3:04 
    GeneralGDI object leak resoved... Pinmemberuub21iec97228-Dec-09 7:02 
    When using image list tag - and setting an image list to the tool a leak occures that can crash the program.
    you need to move the line that frees the icon extracted from the image list from within the if(...) brakets
    GeneralMessage Pinmemberjiftle16-Dec-09 16:10 
    GeneralI like it Pinmemberdxlee23-Oct-09 4:45 
    Generalthis is so cools,thanks. Pinmembersherlockhua22-Oct-09 22:47 
    Generalgreat!! Pinmembergiada2223-Jul-09 23:46 
    Generalthes System Pinmembero48hm11-Jul-09 21:25 
    GeneralI get Error when rebuild demo project. PinmemberCuongfdd12-Jun-09 12:10 
    GeneralRe: I get Error when rebuild demo project. PinmemberCuongfdd28-Jun-09 16:24 
    GeneralRe: I get Error when rebuild demo project. Pinmembersullivangu20-Feb-10 15:41 
    GeneralRe: I get Error when rebuild demo project. Pinmembernirmaldas28-Jun-10 2:26 
    GeneralSolution to Unicode issue... PinmemberIain Clarke, Warrior Programmer9-Dec-10 8:22 
    QuestionHelp! How to add a close button into the tooltip? PinmemberTangyoufox7-May-09 0:16 
    GeneralRelayEvent PinmemberMember 266253524-Apr-09 2:30 
    GeneralCListCtrl toop tip [modified] PinmemberCanopenR13-Apr-09 8:09 
    GeneralRe: CListCtrl toop tip PinmemberCanopenR15-Apr-09 6:37 
    Questioncan not pass the building using vc6.0 for unicode release?help Pinmembere_ilite9-Apr-09 20:56 
    AnswerRe: can not pass the building using vc6.0 for unicode release?help Pinmembere_ilite20-Aug-09 20:42 
    GeneralHot rectangle underneath a group box. PinmemberShraddhan19-Mar-09 9:25 
    GeneralTool Tip in rectangle area PinmemberPadmanabha_M17-Dec-08 0:01 
    GeneralRe: Tool Tip in rectangle area PinmemberUKSonics23-Dec-08 10:58 
    Questionanybody know how to tooltip for Child dialog? Pinmemberkaviniswell16-Nov-08 21:32 
    GeneralDrawIcon rendering is incorrect for icons with transparency Pinmembermruban14-Nov-08 1:22 
    GeneralRe: DrawIcon rendering is incorrect for icons with transparency Pinmembermruban14-Nov-08 6:34 
    Questionthe AddTool's first parameter ?? Pinmemberkaviniswell14-Nov-08 1:10 
    AnswerRe: the AddTool's first parameter ?? Pinmemberkaviniswell14-Nov-08 1:33 
    GeneralCompatibility with Windows Mobile Pinmemberkashifhisam6-Nov-08 20:23 
    QuestionHow to show balloon on system tray icon? Pinmemberjustanywhere28-Oct-08 16:22 
    General_UNICODE Pinmembercoghlans16-Oct-08 2:21 

    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.

    | Advertise | Privacy | Mobile
    Web02 | 2.8.140926.1 | Last Updated 4 Mar 2005
    Article Copyright 2003 by Eugene Pustovoyt
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid