Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do I copy the contents of a CListCtrl object ?

How do I copy the contents of a CListCtrl object ?

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SherTeks
    wrote on last edited by
    #1

    I have a CListCtrl member in my dialog. During runtime, I fill the control's columns and rows with data using 'InsertColumn' and 'SetItemText' functions. Note : This List Control contains 5 rows and 3 columns full of data. Now, I want a copy of the data of the whole list control in another ClistCtrl object which I create during runtime using CListCtrl's Create function. How can I do this since I don't have a 'Copy' function as for data structures like CStringArray.

    I 1 Reply Last reply
    0
    • S SherTeks

      I have a CListCtrl member in my dialog. During runtime, I fill the control's columns and rows with data using 'InsertColumn' and 'SetItemText' functions. Note : This List Control contains 5 rows and 3 columns full of data. Now, I want a copy of the data of the whole list control in another ClistCtrl object which I create during runtime using CListCtrl's Create function. How can I do this since I don't have a 'Copy' function as for data structures like CStringArray.

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      There is no LB_CLONE_FROM_OTHER list control message, so you're going to have to roll your sleeves up and do it yourself. If you already have code to fill up the first control, can you move that into a function, and call it with either CListCtrl * or a dlg ID? Or if this will change over time, write a cloning function? Get the number of columns / rows of the first control, set the second one to the same. Call GetItem a lot on the first control, and SetItem a lot on the second? You'll have to be careful. One thing I can think of is an items lParam - if it is a casted pointer, can you use the same pointer? Or make a new object to point to? Etc. That sort of thing is application specific though. Iain.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups