MFC: How to copy/paste from CListView

Posted on 2009-04-23
Last Modified: 2013-11-20
Dear Experts

In a MFC application with a CListView I would like to add the functionality of being able to select some or all of the fields (with the mouse and selct all by "Ctrl+A"), copy it by pressing "Ctrl+C" and then pasting it, in for instance a Windows Notes document, with the columns delimited by for instance commas. Do any of you have an example of how to do it? I would be very happy!

Thanks very much in advance, Peter
Question by:PeterTokeHedenAhlgren
    1 Comment
    LVL 30

    Accepted Solution

    Hi PeterTokeHedenAhlgren,

    unfortunateley I don't have a sample, but I can describe, it's not so difficult.

    You just need to copy the text you want to paster otherwhere onto the clipboard. For this you simply iterate through the selected rows and build a string of lines of the comma-seperated sub-/item texts. (BTW: If you use a virtual list control you'll have to fill that string from the scratch).

    To do so you can use OpenClipboard, SetClipboardData and CloseClipboard. The clipboard format type to use is CF_TEXT.

    Here you can find a detailed description including sample about how to use a clipboard:

    Hope that helps,


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Unix / Linux grid computing 5 96
    How to know only "File created" with EventLog 3 24
    tripleUp challenge 7 54
    fix34  challenge 9 70
    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    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.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now