Solved

List-View tool tips

Posted on 2006-06-08
9
1,220 Views
1 Endorsement
Last Modified: 2013-12-03
Im trying to add tool tips to my list-view.  Here is my code:

      LVSETINFOTIP info;
      memset(&info,0,sizeof(info));
      info.cbSize = sizeof(info);
      info.dwFlags = 0;
      info.iItem = 0;
      info.iSubItem = 0;
      info.pszText = wbuffer;
      if(!SendMessage(GetDlgItem(this->m_hwndMainDlg,IDC_LIST_MAIN),LVM_SETINFOTIP,0,(LPARAM)&info))
      {
            //ERROR:  I get here
      }

Why would SendMessage() return FALSE here?  
1
Comment
Question by:lwinkenb
9 Comments
 
LVL 5

Author Comment

by:lwinkenb
ID: 16866526
Also, my manifest file looks like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="1.0.0.0"
    processorArchitecture="X86"
    name="CompanyName.ProductName.YourApplication"
    type="win32"
/>
<description>Your application description here.</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>
</assembly>
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16871097
iSubItem
Value of type int that contains the one-based index of the subitem to which this structure refers.

It looks like you set 0-based index.
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 16871203
It still fails when I changed iSubItem to 1.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 2

Expert Comment

by:karfi
ID: 16944221
Did you try your code on windows xp?
MSDN says for this message:
"Minimum operating systems ... Windows XP"
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 16948008
yes
0
 
LVL 5

Accepted Solution

by:
bastibartel earned 500 total points
ID: 16954093
Hi lwinkenb

The trick is to catch notification messages LVN_GETINFOTIP

Subclass the CListView, using a custom class (CMyListCtrl) derived from CListCtrl.
Within the derived class you will receive LVN_GETINFOTIP notification messages.


//## Header file MyListCtrl.h ##################

class CMyListCtrl  : public CListCtrl
{
  public:
  CMyListCtrl  () {;}
  ~CMyListCtrl  (){;}

   //{{AFX_MSG(CMyListCtrl)
   afx_msg void OnLVNGetTipInfo(NMHDR* pNMHDR, LRESULT* pResult) ;
   //}}AFX_MSG
 
  [...]
  DECLARE_MESSAGE_MAP()
};



//## Implmentation of MyListCtrl.h ##################

BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrl)
      //{{AFX_MSG_MAP(CMyListCtrl)
      ON_NOTIFY_REFLECT(LVN_GETINFOTIP,      OnLVNGetTipInfo)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

//****************************************************
//** some intiailzation prior to creation of ListView Control
//**
void CMyListCtrl::PreSubclassWindow()
{
      CListCtrl::PreSubclassWindow();
      
      //** Please send me LVN_GETINFOTIP messages
      SetExtendedStyle( GetExtendedStyle() | LVS_EX_INFOTIP);
}

//****************************************************
//** Message Handler for LVN_GETINFOTIP notifications
//**
void CMyListCtrl::OnLVNGetTipInfo(NMHDR* pNMHDR, LRESULT* pResult)
{
               //** we need a persistent buffer - very lazy programming
      static CString strInfo;
      
      if (pNMHDR->code != LVN_GETINFOTIP) return;
      NMLVGETINFOTIP *lpGetInfoTip = (NMLVGETINFOTIP*)pNMHDR;
      
      int iItem       = lpGetInfoTip->iItem;
      int iSubItem  = lpGetInfoTip->iSubItem;  

      strInfo = "hello"; //** Display Info for 'iItem'      
                //* I believe no subitem info is ever available */
      
                //** fill the NMLVGETINFOTIP structure
      lpGetInfoTip->pszText = strInfo.GetBuffer(1);
      lpGetInfoTip->cchTextMax = strInfo.GetLength();      
}


Cheers,
Sebastian
0
 
LVL 5

Expert Comment

by:bastibartel
ID: 16954113
Errata:  It was supposed to say:

/## Header file MyListCtrl.h #########################

...and

//## Implementation of class CMyListCtrl ( the cpp file) ########
0
 
LVL 5

Expert Comment

by:bastibartel
ID: 17029865
Hello lwinkenb

Are you making any progress on your Tooltip issue ?
Is there anything we may still do for you ?

Cheers,
Sebastian
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 17032102
Sorry it took so long.  Yes, your code was helpful.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question