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. sorting a list

sorting a list

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmsquestion
21 Posts 6 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.
  • D David Crow

    FarPointer wrote:

    Please check this out :-

    Why (send this to me)? I know very well how to sort a list control.


    "The largest fire starts but with the smallest spark." - David Crow

    "Judge not by the eye but by the heart." - Native American Proverb

    F Offline
    F Offline
    FarPointer
    wrote on last edited by
    #10

    Well to first add the notification for HDN_ITEMCLICK is tough:- why because the on notify macro is as follows ON_NOTIFY( wNotifyCode, id, memberFxn ) and the id of the header control is zero unless explicitly set . Regards, FarPointer Blog:FARPOINTER

    D 1 Reply Last reply
    0
    • F FarPointer

      Well to first add the notification for HDN_ITEMCLICK is tough:- why because the on notify macro is as follows ON_NOTIFY( wNotifyCode, id, memberFxn ) and the id of the header control is zero unless explicitly set . Regards, FarPointer Blog:FARPOINTER

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #11

      FarPointer wrote:

      Well to first add the notification for HDN_ITEMCLICK is tough:-

      Compared to what, chewing gum? It gets added to the message map just like any other. How's that tough?

      FarPointer wrote:

      why because the on notify macro is as follows ON_NOTIFY( wNotifyCode, id, memberFxn )

      Yeah, so?

      FarPointer wrote:

      ...the id of the header control is zero unless explicitly set .

      Of course it's zero, and has been since the control's inception. Why would it need to be anything else?


      "The largest fire starts but with the smallest spark." - David Crow

      "Judge not by the eye but by the heart." - Native American Proverb

      F 1 Reply Last reply
      0
      • D David Crow

        FarPointer wrote:

        Well to first add the notification for HDN_ITEMCLICK is tough:-

        Compared to what, chewing gum? It gets added to the message map just like any other. How's that tough?

        FarPointer wrote:

        why because the on notify macro is as follows ON_NOTIFY( wNotifyCode, id, memberFxn )

        Yeah, so?

        FarPointer wrote:

        ...the id of the header control is zero unless explicitly set .

        Of course it's zero, and has been since the control's inception. Why would it need to be anything else?


        "The largest fire starts but with the smallest spark." - David Crow

        "Judge not by the eye but by the heart." - Native American Proverb

        F Offline
        F Offline
        FarPointer
        wrote on last edited by
        #12

        Well not compared to chewing gum :-D ya my mistake i was expecting the message map to be like this:- ON_NOTIFY( HDN_ITEMCLICK, 0, OnHeaderClick) but it will be like this i guess ON_NOTIFY( HDN_ITEMCLICK, IDC_LIST, OnHeaderClick) Regards, FarPointer Blog:FARPOINTER

        1 Reply Last reply
        0
        • D David Crow

          In your CListView/CListCtrl-derived class, provide a handler for the HDN_ITEMCLICK notification. Call the SortItems() method from there. See here for more.


          "The largest fire starts but with the smallest spark." - David Crow

          "Judge not by the eye but by the heart." - Native American Proverb

          A Offline
          A Offline
          aafcls
          wrote on last edited by
          #13

          are there any available comparison functions just for a simple list control for a clicked-on header, to be passed to SortItem?

          D 1 Reply Last reply
          0
          • A aafcls

            are there any available comparison functions just for a simple list control for a clicked-on header, to be passed to SortItem?

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #14

            Other than the one I already provided? It doesn't get much simpler.


            "The largest fire starts but with the smallest spark." - David Crow

            "Judge not by the eye but by the heart." - Native American Proverb

            A 1 Reply Last reply
            0
            • D David Crow

              Other than the one I already provided? It doesn't get much simpler.


              "The largest fire starts but with the smallest spark." - David Crow

              "Judge not by the eye but by the heart." - Native American Proverb

              A Offline
              A Offline
              aafcls
              wrote on last edited by
              #15

              are you referring to the CompareFunction in the article you sent? in that case, would I have to make use of "GetItemText" to fill in the "items" in CompareFunction? i'm just not sure how to implement this with a list of unknown quantity of items..

              D L 2 Replies Last reply
              0
              • A aafcls

                are you referring to the CompareFunction in the article you sent? in that case, would I have to make use of "GetItemText" to fill in the "items" in CompareFunction? i'm just not sure how to implement this with a list of unknown quantity of items..

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #16

                aafcls wrote:

                in that case, would I have to make use of "GetItemText"

                No. You would cast lParam1 and lParam2 to the appropriate pointer value (the pointer value used with SetItemData()).


                "The largest fire starts but with the smallest spark." - David Crow

                "Judge not by the eye but by the heart." - Native American Proverb

                A 1 Reply Last reply
                0
                • A aafcls

                  are you referring to the CompareFunction in the article you sent? in that case, would I have to make use of "GetItemText" to fill in the "items" in CompareFunction? i'm just not sure how to implement this with a list of unknown quantity of items..

                  L Offline
                  L Offline
                  led mike
                  wrote on last edited by
                  #17

                  :confused:

                  aafcls wrote:

                  unknown quantity of items

                  Do you not understand that sort will be called from inside a sorting algorithm and you don't need to be concerned with the quantity of items?

                  "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
                  Colin Angus Mackay in the C# forum

                  led mike

                  1 Reply Last reply
                  0
                  • D David Crow

                    aafcls wrote:

                    in that case, would I have to make use of "GetItemText"

                    No. You would cast lParam1 and lParam2 to the appropriate pointer value (the pointer value used with SetItemData()).


                    "The largest fire starts but with the smallest spark." - David Crow

                    "Judge not by the eye but by the heart." - Native American Proverb

                    A Offline
                    A Offline
                    aafcls
                    wrote on last edited by
                    #18

                    I am very sorry I do not understand. I do not make use of SetItemData(). All I have is my list control where I have a few InsertColumn()s and SetItemText() accordingly. When you tell me to cast these as pointers int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) ...pointing to what exactly?

                    E D 2 Replies Last reply
                    0
                    • A aafcls

                      I am very sorry I do not understand. I do not make use of SetItemData(). All I have is my list control where I have a few InsertColumn()s and SetItemText() accordingly. When you tell me to cast these as pointers int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) ...pointing to what exactly?

                      E Offline
                      E Offline
                      earl
                      wrote on last edited by
                      #19

                      Have you tried the sample code in the link David Crow gave you? They probably point to either an LVITEM or some MFC wrapper class. This information was obtained by reading the docs for the CListCtrl class; you get there by clicking up from DC's link. earl

                      1 Reply Last reply
                      0
                      • A aafcls

                        I am very sorry I do not understand. I do not make use of SetItemData(). All I have is my list control where I have a few InsertColumn()s and SetItemText() accordingly. When you tell me to cast these as pointers int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) ...pointing to what exactly?

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #20

                        aafcls wrote:

                        I do not make use of SetItemData().

                        But you must, if SortItems() is to be used, as it internally calls GetItemData().

                        aafcls wrote:

                        All I have is my list control where I have a few InsertColumn()s and SetItemText() accordingly.

                        You'll also need to use InsertItem().

                        aafcls wrote:

                        ...pointing to what exactly?

                        Whatever pointer value you used with SetItemData().


                        "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                        "Judge not by the eye but by the heart." - Native American Proverb

                        A 1 Reply Last reply
                        0
                        • D David Crow

                          aafcls wrote:

                          I do not make use of SetItemData().

                          But you must, if SortItems() is to be used, as it internally calls GetItemData().

                          aafcls wrote:

                          All I have is my list control where I have a few InsertColumn()s and SetItemText() accordingly.

                          You'll also need to use InsertItem().

                          aafcls wrote:

                          ...pointing to what exactly?

                          Whatever pointer value you used with SetItemData().


                          "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                          "Judge not by the eye but by the heart." - Native American Proverb

                          A Offline
                          A Offline
                          aafcls
                          wrote on last edited by
                          #21

                          oh I actually did use InsertItem() when you say to cast lParam1 and lParam2 to where I must have pointed with SetItemData, do I set them to the same pointer value? what makes param1 and param2 unique?

                          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