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

CListCtrl issue

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmshelpquestionc++data-structures
4 Posts 3 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.
  • I Offline
    I Offline
    imak
    wrote on last edited by
    #1

    I have a MFC application that has a lot of list view in report mode. I have implemented a CGenericListCtrl (derived from CListCtrl) that contains common functionality used in all those list views. All the list views used in my applicatons are derived from CGenericListCtrl. What I am trying to do is basically impement the sorting functionality based upon the type of the columns. For example some columns could be numeric whereas other could be string or date type. In the CGenericListCtrl I have implemnted a Compare function that apply the sorting algorithm depending upon type of the column. So Let's say I have a class CMYFirstListCtrl that is derived from CGenericListCtrl. In CMYFirstListCtrl at the time of creation of columns I also have an array that contains the type of data stored in each column ( via some enumns). What I am trying to do is that when user click on CMYFirstListCtrl header for sorting, I need to pass the column type enum to Compare method of CGenericListCtrl. Can anyone please help me how can I pass this info from a derived class to its parent though some sort of notification?

    _ 1 Reply Last reply
    0
    • I imak

      I have a MFC application that has a lot of list view in report mode. I have implemented a CGenericListCtrl (derived from CListCtrl) that contains common functionality used in all those list views. All the list views used in my applicatons are derived from CGenericListCtrl. What I am trying to do is basically impement the sorting functionality based upon the type of the columns. For example some columns could be numeric whereas other could be string or date type. In the CGenericListCtrl I have implemnted a Compare function that apply the sorting algorithm depending upon type of the column. So Let's say I have a class CMYFirstListCtrl that is derived from CGenericListCtrl. In CMYFirstListCtrl at the time of creation of columns I also have an array that contains the type of data stored in each column ( via some enumns). What I am trying to do is that when user click on CMYFirstListCtrl header for sorting, I need to pass the column type enum to Compare method of CGenericListCtrl. Can anyone please help me how can I pass this info from a derived class to its parent though some sort of notification?

      _ Offline
      _ Offline
      _anil_
      wrote on last edited by
      #2

      Hi I am not sure if I have understood your problem!!! What I think is that you can implement the funtionality for parent class instead of derive class, so that the parent class funtion can directly be called. this may not help you lot... other method you may use "super" to get parent class methods and variable.

      J 1 Reply Last reply
      0
      • _ _anil_

        Hi I am not sure if I have understood your problem!!! What I think is that you can implement the funtionality for parent class instead of derive class, so that the parent class funtion can directly be called. this may not help you lot... other method you may use "super" to get parent class methods and variable.

        J Offline
        J Offline
        Jagadeesh VN
        wrote on last edited by
        #3

        There is no keyword super in C++. It's available only in Java. I am not seeing any problem whatsoever using the Sort function of the Base class. Just call the method Sort(...) and pass the parameters. As long as the Sort method is not virtual, you will always end-up in the Base class method. Alternatively you can think of making Sort(...) method static as long as it is not refering any class memebers and you are passing all the values in the parameter list. You can invoke the method using CGenericListCtrl::Sort(...) "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

        I 1 Reply Last reply
        0
        • J Jagadeesh VN

          There is no keyword super in C++. It's available only in Java. I am not seeing any problem whatsoever using the Sort function of the Base class. Just call the method Sort(...) and pass the parameters. As long as the Sort method is not virtual, you will always end-up in the Base class method. Alternatively you can think of making Sort(...) method static as long as it is not refering any class memebers and you are passing all the values in the parameter list. You can invoke the method using CGenericListCtrl::Sort(...) "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

          I Offline
          I Offline
          imak
          wrote on last edited by
          #4

          Thanks for the response guys. Problem is that OnColumnClick is invoked from the dervied class and during that event I am not sure how can I pass this additional variable containing type of the header. Is there any lParam type of thing that I use to fill in this info? Thanks

          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