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 in list control

Sorting in list control

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxalgorithmshelpquestion
13 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.
  • N Naveen

    CPallini wrote:

    Maybe posting relevant code will help.

    thanks. void MainDlg::OnColumnclickList1(NMHDR* pNMHDR, LRESULT* pResult) { ListView_SortItemsEx( m_list.m_hWnd, CompareFunc, (LPARAM)this ); *pResult = 0; } int MainDlg::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { return 1; }

    nave

    C Offline
    C Offline
    CPallini
    wrote on last edited by
    #4

    IMHO there are two strange things in your code (but I don't know how dangerous they are): - Why are you passing this pointer to the comparisono function (though it is perfectly legal) ? - Your comparison function it's wrong: it cannot order a set. I know it it a test function, but try to improve it. :)

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

    N 1 Reply Last reply
    0
    • C CPallini

      IMHO there are two strange things in your code (but I don't know how dangerous they are): - Why are you passing this pointer to the comparisono function (though it is perfectly legal) ? - Your comparison function it's wrong: it cannot order a set. I know it it a test function, but try to improve it. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #5

      CPallini wrote:

      Why are you passing this pointer to the comparisono function (though it is perfectly legal) ?

      I removed the this pointer. Still the exception is ocurring( Actaully this code will work fine in simple mfc application. I have even tried this in an ocx )

      CPallini wrote:

      Your comparison function it's wrong: it cannot order a set. I know it it a test function, but try to improve it.

      I know the current code will not do sorting. Just for making the code shorter i have removed the comparision codes.

      nave

      C 1 Reply Last reply
      0
      • N Naveen

        CPallini wrote:

        Why are you passing this pointer to the comparisono function (though it is perfectly legal) ?

        I removed the this pointer. Still the exception is ocurring( Actaully this code will work fine in simple mfc application. I have even tried this in an ocx )

        CPallini wrote:

        Your comparison function it's wrong: it cannot order a set. I know it it a test function, but try to improve it.

        I know the current code will not do sorting. Just for making the code shorter i have removed the comparision codes.

        nave

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #6

        Naveen R wrote:

        removed the this pointer. Still the exception is ocurring( Actaully this code will work fine in simple mfc application. I have even tried this in an ocx )

        I expected the above behaviour. I was curious about...

        Naveen R wrote:

        I know the current code will not do sorting. Just for making the code shorter i have removed the comparision codes.

        Maybe the bug it is in the not-posted code! :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        N 1 Reply Last reply
        0
        • C CPallini

          Naveen R wrote:

          removed the this pointer. Still the exception is ocurring( Actaully this code will work fine in simple mfc application. I have even tried this in an ocx )

          I expected the above behaviour. I was curious about...

          Naveen R wrote:

          I know the current code will not do sorting. Just for making the code shorter i have removed the comparision codes.

          Maybe the bug it is in the not-posted code! :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #7

          no no Even the code that I posted causes exception. Simply returning the 1 itself is causing the exception.

          nave

          C 1 Reply Last reply
          0
          • N Naveen

            no no Even the code that I posted causes exception. Simply returning the 1 itself is causing the exception.

            nave

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #8

            IMHO this may happen 'cause you function isn't good for ordering. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

            N 1 Reply Last reply
            0
            • N Naveen

              Hi, I created a shell extension that shows a dialog(MFC). The dialog have a list control and i tried to implement the sort functionality in it. The problem is when I call the ListView_SortItems or ListView_SortItemsEx of the list control, after the first call back returned from my application an exception is coming. Any solution for this? Thanks Naveen

              N Offline
              N Offline
              Nibu babu thomas
              wrote on last edited by
              #9

              Didn't get time to look into your code. Will do soon. :)


              Nibu thomas A Developer Programming tips[^]  My site[^]

              N 1 Reply Last reply
              0
              • C CPallini

                IMHO this may happen 'cause you function isn't good for ordering. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

                N Offline
                N Offline
                Naveen
                wrote on last edited by
                #10

                I got the pblm solved. I missed the "CALLBACK" in the function declaration. Thanks anyway

                nave

                C 1 Reply Last reply
                0
                • N Nibu babu thomas

                  Didn't get time to look into your code. Will do soon. :)


                  Nibu thomas A Developer Programming tips[^]  My site[^]

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #11

                  Hi Nibu, pblm solved. The pblm was I didnt put the "CALLBACK" in the function declaration. Thats all. Thanks anyway.

                  nave

                  N 1 Reply Last reply
                  0
                  • N Naveen

                    Hi Nibu, pblm solved. The pblm was I didnt put the "CALLBACK" in the function declaration. Thats all. Thanks anyway.

                    nave

                    N Offline
                    N Offline
                    Nibu babu thomas
                    wrote on last edited by
                    #12

                    Naveen R wrote:

                    The pblm was I didnt put the "CALLBACK" in the function declaration.

                    Hmm Nice fix.


                    Nibu thomas A Developer Programming tips[^]  My site[^]

                    1 Reply Last reply
                    0
                    • N Naveen

                      I got the pblm solved. I missed the "CALLBACK" in the function declaration. Thanks anyway

                      nave

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #13

                      Good Point! :-D

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

                      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