Handling double click event on items in CListCtrl

I am doing a poject in Win32 App that uses CListCtrl class.I want to know how to handle the double click event on items and know which item the user clicked on. Also when the user double clicks the item I want to open a note pad window that displays details of the clicked item. Please tell me what message map/message handler I should add to achieve this.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Jejo, the message you have to handle to accomplish this is the NB_DBLCLK...

For you to know what item is selected you just have to call: pListCtrl->GetSelectionMark();

Then you can call pListCtrl->GetItemText(pListCtrl->GetSelectionMark(), nSubItemToQuery) to get the corresponding text for each column...

Then you can output it to a text file and open it using:

ShellExecuteA(NULL, "open", pszFileNamePath, NULL, NULL, SW_SHOW);

Hope it helps...

jejob007Author Commented:
Hi NeoEGM thanks for your valuable comment.

Selecting items and opening file works fine but still can you please elaborate more on the NB_DBCLK message.How do I handle this message.What function do  I write and what should I write in declare message map area.


This would be a generic message map for you to handle the message...

BEGIN_MESSAGE_MAP(CWindowClass, CBaseWindowClass)
          ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnNMDblclkList1)

Anyway, if you are using VisualStudio, you could just make it write it for you... Just right click the ListCtrl in the dialog and go to AddEventHandler...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.