Handling double click event on items in CListCtrl

Posted on 2006-04-21
Last Modified: 2013-11-20
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.


Question by:jejob007
    LVL 3

    Expert Comment

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


    Author Comment

    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.


    LVL 3

    Accepted Solution

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


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    745 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

    15 Experts available now in Live!

    Get 1:1 Help Now