Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

List-View tool tips

Posted on 2006-06-08
9
Medium Priority
?
1,282 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

636 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