Solved

List-View tool tips

Posted on 2006-06-08
9
1,247 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
[X]
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
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 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