Announcement

Collapse
No announcement yet.

Listview column header

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

  • Listview column header

    I know i can change the text of a listview column, but how can I (or can I) set the font for the header to be different than the rows?


    Later:
    I am trying to show the ^ and down block characters on sorted columns. The sort works fine, but I want to show it how windows explorer does.

    I haven't tried, but I guess what I want is IMAGE in the header: I found that in this thread
    http://www.powerbasic.com/support/pb...n+header+image
    Last edited by Barry Erick; 28 Nov 2008, 10:00 PM. Reason: Found possible answer
    Barry

  • #2
    Yes you need images and I know there there is at least one example here.

    Search on 'arrow' in subject gets lots of posts with promising titles. (Not 'image', not 'listview', not 'sort', just 'arrow')

    eg.. http://www.powerbasic.com/support/pb...ighlight=arrow

    Fonts is different.. for that you should be able to just send wm_setFont to the header of the listview.... Listview_GetHeader(hLV)

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

    Comment


    • #3
      I tried the example I show the link to and still can't get it to work. There is alot of stuff here, and I will try them all.
      Barry

      Comment


      • #4
        Using "arrow" to find info re "listview" controls and their "header" component for "sort images" is kind of like searching for hockey news using "little round black rubber thing" as the search term, huh?
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Probably. Just wish our goalie could find one of those "round rubber things" easier.

          I now have text changing.. just bitmap not showing and I am sure that is how I am loading it into memory, using DDT while I should use SDK.
          Barry

          Comment


          • #6
            I don't see any "HEADER" functions for the intrinsic LISTVIEW controls offered in 9x DDT other than getting or setting the header text.

            About all you can do is "try" the SDK functions using the handle obtained with
            Code:
             CONTROL HANDLE  CBHNDL, %ID_LISTVIEW  to hLV 
             hHdr = ListView_GetHeader (hLV)
            Then you will use the Header_SetItem function to set the image and or other goodies in the HDITEM structure. (You want the iImage member to be the index of an IMAGELIST )

            If the header control will not cooperate nicely with the DDT-created listview, you can create the header control yourself (CONTROL ADD $WC_HEADER....) located immediately above the listview control you create with style LVS_NOCOLUMNHEADER.

            In this case to ensure you keep the header and column widths the same you'll have to process WM_NOTIFY/HDN_BEGINTRACK, HDN_TRACK and/or HDN_ENDTRACK notifications and resize the listview column sizes to match the header.

            I did this once, it's not as bad as it sounds, and I did not have any LISTVIEW SET COLUMN command to use (although Listview_SetColumnWidth is not all that challenging).

            One thing to watch out for if you go "separate controls": PB indexes the columns to base one (1); the header control will be indexed to zero (0).

            That is unless the "#OPTION BASE DDT 0|1 " metastatement was included in this release and I missed it in the help file.


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

            Comment


            • #7
              This is the function, so far, that works except for the image. I do have a temp string in there that will come out once the bitmap works.

              Code:
              FUNCTION ShowListHeaderSortDirection(col AS LONG,Dir AS LONG) AS LONG
              'add title to the colum with a up or down arrow to show sort direction
              
              LOCAL hListView AS LONG
              LOCAL hHeader AS LONG
              LOCAL hdi AS HD_ITEM
              LOCAL szItem AS ASCIIZ * 32
              LOCAL hBmp AS LONG
              LOCAL nCol AS LONG
              
              CONTROL HANDLE MainDlg,%IDC_SYSLISTVIEW32_1 TO hListView
              hHeader = sendmessage (hListview, %LVM_GETHEADER,0,BYVAL 0)
              
              szItem = ColTitles(col)
              hdi.mask = %HDI_BITMAP OR %HDI_FORMAT OR %HDI_TEXT
              
              hdi.fmt = %HDF_STRING OR %HDF_IMAGE OR %HDF_BITMAP_ON_RIGHT
              IF dir = 1 THEN
                  hdi.iImage = UpBmpHndl
                  szItem = "UP"
                  ELSE
                  szItem ="DOWN" 'just to see if it works
                  hdi.iImage = Downbmphndl
              END IF
                 hdi.pszText = VARPTR(szItem)
              nCol = Col
              SendMessage( hHeader, %HDM_SETITEM,nCol-1, VARPTR( hdi))
              
              
              END FUNCTION
              Barry

              Comment


              • #8
                Barry,
                I'm not sure if this is what you are looking for but if it is I'll try to extract the Listview code from the app that created the attached:

                James
                Attached Files

                Comment


                • #9
                  Originally posted by jcfuller View Post
                  Barry,
                  I'm not sure if this is what you are looking for but if it is I'll try to extract the Listview code from the app that created the attached:

                  James
                  I don't think so. I have the listview poulated, I can sort it, but I want to add the direction indicators to the column headers. In my above example, it is from examples in the forum. I put "up" and "Down" texts in there to show I am changing the column headers, but still have to load the bmp files correctly for them to be added to the header title instead of the words "up" or 'Down"
                  Barry

                  Comment


                  • #10
                    If you are using a bitmap handle directly (without an image list) , use HDITEM.hBm instead of HDITEM.iImage

                    With HDITEM.iImage you use an INDEX into an IMAGELIST, not an image handle.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Michael,
                      I changed it to that, but still did not have it working. I took out the Device Open code for loading the bitmap, and tried this.
                      Code:
                      IF dir = 1 THEN
                              GRAPHIC BITMAP LOAD "UP",32,32 TO hbmp
                              GRAPHIC ATTACH hBmp,0
                              hdi.hBm = hBmp
                          ELSE
                              GRAPHIC BITMAP LOAD "DOWN",32,32 TO hBmp
                              GRAPHIC ATTACH hBmp,0
                              hdi.hBm = hBmp
                      END IF 
                      hdi.pszText = VARPTR(szItem)
                      nCol = Col
                      SendMessage( hHeader, %HDM_SETITEM,nCol-1, VARPTR( hdi))
                      GRAPHIC BITMAP END
                      I assume the PowerBASIC handle, hbmp, is not the same handle that HDM_SETITEM wants in hdi.hBmp, but how does one find that. The control Handle function needs a control and the bitmap is not there. I wonder... could i have hidden graphic windows and load stuff there just to get a handle?
                      hmm......
                      Barry

                      Comment


                      • #12
                        I assume the PowerBASIC handle, hbmp, is not the same handle that HDM_SETITEM wants in hdi.hBmp, but how does one find that.
                        Doc doesn't help except that the word 'handle' has a link thing and that text refers to Windows' objects.

                        Try the GDI function GetObject() or GetObjectType() against hBMP. If it's not a valid Windows 'hBMP' you'll get an error.

                        Wait a mnute... before you go that far.... you may have a far more plebian explanation ...

                        GRAPHIC BITMAP END may be invalidating hBmp; try not doing that.

                        Failing that, change to LoadImage() or LoadBitmap() instead of GRAPHIC BITMAP LOAD to obtain hBmp.
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          I've tried loadImage and LOadBitmap and BOTH return 0 as the handle.
                          "UP" and "DOWN" are in the resource like this:

                          Code:
                          UP    BITMAP  DISCARDABLE  "UP.BMP"
                          DOWN BITMAP DISCARDABLE "DOWN.BMP"
                          Barry

                          Comment


                          • #14
                            >I've tried loadImage and LoadBitmap and BOTH return 0 as the handle.

                            Show code.. but based on resource definition.......
                            Code:
                            hBMP  = LoadBitmap (GetModuleHandle (BYVAL %NULL), "UP")
                            .. should be working just fine.

                            (Assuming that resource is for the executable module of the application)

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

                            Comment


                            • #15
                              Thanks,
                              It turns out that PBForms kept erasing the UP and DOWN entires from the resource file even though I was outside the block. I had to make a seperate resource file and it works. Now just to make the UP and DOWN bitmaps smaller and with a transparent icon.

                              Again,
                              Thanks for the help and I'll cheer for Milwaukee over Chicago anyday!!
                              Barry

                              Comment


                              • #16
                                It turns out that PBForms kept erasing the UP and DOWN entires from the resource file even though I was outside the block.
                                I'm not a PBForms user so I don't know if that is the expected behavior or not. If it isn't I hope you made the time to file a 'bug report.'

                                If it is the expected behavior, sure sounds like there is a "new feature suggestion" just begging to be put on "the list."

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

                                Comment


                                • #17
                                  PBForms marks areas of code "not to play with" and I had the code outside that area in the .rc code. In the main dialogs, they mark from the start to just before the call to show the dialog and placing stuff there, is fine.

                                  This does not have the new listview or tab classes that are built into PB9, but relies on the api for those calls. I find I can itermix some of the common codes to let PBForms make the gui abd use OPB syntax to make use of the api features.
                                  Barry

                                  Comment

                                  Working...
                                  X