Solved

List-View tool tips

Posted on 2006-06-08
9
1,206 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now