Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

List-View tool tips

Posted on 2006-06-08
9
1,229 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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