Announcement

Collapse
No announcement yet.

ListView with sort diamonds and right aligned

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ListView with sort diamonds and right aligned

    The following code from the LVARROWS example on the source forum works fine except for how it handles right aligned listview columns.

    The following code section from that source code example causes the right aligned column to become left aligned including the data. Would anyone have a way to code this to put the icon on the left of the text instead of the right?

    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    '* Set the header icons based on the active column (index) and the sort order
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    SUB SetHeaderIcons(BYVAL iActiveColumn AS INTEGER, BYVAL iSortOrder AS INTEGER)
       LOCAL i AS INTEGER
       LOCAL hdi AS HD_ITEM
       LOCAL iAlignRight AS INTEGER
       LOCAL iAlignLeft AS INTEGER
    
       FOR i = 0 TO Header_GetItemCount(ghLvHdr) - 1
          'Go through each column header
          hdi.mask = %HDI_FORMAT OR %HDI_IMAGE
          Header_GetItem ghLvHdr, i + 1, hdi
          iAlignRight = (hdi.fmt = %HDF_RIGHT)                     
          hdi.fmt = %HDF_STRING OR (iAlignRight AND %HDF_RIGHT)      
          IF i = iActiveColumn THEN
             hdi.fmt = hdi.fmt OR %HDF_IMAGE OR ((iAlignRight = %FALSE) AND %HDF_BITMAP_ON_RIGHT)
          END IF
          hdi.iImage = iSortOrder
          CALL Header_SetItem(ghLvHdr, i, hdi)
       NEXT
    END SUB
    Bob Mechler

  • #2
    Putting the sorting icon on the left is not the problem, it's the change in justification of the header text from right to left after the above function runs.

    Bob Mechler

    Comment


    • #3
      The following code always returns 0 even if one of the columns is %HDF_RIGHT.
      Code:
      iAlignRight = (hdi.fmt = %HDF_RIGHT)
      Bob Mechler

      Comment


      • #4
        Don't know this will solve that problem but...
        Code:
        [COLOR="Red"]FOR i = 0 TO Header_GetItemCount(ghLvHdr) - 1[/COLOR]
              'Go through each column header
              hdi.mask = %HDI_FORMAT OR %HDI_IMAGE
              Header_GetItem ghLvHdr, [COLOR="Red"]i + 1,[/COLOR] hdi
        ...
        The Header_GetItem() call should be using index "i" not "i+1"
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Making i instead of i + 1 didn't seem to make a difference.

          I'll look back at the LVDEMO.ZIP and Steve's suggestion in the other thread.

          Bob Mechler

          Comment


          • #6
            Code:
            hdi.fmt = hdi.fmt OR %HDF_IMAGE OR ((iAlignRight = %FALSE) AND %HDF_BITMAP
            I'd use more parens here

            If this is being interpreted by the compiler as .....
            Code:
            hdi.fmt = (hdi.fmt OR %HDF_IMAGE OR ((iAlignRight = %FALSE))  AND %HDF_BITMAP
            ... that format member will always be zero; and the total word will only be TRUE when the status word includes HDF_BITMAP.

            If the compiler IS interpreting that that way and that's what you wanted to happen, I think you should be more careful what you ask for because you may get it.

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              See my post to the tail end of this http://www.powerbasic.com/support/pb...ad.php?t=23690

              iAlignRight was never setting to true if the column was right aligned on creation. The extra ()'s didn't matter. For now, I collect in a global array the alignments (Left,Right) etc. I will be looking for another way to avoid the use of the global array here.

              While great code, I don't think it was tested with righ-aligned columns even though the code looks at first glance to be addressing it.

              Bob Mechler

              Comment

              Working...
              X