Click here to Skip to main content
Click here to Skip to main content
Go to top

ParamTooltip

, 11 Nov 2004
Rate this:
Please Sign up or sign in to vote.
Implements a Tooltip control like that displayed with the Intellisense technology.

Sample Image of the demo ParamTooltip

Introduction

This article demonstrates creating a class to show tooltips for methods and its parameters, like Intellisense technology.

Using the class

Using the class is easy. You only have to instantiate an object, create the control and add information about the methods and its parameters, and then show it in any screen position.

Create a ParamTooltipCtrl in your application

Include ParamTooltipCtrl.h in the source file where you want to use the CParamTooltipCtrl control:

#include "ParamTooltipCtrl.h"

Create a member variable for the control:

CParamTooltipCtrl m_wndTT;

Create the control and initialize it with the names of methods and their parameters:

m_wndTT.Create(this);

CString sMethod;
vector<CString> setParams;

sMethod = "int DrawText";
setParams.push_back(CString("const CString &str"));
setParams.push_back(CString("LPRECT lpRect"));
setParams.push_back(CString("UINT nFormat"));
m_wndTT.AddMethod(sMethod, setParams);

setParams.resize(0);
setParams.push_back(CString("LPCTSTR lpszString"));
setParams.push_back(CString("int nCount"));
setParams.push_back(CString("LPRECT lpRect"));
setParams.push_back(CString("UINT nFormat"));
m_wndTT.AddMethod(sMethod, setParams);

Show the ParamTooltipCtrl control in the screen

When you want to show the control, call the methods SetCurMethod and SetCurParam to set the method and parameter you want to emphasize, and then call the method ShowTooltip:

m_wndTT.SetCurMethod(0);
m_wndTT.SetCurParam(1);
m_wndTT.ShowTooltip(CPoint(300,300));

To hide the control, call the CWnd::ShowWindow method:

m_wndTT.ShowWindow(SW_HIDE);

Iterate between methods and parameters

To iterate between the previous and next methods, and previous and next parameters, use the ShowPrevMethod, ShowNextMethod, ShowPrevParam and ShowNextParam methods:

void CParamToolTipView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    switch( nChar ) {
        case VK_UP:
            m_wndTT.ShowPrevMethod();
            break;
        case VK_DOWN:
            m_wndTT.ShowNextMethod();
            break;
        case VK_LEFT:
            m_wndTT.ShowPrevParam();
            break;
        case VK_RIGHT:
            m_wndTT.ShowNextParam();
            break;
    }

    CView::OnKeyDown(nChar, nRepCnt, nFlags);
}

Points of Interest

The method CParamTooltipCtrl::Draw draws the bitmaps creating it in memory, so you don't have to load it from resources.

History

Version 1.0 - Wed, 10 Nov of 2004.

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

Share

About the Author

_goa
Software Developer Dreaming With Objects S.L.
Spain Spain
No Biography provided

Comments and Discussions

 
GeneralDestroyWindow PinmemberRoger6519-Nov-04 4:07 

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.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 12 Nov 2004
Article Copyright 2004 by _goa
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid