Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / Windows Forms

Adding "Balloon" Style to ToolTip Provider

Rate me:
Please Sign up or sign in to vote.
4.59/5 (23 votes)
29 Apr 20051 min read 125.1K   2K   57   20
How to add "Balloon" style to ToolTip provider
In this post, I present a solution about balloon Tooltip which I think is the easiest and does not influence existing System.Windows.Forms.ToolTip implementation.

Sample Image - Balloon_ToolTip.jpgRed Balloon toolTip

Introduction

There are a lot of articles about "balloon" Tooltip, many lines of codes written with classes which solved the problem. Here, I show yet another solution which I think is the easiest and does not influence existing System.Windows.Forms.ToolTip implementation.

Solution

Probably you may know, reflection is a big advantage in .NET Framework, and I think will use it this time also. System.Windows.Forms.ToolTip class holds handle to the native tooltip window. This handle is non public, so we need to use reflection to get this member. Then, we can change the style of the window to "balloon".

Usage

Need to call function SetBalloonStyle from place where the ToolTip window handle is created. In my example, I do it in OnLoad of the Form. If you call the function with handle which is not valid, an exception will be thrown.

C#
protected override void OnLoad(EventArgs e)
{
  base.OnLoad (e);  
  // set toolTip native window style to "balloon".
  NativeMethods.SetBalloonStyle ( toolTip1 );
}

Final Notes

Same approach can be used in many places, like the example in System.Windows.Forms.PropertyGrid to make it flat.

History

  • 2nd May, 2005: Added SetBackColor function, showing how you can change the color of the tooltip window

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.


Written By
United States United States
http://www.mommosoft.com

Comments and Discussions

 
QuestionNice work Pin
Mike Hankey18-Aug-14 6:18
mveMike Hankey18-Aug-14 6:18 
Generalgood work Pin
amin keshani4-Nov-06 21:45
amin keshani4-Nov-06 21:45 
Generalc# .net 2005 error Pin
radnix15-Apr-06 5:36
radnix15-Apr-06 5:36 
GeneralRe: c# .net 2005 error Pin
Mihail Stefanov15-Apr-06 10:38
Mihail Stefanov15-Apr-06 10:38 
GeneralRe: c# .net 2005 error Pin
bhupinders14-Mar-07 20:59
bhupinders14-Mar-07 20:59 
Thanks very much. I was also facing same problem.


Bhupinder Bajwa
QuestionRight to Left Balloon Pin
AmirSasan30-Oct-05 10:53
AmirSasan30-Oct-05 10:53 
AnswerRe: Right to Left Balloon Pin
Mihail Stefanov2-Nov-05 10:47
Mihail Stefanov2-Nov-05 10:47 
GeneralRe: Right to Left Balloon Pin
AmirSasan3-Nov-05 10:52
AmirSasan3-Nov-05 10:52 
Generalgood idea Pin
Neil Yao27-Oct-05 20:25
Neil Yao27-Oct-05 20:25 
GeneralRe: good idea Pin
Mihail Stefanov27-Oct-05 20:30
Mihail Stefanov27-Oct-05 20:30 
GeneralCustom balloon content Pin
WillemM5-Jul-05 0:01
WillemM5-Jul-05 0:01 
GeneralRe: Custom balloon content Pin
Mihail Stefanov5-Jul-05 1:18
Mihail Stefanov5-Jul-05 1:18 
GeneralAny news? Pin
_JERKER_17-Oct-05 22:42
_JERKER_17-Oct-05 22:42 
GeneralRe: Any news? Pin
Mihail Stefanov27-Oct-05 20:29
Mihail Stefanov27-Oct-05 20:29 
GeneralRe: Custom balloon content Pin
Mihail Stefanov2-Nov-05 10:44
Mihail Stefanov2-Nov-05 10:44 
GeneralAwesome! Pin
Nick Z.5-May-05 7:46
Nick Z.5-May-05 7:46 
GeneralRe: Awesome! Pin
RichNFamous19-May-05 0:02
RichNFamous19-May-05 0:02 
GeneralGood job! Pin
RK KL2-May-05 7:43
RK KL2-May-05 7:43 
GeneralRe: Good job! Pin
Mihail Stefanov2-May-05 9:02
Mihail Stefanov2-May-05 9:02 
GeneralRe: Good job! Pin
RK KL2-May-05 11:12
RK KL2-May-05 11:12 

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.