Click here to Skip to main content
Licence 
First Posted 29 Apr 2005
Views 86,861
Bookmarked 57 times

Adding "Balloon" style to ToolTip provider

By | 29 Apr 2005 | Article
Adding "Balloon" style to ToolTip provider.

Sample Image - Balloon_ToolTip.jpg Red 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 most 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, exception will be thrown.

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

  • 02/05/05

    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

About the Author

Mihail Stefanov



United States United States

Member

http://www.mommosoft.com

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
Generalgood work Pinmemberamin keshani21:45 4 Nov '06  
Generalc# .net 2005 error Pinmemberradnix5:36 15 Apr '06  
GeneralRe: c# .net 2005 error PinmemberMihail Stefanov10:38 15 Apr '06  
GeneralRe: c# .net 2005 error Pinmemberbhupinders20:59 14 Mar '07  
QuestionRight to Left Balloon PinmemberAmirSasan10:53 30 Oct '05  
AnswerRe: Right to Left Balloon PinmemberMihail Stefanov10:47 2 Nov '05  
GeneralRe: Right to Left Balloon PinmemberAmirSasan10:52 3 Nov '05  
Generalgood idea PinmemberNeil Yao20:25 27 Oct '05  
GeneralRe: good idea PinmemberMihail Stefanov20:30 27 Oct '05  
GeneralCustom balloon content PinmemberWillemM0:01 5 Jul '05  
GeneralRe: Custom balloon content PinmemberMihail Stefanov1:18 5 Jul '05  
GeneralAny news? Pinmember_JERKER_22:42 17 Oct '05  
GeneralRe: Any news? PinmemberMihail Stefanov20:29 27 Oct '05  
GeneralRe: Custom balloon content PinmemberMihail Stefanov10:44 2 Nov '05  
GeneralAwesome! PinmemberNick Z.7:46 5 May '05  
GeneralRe: Awesome! PinmemberRichNFamous0:02 19 May '05  
GeneralGood job! PinmemberHyperX7:43 2 May '05  
GeneralRe: Good job! PinmemberMihail Stefanov9:02 2 May '05  
GeneralRe: Good job! PinmemberHyperX11:12 2 May '05  

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 29 Apr 2005
Article Copyright 2005 by Mihail Stefanov
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid