Announcement

Collapse
No announcement yet.

Image in ListView Header

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

  • Image in ListView Header

    Hi

    Looking for code to put images in the Listview's Column header...


    ------------------
    Henning
    Henning

  • #2
    Hi Henning;

    The key element is getting the header control handle from the listview.
    Once you have that, then fill in structure and then modify the column attributes.
    I have not actually tested it, but should be something like this...

    HTH
    Regards,
    Jules

    Code:
      LOCAL hHeader AS LONG
      LOCAL hdi     AS HD_ITEM
      LOCAL szItem  AS ASCIIZ*32
      LOCAL hBmp    AS LONG
      LOCAL nCol    AS LONG
     
      'get a handle to the listview header component
      hHeader = SendMessage( hListView, %LVM_GETHEADER, 0, BYVAL 0)
     
      'set up the required structure members
      szItem      = "Hello"
      hdi.mask    = %HDI_IMAGE OR %HDI_FORMAT
      hdi.pszText = VARPTR(szItem)
      hdi.fmt     = %HDF_STRING OR %HDF_IMAGE OR %HDF_BITMAP_ON_RIGHT
      hdi.iImage  = hBmp   '<--Load your Bitmap into memory first.
     
      'modify the header column number Zero...
      nCol = 0 :SendMessage hHeader, %HDM_SETITEM, nCol, hdi
    Best regards
    Jules
    www.rpmarchildon.com

    Comment


    • #3
      Right on Jules,

      Thanks for helping out !

      ------------------
      Henning
      Henning

      Comment


      • #4
        I have just written the follow routine but am getting:-

        PowerBASIC Compiler for Windows
        PB/Win Version 8.01
        Copyright (c) 1996-2005 PowerBasic Inc.
        Venice, Florida USA
        All Rights Reserved

        Error 420 in F:\Data\PBDLL61\Samples\Ian\Time Sheet.bas(3285:049): Relational operator expected
        Line 3285: SendMessage hHeader, %HDM_SETITEM, nCol, hdi
        ==============================
        Compile failed at 16:18:13 on 28/06/2006

        Can you please tell why?
        I really only need to change the text in the header

        Thanks
        Ian

        FUNCTION UpdateLeave(hDlg AS LONG) AS LONG
        LOCAL hHeader AS LONG
        LOCAL hListView AS LONG
        LOCAL hdi AS HD_ITEM
        LOCAL szItem AS ASCIIZ*32
        LOCAL hBmp AS LONG
        LOCAL nCol AS LONG

        CONTROL HANDLE hDlg, %IDC_SYSLISTVIEW32_1 TO hListView

        'get a handle to the listview header component
        hHeader = SendMessage( hListView, %LVM_GETHEADER, 0, BYVAL 0)

        'set up the required structure members
        szItem = "Hello"
        hdi.mask = %HDI_IMAGE OR %HDI_FORMAT
        hdi.pszText = VARPTR(szItem)
        hdi.fmt = %HDF_STRING OR %HDF_IMAGE OR %HDF_BITMAP_ON_RIGHT
        hdi.iImage = hBmp '<--Load your Bitmap into memory first.

        'modify the header column number Zero...
        nCol = 3
        SendMessage hHeader, %HDM_SETITEM, nCol, hdi
        END FUNCTION


        ------------------
        Ian Docksey, Trinitarian Bible Society
        Ian Docksey, Trinitarian Bible Society

        Comment


        • #5
          > Can you please tell why?

          Because hdi is an structure and the lParam parameter is a Long.
          Use VARPTR to pass the address of the structure.

          SendMessage hHeader, %HDM_SETITEM, nCol, VARPTR(hdi)
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            Code:
            SendMessage hHeader, %HDM_SETITEM, nCol, VARPTR(hdi)
            FWIW.... that's the same as ...
            Code:
            SendMessage hHeader, %HDM_SETITEM, nCol, BYREF hdi
            Very good to remember if you have a habit of typing "VAPRTR" when you mean "VARPTR" and are sick of compile-time errors for "undefined array variable"


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

            Comment

            Working...
            X