Click here to Skip to main content
15,885,244 members
Articles / Desktop Programming / MFC
Article

A nice multiline ToolTipCtrl example.

Rate me:
Please Sign up or sign in to vote.
4.42/5 (24 votes)
8 Feb 2004 124.4K   3.9K   48   35
A nice multiline ToolTipCtrl example looking like the one available in Delphi.

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


Written By
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 .

Comments and Discussions

 
GeneralMulti Monitor support [modified] Pin
renaudgillet13-Nov-08 6:59
renaudgillet13-Nov-08 6:59 
GeneralUsing ToolTipCtrlEx for toolbar Pin
Hemant_Jangid2-Oct-05 20:52
Hemant_Jangid2-Oct-05 20:52 
GeneralTooltip for MSFlexGrid Cells Pin
ana4raj25-Oct-04 23:56
sussana4raj25-Oct-04 23:56 
GeneralTooltip for MSFlexGrid Cells Pin
Anonymous25-Oct-04 23:55
Anonymous25-Oct-04 23:55 
GeneralRe: Tooltip for MSFlexGrid Cells Pin
rajroy_2419-Jul-07 3:21
rajroy_2419-Jul-07 3:21 
Generaluncompleted removed border with removed return CToolTipCtrl::OnNcPaint(); Pin
tony_w200016-Aug-04 1:18
tony_w200016-Aug-04 1:18 
GeneralRe: uncompleted removed border with removed return CToolTipCtrl::OnNcPaint(); Pin
TomKat16-Aug-04 2:31
TomKat16-Aug-04 2:31 
GeneralFix for XP / 2000 Pin
VoidIndigo6-Aug-04 3:39
VoidIndigo6-Aug-04 3:39 
GeneralRe: Fix for XP / 2000 Pin
VoidIndigo6-Aug-04 3:52
VoidIndigo6-Aug-04 3:52 
GeneralRe: Fix for XP / 2000 Pin
TomKat7-Aug-04 2:32
TomKat7-Aug-04 2:32 
GeneralRe: Fix for XP / 2000 Pin
VoidIndigo11-Aug-04 3:44
VoidIndigo11-Aug-04 3:44 
GeneralRe: Fix for XP / 2000 Pin
rspeng14-Mar-05 20:11
rspeng14-Mar-05 20:11 
This solution is great. But it will make the tooltip
not shown for the first time the mouse move over
the control. Therefore, I add on command as

LRESULT CToolTipCtrlAdv::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
switch(message) {
case WM_PRINT: // eat this message, tooltips under XP / 2000 use WM_PRINT + WM_PRINTCLIENT to draw
SendMessage(WM_PAINT);
return 0; // if we eat this message, the WM_PRINTCLIENT will be skipped and WM_PAINT will be used
// which is what we expect with our overloaded CToolTipCtrlAdv - SLC
break;

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);
}

And it work well.

Spock Peng
GeneralHelp Pin
alexwinx17-Feb-04 21:42
sussalexwinx17-Feb-04 21:42 
GeneralRe: Help Pin
TomKat18-Feb-04 7:04
TomKat18-Feb-04 7:04 
GeneralRe: Help Pin
VoidIndigo6-Aug-04 3:41
VoidIndigo6-Aug-04 3:41 
General!!!Bug Fix Pin
TomKat16-Feb-04 21:08
TomKat16-Feb-04 21:08 
GeneralNice but .. Pin
gri14-Feb-04 1:31
gri14-Feb-04 1:31 
GeneralRe: Nice but .. Pin
TomKat14-Feb-04 1:59
TomKat14-Feb-04 1:59 
GeneralRe: Nice but .. Pin
gri14-Feb-04 3:01
gri14-Feb-04 3:01 
GeneralRe: Nice but .. Pin
mrsilver14-Feb-04 3:20
mrsilver14-Feb-04 3:20 
GeneralRe: Nice but .. Pin
cdpc25-Aug-08 18:46
cdpc25-Aug-08 18:46 
GeneralRe: Nice but .. Pin
TomKat15-Feb-04 21:40
TomKat15-Feb-04 21:40 
GeneralRe: Nice but .. Pin
Fahad Ahmed29-Jul-04 10:20
Fahad Ahmed29-Jul-04 10:20 
GeneralRe: Nice but .. Pin
swqswqswqswq31-Oct-05 8:25
swqswqswqswq31-Oct-05 8:25 
GeneralRe: Nice but .. Pin
Vtt12-Aug-09 23:38
Vtt12-Aug-09 23:38 

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.