Announcement

Collapse
No announcement yet.

DDT ListView with gridlines

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

  • DDT ListView with gridlines

    I have just been working on the following exe as a sample listview with
    gridlines. It is set for multi select, however I cannot get the FULLROWSELECT to show. Also, I would like to have the ListView to respond
    to the Mouse duoble click in the callback function and would appreciate
    any help.

    '==============================================================================
    '
    ' Testing listview routines
    ' David Morris 23/01/2000
    '==============================================================================
    ' ** Eliminate unnecessary macros
    %NOANIMATE = 1
    %NODRAGLIST = 1
    %NOHEADER = 1
    %NOIMAGELIST = 1
    '%NOLISTVIEW = 1
    %NOTABCONTROL = 1
    %NOTRACKBAR = 1
    %NOTREEVIEW = 1
    %NOUPDOWN = 1

    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMMCTRL.INC"

    %IDOK = 1
    %IDCANCEL = 2
    %IDTEXT = 100
    %BS_DEFAULT = 1
    %IDLISTVIEW = 101

    '%LVS_EX_TRACKSELECT = &H8 'Should be in your "COMMCTRL.INC"
    '%LVS_EX_GRIDLINES = &H1 'Should be in your "COMMCTRL.INC"

    '------------------------------------------------------------------------------
    ' Global variable to recieve the user name

    GLOBAL UserName AS STRING
    GLOBAL hListView AS LONG
    '------------------------------------------------------------------------------
    SUB AppendListView (hList AS LONG, Rec() AS STRING )
    DIM z AS INTEGER
    DIM iStatus AS INTEGER
    DIM szStr AS ASCIIZ * 300
    DIM lvi AS LV_ITEM
    LOCAL x AS LONG

    'this will be the next record

    lvi.iItem = ListView_GetItemCount(hList) '+ 1
    lvi.mask = %LVIF_TEXT
    lvi.stateMask = %LVIS_FOCUSED '%LVIS_SELECTED
    lvi.pszText = VARPTR(szStr)

    FOR z = 0 TO UBOUND(Rec)
    szStr = Rec(z)
    lvi.iSubItem = z
    lvi.lParam = lvi.iItem
    IF z = 0 THEN
    lvi.mask = %LVIF_TEXT OR %LVIF_PARAM OR %LVIF_STATE
    iStatus = ListView_InsertItem (hList, lvi)
    ELSE
    lvi.mask = %LVIF_TEXT
    iStatus = ListView_SetItem (hList, lvi)
    END IF
    NEXT

    END SUB


    CALLBACK FUNCTION OkButton()

    CONTROL GET TEXT CBHNDL, %IDTEXT TO UserName
    DIALOG END CBHNDL, 1

    END FUNCTION

    CALLBACK FUNCTION CancelButton()

    DIALOG END CBHNDL, 0

    END FUNCTION

    CALLBACK FUNCTION ListViewProcess ()
    IF CBCTLMSG = %NM_DBLCLK THEN
    MSGBOX "Double Click",48,"LISTVIEW 'NOT working
    END IF

    END FUNCTION

    '------------------------------------------------------------------------------

    FUNCTION PBMAIN () AS LONG

    $REGISTER NONE

    LOCAL hDlg AS LONG
    LOCAL result AS LONG, zText AS ASCIIZ * 255
    LOCAL icc AS INIT_COMMON_CONTROLSEX
    LOCAL LVC AS LV_COLUMN, i AS LONG,r AS LONG, c AS LONG
    %NumCols = 5:%NumRows = 10
    DIM Rec(%NumCols)AS STRING
    LOCAL LVI AS LV_ITEM
    '%LVS_EX_TRACKSELECT = &H8
    ' InitCommonControls
    icc.dwICC = %ICC_DATE_CLASSES OR %ICC_BAR_CLASSES OR %ICC_LISTVIEW_CLASSES
    icc.dwSize = SIZEOF(icc)
    InitCommonControlsEx icc

    ' ** Create a new dialog template
    DIALOG NEW 0, "What is your name?", ,, 460, 250, 0, 0 TO hDlg

    ' ** Add controls to it
    CONTROL ADD TEXTBOX, hDlg, %IDTEXT, "", 14, 12, 134, 12, 0
    CONTROL ADD BUTTON, hDlg, %IDOK, "OK", 34, 32, 40, 14, %BS_DEFAULT CALL OkButton
    CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 84, 32, 40, 14, 0 CALL CancelButton
    '$WC_LISTVIEW
    CONTROL ADD "SysListView32", hDlg, %IDLISTVIEW,"",0,50,300,180, _
    %WS_border OR %WS_Child OR %WS_visible OR _
    %LVS_Report OR %LVS_SHOWSELALWAYS, _
    %WS_EX_CLIENTEDGE CALL ListViewProcess

    CONTROL HANDLE hDlg,%IDLISTVIEW TO hListView
    CONTROL SEND hDlg,%IDLISTVIEW,%LVM_SETEXTENDEDLISTVIEWSTYLE, _
    %LVS_EX_GRIDLINES, 1
    CONTROL SEND hDlg,%IDLISTVIEW,%LVM_SETEXTENDEDLISTVIEWSTYLE, _
    %LVS_EX_FULLROWSELECT, 1 'NOT WORKING YET

    lvC.mask = %LVCF_FMT OR %LVCF_WIDTH OR %LVCF_TEXT OR %LVCF_SUBITEM
    lvC.fmt = %LVCFMT_LEFT
    lvC.cx = 90
    LVC.cchTextMax = 255
    FOR c = 1 TO %NumCols
    zText = "Column " + FORMAT$(c - 1)
    LVC.pszText = VARPTR(zText)
    CONTROL SEND hDlg,%IDLISTVIEW,%LVM_INSERTCOLUMN, c, VARPTR(lvc)
    NEXT
    FOR r = 1 TO %NumRows
    FOR c = 1 TO %NumCols
    rec(c-1) = "Row " + FORMAT$(r) + " Col " + FORMAT$(c-1)
    NEXT c
    AppendListView hListView, Rec()
    NEXT r



    ' ** Display the dialog
    DIALOG SHOW MODAL hDlg TO result

    ' ** Check the result
    IF result THEN
    MSGBOX "Hello " & UserName
    END IF

    END FUNCTION

  • #2
    Have made further progress by looking at earlier postings by Peter Redei.
    Quote: "To the attainment of knowledge there is no end"
    I gather the ListView can be made into an editable grid - now that will
    be something to behold.

    Here is my latest code for tonight:-

    '==============================================================================
    '
    ' Testing listview routines
    ' David Morris 23/01/2000
    ' added some routines by Peter Redei
    '==============================================================================
    ' ** Eliminate unnecessary macros
    %NOANIMATE = 1
    %NODRAGLIST = 1
    %NOHEADER = 1
    %NOIMAGELIST = 1
    '%NOLISTVIEW = 1
    %NOTABCONTROL = 1
    %NOTRACKBAR = 1
    %NOTREEVIEW = 1
    %NOUPDOWN = 1

    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMMCTRL.INC"

    %IDOK = 1
    %IDCANCEL = 2
    %IDTEXT = 100
    %BS_DEFAULT = 1
    %IDLISTVIEW = 101

    '%LVS_EX_TRACKSELECT = &H8 'Should be in your "COMMCTRL.INC"
    '%LVS_EX_GRIDLINES = &H1 'Should be in your "COMMCTRL.INC"

    '------------------------------------------------------------------------------
    ' Global variable to recieve the user name

    GLOBAL UserName AS STRING
    GLOBAL hListView AS LONG
    GLOBAL lviewSort AS INTEGER

    TYPE dField
    fName AS ASCIIZ * 80
    SIZE AS INTEGER
    Alignment AS INTEGER
    END TYPE

    TYPE ListData
    Columns AS INTEGER
    Fields(0 TO 80) AS dField
    END TYPE

    FUNCTION HitColumn (hList AS LONG, xdim AS LONG) AS LONG
    LOCAL i AS LONG
    LOCAL x AS LONG
    LOCAL sumx AS LONG

    sumx = 0
    i = 0
    DO
    x = ListView_GetColumnWidth(hList, i)
    sumx = sumx + x
    IF xdim < sumx THEN
    FUNCTION = i
    EXIT DO
    END IF
    INCR i
    LOOP

    END FUNCTION

    SUB AppendListView (hList AS LONG, Rec() AS STRING )
    DIM z AS INTEGER
    DIM iStatus AS INTEGER
    DIM szStr AS ASCIIZ * 300
    DIM lvi AS LV_ITEM
    LOCAL x AS LONG

    'this will be the next record

    lvi.iItem = ListView_GetItemCount(hList) '+ 1
    lvi.mask = %LVIF_TEXT
    lvi.stateMask = %LVIS_FOCUSED '%LVIS_SELECTED
    lvi.pszText = VARPTR(szStr)

    FOR z = 0 TO UBOUND(Rec)
    szStr = Rec(z)
    lvi.iSubItem = z
    lvi.lParam = lvi.iItem
    IF z = 0 THEN
    lvi.mask = %LVIF_TEXT OR %LVIF_PARAM OR %LVIF_STATE
    iStatus = ListView_InsertItem (hList, lvi)
    ELSE
    lvi.mask = %LVIF_TEXT
    iStatus = ListView_SetItem (hList, lvi)
    END IF
    NEXT

    END SUB

    SUB ResetLParam(hList AS LONG)
    LOCAL i AS LONG
    LOCAL recs AS LONG
    LOCAL lvi AS LV_ITEM
    LOCAL x AS LONG

    lvi.mask = %LVIF_PARAM
    lvi.iSubItem = 0
    recs = ListView_GetItemCount(hList)
    FOR i = 0 TO recs - 1
    lvi.iItem = i
    x = ListView_GetItem (hList, lvi)
    lvi.lParam = lvi.iItem
    x = ListView_SetItem (hList, lvi)
    NEXT
    END SUB

    FUNCTION RetrieveLVData(hList AS LONG, Recno AS LONG, Fieldno AS LONG) AS STRING
    %cchTextMax = 300
    LOCAL lvi AS LV_ITEM
    LOCAL value AS ASCIIZ * 300
    LOCAL x AS LONG

    lvi.cchTextMax = %cchTextMax
    lvi.iItem = Recno
    lvi.pszText = VARPTR(value)
    lvi.iSubItem = Fieldno
    lvi.Mask = %LVIF_TEXT
    x = ListView_GetItem (hList, lvi)
    FUNCTION = value
    END FUNCTION

    FUNCTION compare(BYVAL lParam1 AS LONG, BYVAL lParam2 AS LONG, _
    BYVAL lParamsort AS LONG) AS INTEGER
    'The lParam1 parameter is the 32-bit value associated with
    'the first item being compared; and the lParam2 parameter is
    'the value associated with the second item. These are the
    'values that were specified in the lParam member of the
    'items’ LV_ITEM structure when they were inserted into the
    'list. The lParamSort parameter is the same value passed to
    'the LVM_SORTITEMS message.

    'The comparison function must return a negative value if
    'the first item should precede the second, a positive value
    'if the first item should follow the second, or zero if
    'the two items are equivalent.

    'lParam will carry a pointer to the value in the cell

    LOCAL value1 AS ASCIIZ * 300
    LOCAL value2 AS ASCIIZ * 300
    LOCAL j%

    FUNCTION = 0

    value1 = RetrieveLVData(hListView, lParam1, lParamsort)
    value2 = RetrieveLVData(hListView, lParam2, lParamsort)

    SELECT CASE lviewSort
    CASE 0 'ascending
    j = 1
    CASE ELSE 'descending
    j = -1
    END SELECT

    IF value1 < value2 THEN
    FUNCTION = -1 * j
    ELSEIF value1 = value2 THEN
    FUNCTION = 0
    ELSE
    FUNCTION = 1 * j
    END IF
    END FUNCTION

    CALLBACK FUNCTION OkButton()

    CONTROL GET TEXT CBHNDL, %IDTEXT TO UserName
    DIALOG END CBHNDL, 1

    END FUNCTION

    CALLBACK FUNCTION CancelButton()

    DIALOG END CBHNDL, 0

    END FUNCTION

    CALLBACK FUNCTION ListViewProcess ()
    IF CBCTLMSG = %WM_LBUTTONDBLCLK THEN
    MSGBOX "Double Click",48,"LISTVIEW 'NOT working
    END IF

    END FUNCTION

    CALLBACK FUNCTION tstListView()
    LOCAL ID&, hDlg AS LONG
    'LOCAL tbab AS TBADDBITMAP
    LOCAL lpToolTip AS TOOLTIPTEXT PTR
    LOCAL lData AS ListData
    LOCAL my_LpLvNm AS NM_LISTVIEW PTR
    LOCAL hi AS LV_HITTESTINFO
    LOCAL itemselect AS LONG
    LOCAL reclient AS rect
    LOCAL pt AS POINTAPI
    LOCAL i AS LONG, sText AS STRING

    STATIC zText AS ASCIIZ * 255
    'STATIC hBmp AS LONG
    hDlg = CBHNDL
    SELECT CASE CBMSG
    CASE %WM_INITDIALOG

    CASE %WM_NOTIFY
    SELECT CASE LOWRD(CBWPARAM)
    CASE %IDLISTVIEW
    my_LpLvNm = CBLPARAM
    IF @my_LpLvNm.hdr.code = %LVN_COLUMNCLICK THEN
    'cursor position
    GetCursorPos pt
    'switching to control coordinates
    ScreenToClient hListView, pt
    'switching to item
    hi.pt = pt
    hi.iItem = 2
    hi.Flags = %LVHT_ABOVE OR %LVHT_BELOW OR %LVHT_NOWHERE OR _
    %LVHT_ONITEMICON OR %LVHT_ONITEMLABEL OR %LVHT_ONITEMSTATEICON OR _
    %LVHT_TOLEFT OR %LVHT_TORIGHT

    'hittest does not work (no idea why not, please let me know if anybody knows)
    itemselect = ListView_HitTest(hListView, hi)
    'do it with replacement function
    itemselect = HitColumn(hListView, hi.pt.x)
    i = (itemselect = -1)
    IF i = 0 THEN
    'toggle ascending/descending
    lviewSort = NOT lviewSort
    ListView_SortItems hListView, _
    CODEPTR(compare), _
    itemselect
    'lparam was set to the original 'recordnumber'
    'now this changed, we need to set it to the new position
    ResetLParam hListView
    END IF
    ELSEIF @my_LpLvNm.hdr.code = %NM_DBLCLK THEN 'Now have Mouse Clicks!
    sText = RetrieveLVData(hListView, 0, 0) 'Next find where click was
    MSGBOX sText,48,"LISTVIEW"
    END IF
    END SELECT
    END SELECT
    END FUNCTION


    FUNCTION PBMAIN () AS LONG

    $REGISTER NONE

    LOCAL hDlg AS LONG
    LOCAL result AS LONG, zText AS ASCIIZ * 255
    LOCAL icc AS INIT_COMMON_CONTROLSEX
    LOCAL LVC AS LV_COLUMN, i AS LONG,r AS LONG, c AS LONG
    %NumCols = 5:%NumRows = 10
    DIM Rec(%NumCols)AS STRING
    LOCAL LVI AS LV_ITEM
    '%LVS_EX_TRACKSELECT = &H8
    ' InitCommonControls
    icc.dwICC = %ICC_DATE_CLASSES OR %ICC_BAR_CLASSES OR %ICC_LISTVIEW_CLASSES
    icc.dwSize = SIZEOF(icc)
    InitCommonControlsEx icc

    ' ** Create a new dialog template
    DIALOG NEW 0, "What is your name?", ,, 460, 250, 0, 0 TO hDlg

    ' ** Add controls to it
    CONTROL ADD TEXTBOX, hDlg, %IDTEXT, "", 14, 12, 134, 12, 0
    CONTROL ADD BUTTON, hDlg, %IDOK, "OK", 34, 32, 40, 14, %BS_DEFAULT CALL OkButton
    CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 84, 32, 40, 14, 0 CALL CancelButton
    '$WC_LISTVIEW
    CONTROL ADD "SysListView32", hDlg, %IDLISTVIEW,"",0,50,300,180, _
    %WS_border OR %WS_Child OR %WS_visible OR _
    %LVS_Report OR %LVS_SHOWSELALWAYS, _
    %WS_EX_CLIENTEDGE CALL ListViewProcess

    CONTROL HANDLE hDlg,%IDLISTVIEW TO hListView
    CONTROL SEND hDlg,%IDLISTVIEW,%LVM_SETEXTENDEDLISTVIEWSTYLE, _
    %LVS_EX_GRIDLINES, 1
    CONTROL SEND hDlg,%IDLISTVIEW,%LVM_SETEXTENDEDLISTVIEWSTYLE, _
    %LVS_EX_FULLROWSELECT, 1 'NOT WORKING YET

    lvC.mask = %LVCF_FMT OR %LVCF_WIDTH OR %LVCF_TEXT OR %LVCF_SUBITEM
    lvC.fmt = %LVCFMT_LEFT
    lvC.cx = 90
    LVC.cchTextMax = 255
    FOR c = 1 TO %NumCols
    zText = "Column " + FORMAT$(c - 1)
    LVC.pszText = VARPTR(zText)
    CONTROL SEND hDlg,%IDLISTVIEW,%LVM_INSERTCOLUMN, c, VARPTR(lvc)
    NEXT
    FOR r = 1 TO %NumRows
    FOR c = 1 TO %NumCols
    rec(c-1) = "Row " + FORMAT$(r) + " Col " + FORMAT$(c-1)
    NEXT c
    AppendListView hListView, Rec()
    NEXT r

    ' ** Display the dialog
    DIALOG SHOW MODAL hDlg CALL tstListView TO Result

    ' ** Check the result
    IF result THEN
    MSGBOX "Hello " & UserName
    END IF

    END FUNCTION

    Comment


    • #3
      The equate %LVM_SETEXTENDEDLISTVIEWSTYLE is undefined.

      Regards
      Peter
      [email protected]
      www.dreammodel.dk

      Comment


      • #4
        Peter, your INC files are likely to be out of date... be sure to download the latest editions from the web site at http://www.powerbasic.com/files/pub/pbwin/win32api.zip


        -------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          This now works the FullRow select in the ListView. Replace the code in the PBMAIN as appropriate with this:-

          CONTROL HANDLE hDlg,%IDLISTVIEW TO hListView

          lStyle = SendMessage(hListView, _
          %LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
          lStyle = lStyle OR %LVS_EX_FULLROWSELECT OR %LVS_EX_TRACKSELECT OR %LVS_EX_GRIDLINES
          CALL SendMessage(hListView, %LVM_SETEXTENDEDLISTVIEWSTYLE, _
          0, BYVAL lStyle)

          Comment


          • #6
            Excellent example David... try adding %WS_TABSTOP to the listbox style and check out the "auto-select" effect... quite interesting!

            Just to be complete (picky, picky!), add %WS_TABSTOP to the %BS_DEFAULT button style and give the buttons a keyboard accelerator (use the & symbol).

            -------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Thanks Lance. I appreciate your comments.

              Later on I'll explore using the inbuilt %LVM_EDITLABEL to turn the tool
              into an editable grid. There is a lot more in the ListView including
              %LVM_FINDITEM. All of these are listed in the Commctrl.inc file, although
              without much documentation.

              I have been slowly reviewing data by Nancy Winnick Cluts from MS Developer
              Network Technology Group - Win32 Common Controls, Part 4. It has a reference
              mk:ivt:techart/msdn_commctl4.htm

              After further checking, I also changed the code for the %WM_NOTIFY to use
              more of the information returned in the NM_LISTVIEW structure:-

              CASE %WM_NOTIFY
              SELECT CASE LOWRD(CBWPARAM)
              CASE %IDLISTVIEW
              my_LpLvNm = CBLPARAM
              IF @my_LpLvNm.hdr.code = %LVN_COLUMNCLICK THEN
              itemselect = @my_LpLvNm.iSubItem 'HitColumn(hListView, hi.pt.x)
              i = (itemselect = -1)
              CONTROL SET TEXT hDlg&, %IDTEXT1, FORMAT$(ItemSelect)
              IF i = 0 THEN
              'toggle ascending/descending
              lviewSort = NOT lviewSort
              ListView_SortItems hListView, _
              CODEPTR(compare), _
              itemselect
              'lparam was set to the original 'recordnumber'
              'now this changed, we need to set it to the new position
              ResetLParam hListView
              END IF
              ELSEIF @my_LpLvNm.hdr.code = %NM_DBLCLK THEN 'Now have Mouse Clicks!
              'cursor position
              sText = RetrieveLVData(hListView, @my_LpLvNm.iItem, 4) 'Next find where click was
              CONTROL SET TEXT hDlg&, %IDTEXT, sText

              END IF


              Comment


              • #8
                Just for interest, I have just easily loaded and sorted the ListView with
                10000 rows and 8 columns - (probably NOT recommended) :-

                %NumCols = 8:%NumRows = 10000

                FOR c = 1 TO %NumCols
                IF c = 1 THEN
                zText = "Row No"
                LVC.pszText = VARPTR(zText)
                CONTROL SEND hDlg,%IDLISTVIEW,%LVM_INSERTCOLUMN, c, VARPTR(lvc)
                ELSE
                zText = "Column " + FORMAT$(c - 1)
                LVC.pszText = VARPTR(zText)
                CONTROL SEND hDlg,%IDLISTVIEW,%LVM_INSERTCOLUMN, c, VARPTR(lvc)
                END IF
                NEXT

                FOR r = 0 TO %NumRows
                lvi.iItem = r
                lvi.iSubItem = 0
                lvi.pszText = %LPSTR_TEXTCALLBACK
                lvi.cchTextMax = 300
                lvi.iImage = r
                lvi.lParam = STRPTR(rec2(0,0))
                IF (ListView_InsertItem(hListView, lvi) = -1) THEN EXIT FOR
                FOR c = 0 TO %NumCols
                IF c = 0 THEN
                rec2(r,c) = FORMAT$(r,"0000")
                CALL ListView_SetItemText(hListView, r, c, BYCOPY (rec2(r,c)))
                ELSE
                rec2(r,c) = "xRow " + FORMAT$(r) + " xCol " + FORMAT$(c)
                CALL ListView_SetItemText(hListView, r, c, BYCOPY (rec2(r,c)))
                END IF
                NEXT c
                NEXT r

                Comment


                • #9
                  David,

                  3 quickies for you.

                  1. How is the project going?
                  2. Have you sorted out the in-place editting yet.
                  3. Could you email the final code example to me ( at [email protected])

                  For your info, a while back (probably close to a year, I received a lot of help from Lance regarding in-place editing of a tree view control.

                  The codesnippets to do that are below (though they are for PB/DLL 5.0, not DDT.

                  Code:
                  FUNCTION TreeEditProc(BYVAL hCtl AS LONG, _
                                        BYVAL Msg AS LONG, _
                                        BYVAL wParam AS LONG, _
                                        BYVAL lParam AS LONG) EXPORT AS LONG
                  
                      DIM sztext AS ASCIIZ * 256
                  
                      SELECT CASE Msg
                        CASE %WM_GETDLGCODE
                          FUNCTION = %DLGC_WANTALLKEYS
                          EXIT FUNCTION
                      END SELECT
                  
                      FUNCTION=CallWindowProc(BYVAL glpTreeEditProc, hCtl, Msg, wParam, lParam)
                  
                  END FUNCTION
                  
                  
                  And in the main window handler...
                  
                  CASE %TVN_LAST TO %TVN_FIRST
                     SELECT CASE @lpNmh.idFrom
                        CASE %trvMain
                           SELECT CASE @lpNmh.Code
                              CASE %TVN_BEGINLABELEDIT
                                 hTree& = GetDlgItem(hDlg, %trvMain)
                                 ghTreeEditCtrl = TreeView_GetEditControl(hTree&)
                                 IF ghTreeEditCtrl THEN
                                    glpTreeEditProc = SetWindowLong(ghTreeEditCtrl, _
                                            %GWL_WNDPROC, BYVAL CODEPTR(TreeEditProc))
                                    action = %TRUE
                                 END IF
                              CASE %TVN_ENDLABELEDIT
                                 tvd = lParam
                                 ' Remove Subclassing
                                 SetWindowLong ghTreeEditCtrl, %GWL_WNDPROC, glpTreeEditProc
                                 glpTreeEditProc = 0
                                 ' Update the control
                                 IF ISTRUE @tvd.item.pszText THEN
                                    hTrv& = GetDlgItem(hDlg, %trvMain)
                                    hti&=TreeView_GetSelection(hTrv&)
                                    tItem.mask = %TVIF_HANDLE
                                    tItem.hItem = hti&
                                    TreeView_GetItem hTrv&, tItem
                                    tItem.pszText = @tvd.item.pszText
                                    tItem.mask = %TVIF_TEXT
                                    TreeView_SetItem hTrv&, tItem
                                    Action = %TRUE
                                 ELSE
                                    Action = %FALSE
                                 END IF
                  I hope this is of help to you.

                  Regards

                  Andrew
                  --------------
                  andrew dot lindsay at westnet dot com dot au

                  Comment


                  • #10
                    Andrew, I have sent you the latest code. I haven't done any more for over
                    a week and haven't explored the edit procedure. I think the edit is for the
                    complete LV_ITEM. If I needed to edit the records, I would probably parse
                    the item record into edit fields on the double click of the ListView. On
                    completion of the edit, I would save the edit fields back to the ListView
                    and also to the database.

                    Comment

                    Working...
                    X