Click here to Skip to main content
13,344,273 members (56,180 online)
Click here to Skip to main content
Add your own
alternative version


35 bookmarked
Posted 2 Dec 2005

Displaying a Title and an Icon in a ToolTip window

, 2 Dec 2005
Rate this:
Please Sign up or sign in to vote.
How to display a title and an icon in a ToolTip window.

Sample Image


There are a lot of articles about ToolTip controls. However, all of them do not support displaying a title and an icon. So I am sharing my ToolTip control named ScToolTip which supports displaying of a title and an icon.

Using the Control

To use the control, you just drag the control onto the form from the Visual Studio .NET toolbox. Then each control on the form will have three new properties that you can set for the particular object. Visual Studio will add the additional code automatically to support displaying tooltip for controls.

Points of Interest

The ScToolTip class is declared as follows:

ProvideProperty("IconType", typeof(Control)),
public class ScToolTip : Component,IExtenderProvider

To display different titles and icons, you must fill the TOOLINFO structure like this:

TOOLINFO toolinfo = new TOOLINFO();
toolinfo.hwnd = handle;
// the window handle which will accept
// the TTN_NEEDTEXT message sended
// by the native tooltip window.

toolinfo.uFlags = TTF_IDISHWND;
toolinfo.uId = control.Handle;
toolinfo.lpszText = LPSTR_TEXTCALLBACKW;
// the native tooltip window sends
// the TTN_NEEDTEXT message to the owner
// window to retrieve the text.

When the owner window accepts the TTN_NEEDTEXT message, we do this:

if (m.Msg == NativeMethods.WM_NOTIFY)
    NativeMethods.NMHDR hdr = 

    if (hdr.code == NativeMethods.TTN_NEEDTEXT)
        Control control = 
                Control.FromHandle(new IntPtr(hdr.idFrom));
        if (control != null)
            string text = GetToolTip(control);

            string title = GetTipTitle(control);
            int icon = (int)GetIconType(control);

            // change the title and icon 
            NativeMethods.SendMessage(new HandleRef(this, 

            NativeMethods.NMTTDISPINFO info = 
            info.lpszText = text;


This article was inspired by wilsone8's article "Building a Ballontooltip provider in C#".


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

Yokel Sun
Web Developer
China China
I love c#.

You may also be interested in...

Comments and Discussions

Generalmissing features Pin
Saied Javadi12-Jun-06 6:10
memberSaied Javadi12-Jun-06 6:10 
GeneralVery Nice Pin
memberANIL KUMAR SHARMA (INDIA)31-Mar-06 23:12 
QuestionVery very nice but... Pin
dox2477-Dec-05 3:27
memberdox2477-Dec-05 3:27 
AnswerRe: Very very nice but... Pin
SimplyConfuzed12-Jul-06 10:15
memberSimplyConfuzed12-Jul-06 10:15 
AnswerRe: Very very nice but... Pin
joel danowitz29-Sep-08 20:17
memberjoel danowitz29-Sep-08 20:17 
GeneralRe: Very very nice but... Pin
SanShark15-Jun-09 1:13
memberSanShark15-Jun-09 1:13 
GeneralRe: Very very nice but... Pin
SanShark15-Jun-09 1:15
memberSanShark15-Jun-09 1:15 
GeneralRe: Very very nice but... Pin
SanShark15-Jun-09 1:14
memberSanShark15-Jun-09 1:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 2 Dec 2005
Article Copyright 2005 by Yokel Sun
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid