Click here to Skip to main content
Click here to Skip to main content

A nice multiline ToolTipCtrl example.

By , 8 Feb 2004
 

Sample Image - ToolTipEx.jpg

Introduction

Well there is nothing much to say about this. This is a simple better looking multi-line tooltip control.

#pragma once
class CToolTipCtrlEx : public CToolTipCtrl
{
 DECLARE_DYNAMIC(CToolTipCtrlEx)
 enum Orientations
 {
  NW=1,
  NE,
  SW,
  SE,
 };
public:
 CToolTipCtrlEx();
 virtual ~CToolTipCtrlEx();
protected:
 DECLARE_MESSAGE_MAP()
 virtual void PreSubclassWindow();
private:
 afx_msg void OnPaint();
 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
 afx_msg void OnNcPaint();
public:
 COLORREF m_bkColor;//=RGB(255,255,255);
 COLORREF m_leftColor;//=RGB(255, 210, 83);
 COLORREF m_frameColor;//=RGB(155, 110, 53);
 COLORREF m_textColor;//=RGB(0,0,0);
 COLORREF m_arrowColor;//=RGB(0,0,0);
};

Just use it like a normal ToolTipCtrl control.

In the end

This is a tooltip inspired by the Delphi Flat Hint and the arrows are using the port of the Delphi drawing algorithm. This is free to use, modify it but you can't claim it. Any feedback and rating is most welcome.

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

TomKat
Web Developer
Romania Romania
I have been programming for the past 6 years in VBasic, Delphi, C, C++ .
I also have extended knowledge of webdesign (HTML, CSS, JavaScript, VBScript), webprogramming (PHP, ASP, ASP.NET (C#)) and database integration (mySql, MSSQL Server).
And when I`m not programming I`m working out or working on some personal projects .
Last but not least I`m looking for a project-based job in programming or webdesign .

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMulti Monitor support [modified]memberrenaudgillet13-Nov-08 6:59 
GeneralUsing ToolTipCtrlEx for toolbarmemberHemant K Jangid2-Oct-05 20:52 
GeneralTooltip for MSFlexGrid Cellssussana4raj25-Oct-04 23:56 
GeneralTooltip for MSFlexGrid CellssussAnonymous25-Oct-04 23:55 
GeneralRe: Tooltip for MSFlexGrid Cellsmemberrajroy_2419-Jul-07 3:21 
Generaluncompleted removed border with removed return CToolTipCtrl::OnNcPaint();membertony_w200016-Aug-04 1:18 
GeneralRe: uncompleted removed border with removed return CToolTipCtrl::OnNcPaint();memberTomKat16-Aug-04 2:31 
GeneralFix for XP / 2000memberVoidIndigo6-Aug-04 3:39 
Under XP / 2000 tooltips use WM_PRINT / WM_PRINTCLIENT to do the drawing. I figured this out after a half a day of tracing through Windows events by hand.
 
Add this to the CTooTipCtrlEx and it fixes the problem:
 
LRESULT CToolTipCtrlEx::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
	switch ( message )
	{
	case WM_PRINT:	// eat this message, tooltips under XP / 2000 use WM_PRINT + WM_PRINTCLIENT to draw
		return 0;	// if we eat this message, the WM_PRINTCLIENT will be skipped and WM_PAINT will be used
		break;		// which is what we expect with our overloaded CToolTipCtrlEx - SLC
	case WM_PRINTCLIENT:
		return 0;	// we should never get this... but just in case - SLC
		break;
	default:
		//TRACE( _T("OTHER :0x%x\r\n"), message );
		break;
	}
	return CToolTipCtrl::WindowProc( message, wParam, lParam );
}
 
Thanks for the great work!

 
-
Void
GeneralRe: Fix for XP / 2000memberVoidIndigo6-Aug-04 3:52 
GeneralRe: Fix for XP / 2000memberTomKat7-Aug-04 2:32 
GeneralRe: Fix for XP / 2000memberVoidIndigo11-Aug-04 3:44 
GeneralRe: Fix for XP / 2000memberrspeng14-Mar-05 20:11 
GeneralHelpsussalexwinx17-Feb-04 21:42 
GeneralRe: HelpmemberTomKat18-Feb-04 7:04 
GeneralRe: HelpmemberVoidIndigo6-Aug-04 3:41 
General!!!Bug FixmemberTomKat16-Feb-04 21:08 
GeneralNice but ..membergri14-Feb-04 1:31 
GeneralRe: Nice but ..memberTomKat14-Feb-04 1:59 
GeneralRe: Nice but ..membergri14-Feb-04 3:01 
GeneralRe: Nice but ..membermrsilver14-Feb-04 3:20 
GeneralRe: Nice but ..memberMember 222813625-Aug-08 18:46 
GeneralRe: Nice but ..memberTomKat15-Feb-04 21:40 
GeneralRe: Nice but ..memberFahad Ahmed29-Jul-04 10:20 
GeneralRe: Nice but ..memberswqswqswqswq31-Oct-05 8:25 
GeneralRe: Nice but ..memberVtt12-Aug-09 23:38 
GeneralThe Book of KnowledgememberAntonio Barros9-Feb-04 23:19 
GeneralRe: The Book of KnowledgememberTomKat9-Feb-04 23:40 
GeneralRe: The Book of KnowledgememberGary Wheeler10-Feb-04 10:50 
GeneralRe: The Book of KnowledgememberTomKat11-Feb-04 1:32 
GeneralRe: The Book of KnowledgememberHockey2-May-04 22:27 
GeneralRe: The Book of KnowledgememberTomKat3-May-04 0:18 
GeneralGood job.membertony_w20009-Feb-04 13:00 
GeneralRe: Good job.memberTomKat9-Feb-04 19:53 
GeneralAnd in C#memberAntonio Barros9-Feb-04 8:10 
GeneralRe: And in C#sussTomKat9-Feb-04 9:36 

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130617.1 | Last Updated 9 Feb 2004
Article Copyright 2004 by TomKat
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid