Announcement

Collapse
No announcement yet.

Re-clicking treeview node twice problem

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

  • Re-clicking treeview node twice problem

    If I click a node on a treeview (%ID_TREE2) the following is true and the code that follows executes. If I click the same node again this code is not true (probably because it doesn't detect a change) How do I get a node to satisfy a condition if I want to be able to click the same node twice in a row without moving the selection.

    Code:
            IF (@lpNmh.Code = %TVN_SELCHANGED) AND (@lpNmh.idFrom = %ID_TREE2) THEN
    I just want clicking a node to tell the callback to do something wheter I click the node once or several times in a row.

    Bob Mechler

  • #2
    just want clicking a node to tell the callback to do something wheter I click the node once or several times in a row
    Then you want to process the NM_CLICK notification instead of the TVN_SELCHANGED notification.

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

    Comment


    • #3
      In the following code under WM_NOTIFY based on a SELECT statement using the idFrom to get the control id to process the following code works for one selection.
      Code:
              IF (@lpNmh.Code = %TVN_SELCHANGED) AND (@lpNmh.idFrom = %ID_TREE2) THEN
      '        IF (@lpNmh.Code = %NM_CLICK) AND (@lpNmh.idFrom = %ID_TREE2) THEN
                lpTV = CBLPARAM
                itree = @lpTV.ItemNew.hItem          
                pItem.hitem = itree
                pItem.mask = %TVIF_TEXT
                pItem.pszText = VARPTR(TmpAsciiz)
                pItem.cchTextMax = SIZEOF(TmpAsciiz)
                TreeView_GetItem GetDlgItem(hdlg,%ID_TREE2), pItem
                idx = SCRTOP(SCR): hdx = SCRBOT(SCR)
                TmpString$ = trim$(TmpAsciiz)
                CONTROL SET TEXT hdlg,ID_MENU_CHOICE,""
                WHILE idx <= hdx
                  TmpString$ = TRIM$(TmpAsciiz)        
                  IF LEFT$(TmpString$,1) = "*" THEN
                    TmpString$ = MID$(TmpString$,2) 'allow pre-release programs to run
                  END IF
                  IF INSTR(TRIM$(TmpString$),"*") > 0 THEN
                    COPT$ = TRIM$(TmpString$)
                  END IF
                  VSMENUITEM$ = VS$(idx)
                  IF INSTR(MENU_KIND$," NUMBERLESS") > 0 AND LEN(TRIM$(TmpString$)) > 0 THEN
                    IL = INSTR(VSMENUITEM$,".")
                    IF IL > 0 AND VAL(VSMENUITEM$) > 0 THEN
                      VSMENUITEM$ = TRIM$(MID$(VSMENUITEM$,IL + 1))
                    END IF
                  END IF 
                  TmpString$ = Remove$(TmpString$,ANY "*")
                  IF TRIM$(VSMENUITEM$) = TRIM$(TmpString$) THEN
                      COPT$ = VS$(idx)
                      COPT$ = TRIM$(COPT$)
                      IF ID_MENU_ITEMS$ = "" THEN
                        ID_MENU_ITEMS$ = "0123456789"
                      END IF
                      CONTROL GET USER hdlg,CBCTL,1 TO COPT_MENU&
                      IF COPT_MENU& = -1 THEN
                        COPT$ = TRIM$(STR$(0))
                      ELSEIF COPT_MENU& > 0 THEN
                        COPT$ = TRIM$(STR$(COPT_MENU&))
                      END IF
                      IF INSTR(COPT$,"Press ENTER") > 0 THEN
                        KeyBd_Event %VK_RETURN, MapVirtualKey(%VK_RETURN, 0), 0, 0: SLEEP 0
                        KeyBd_Event %VK_RETURN, MapVirtualKey(%VK_RETURN, 0), %KEYEVENTF_KEYUP, 0: SLEEP 0
                      ELSEIF INSTR(ID_MENU_ITEMS$,LEFT$(COPT$,1))> 0 THEN
                        IF INSTR("0123456789",LEFT$(COPT$,1)) > 0 THEN
                          IF VAL(COPT$) < 100 THEN
                            COPT$ = FNJR$(VAL(COPT$),2,48)
                          ELSEIF VAL(COPT$) > 99 THEN
                            COPT$ = FNJR$(VAL(COPT$),3,48)
                          END IF
                        ELSE
                          COPT$ = LEFT$(COPT$,1)
                        END IF
                       ' MSGBOX(COPT$ + TRIM$(VSMENUITEM$) + $CRLF + TRIM$(TmpString$) + $CRLF + STR$(IDX) + $CRLF + STR$(hdx))
                        IF idx <= hdx THEN
                          CONTROL SET TEXT hdlg,ID_MENU_CHOICE,COPT$
                        END IF  
                        IF @lpTV.action = %TVC_BYMOUSE THEN
                          KeyBd_Event %VK_RETURN, MapVirtualKey(%VK_RETURN, 0), 0, 0: SLEEP 0
                          KeyBd_Event %VK_RETURN, MapVirtualKey(%VK_RETURN, 0), %KEYEVENTF_KEYUP, 0: SLEEP 0
                        END IF
                      END IF
                    EXIT LOOP
                  END IF
                  INCR idx
                WEND
                TVN_TOOGLE = 0 
              END IF
      If I use the line with %NM_CLICK (currently remarked out) instead of the line above it then it does not work.

      Thanks for any help.

      Bob Mechler

      Comment


      • #4
        Something is amiss. The control always sends a NM_CLICK notification when it is clicked
        even when the selected item is clicked more than once. If it did not, a programmer would
        have to subclass the control to perform hit-testing.
        In the following SDK code snippet, the MessageBeep statement is always executed no matter how
        many times the same node is clicked.
        Code:
        FUNCTION Form1_WndProc _
          ( _
          BYVAL hWnd    AS DWORD, _ ' window handle
          BYVAL uMsg    AS DWORD, _ ' type of message
          BYVAL wParam  AS DWORD, _ ' first message parameter
          BYVAL lParam  AS LONG _   ' second message parameter
          ) EXPORT AS LONG
        
          LOCAL ptnmhdr     AS NMHDR PTR            ' information about a notification message
        
          SELECT CASE uMsg
            CASE %WM_COMMAND
        
            CASE %WM_NOTIFY
              ptnmhdr = lParam
        
              SELECT CASE @ptnmhdr.idFrom
                CASE %IDC_FORM1_TAB1
        
                CASE %IDC_FORM1_TREEVIEW1
        
                  SELECT CASE @ptnmhdr.code
                    CASE %TVN_BEGINLABELEDIT
        
                    CASE %TVN_SELCHANGED
        
                    CASE %NM_CLICK
                      MessageBeep %MB_ICONEXCLAMATION   
                      
                    CASE %TVN_ENDLABELEDIT
                  END SELECT
        
              END SELECT
        
            CASE %WM_SYSCOLORCHANGE
          END SELECT
        
          FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)
        
        END FUNCTION
        Dominic Mitchell
        Phoenix Visual Designer
        http://www.phnxthunder.com

        Comment


        • #5
          When you get NM_CLICK, you have to determine on which node - IF ANY - the click occurred.
          Code:
            IF (@lpNmh.Code = %NM_CLICK) AND (@lpNmh.idFrom = %ID_TREE2) THEN
                GetCursorPos  pt   ' get where mouse is - screen cooridinates
                ScreenToClient     ' get where this is in treeview control client coordinates
                                ' so you can........
               TreeView_HitTest   ' On which hItem in what area - if any ? 
                process click on hit node
          
          ......
          If you want to 'do something' on a click, process WM_NOTIFY/NM_CLICK and just forget about WM_NOTIFY/TVN_SELCHANGED

          Process WM_NOTIFY/TVN_SELCHANGED if you want to do something on a change of selection.

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

          Comment


          • #6
            I suspect you may want to do something this....?
            Code:
            CASE %WM_NOTIFY
               IF (@lpNmh.Code = %TVN_SELCHANGED AND (@lpNmh.idFrom = %ID_TREE2) THEN
                     do stuff on change of selection, regardless of mode _ 
                      (keystroke or click you don't care which)
                 .......
            
               ELSEIF (@lpNmh.Code = %NM_CLICK AND (@lpNmh.idFrom = %ID_TREE2) THEN
                  GetCursorPos  pt   ' get where mouse is - screen cooridinates
                  ScreenToClient     ' get where this is in treeview control client coordinates
                       TreeView_HitTest   ' On which hItem in what area - if any ? 
                   DO STUFF *ONLY if  
                      TreeView_getSelection  () 
                         tells you the click has occurred on the already-selected hItem
            
            ...
            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Click same TV node issue

              The following example program seems to be getting close to what I want. I can get a response based on clicking the text portion of the treeview node but can't get the text with the hittest information passed back and/or don't know how.

              If I click the same node twice I get a different value in the %NM_CLICK event area.

              I took Michael's suggestion and explored useding hittest functionality but I'm stuck as to what to do next.

              Bob Mechler
              Code:
              #PBFORMS CREATED V1.51
              #COMPILE EXE
              #DIM ALL
              '------------------------------------------------------------------------------
              '   ** Includes **
              '------------------------------------------------------------------------------
              #PBFORMS BEGIN INCLUDES
              '%USEMACROS = 1
              #IF NOT %DEF(%WINAPI)
                #INCLUDE "WIN32API.INC"
              #ENDIF
              #IF NOT %DEF(%COMMCTRL_INC)
                #INCLUDE "COMMCTRL.INC"
              #ENDIF
              #INCLUDE "PBForms.INC"
              #PBFORMS END INCLUDES
              '------------------------------------------------------------------------------
              
              '------------------------------------------------------------------------------
              '   ** Constants **
              '------------------------------------------------------------------------------
              #PBFORMS BEGIN CONSTANTS
              %IDD_DIALOG1         =  101
              %TRV_SYSTREEVIEW32_1 = 1001
              %LBL_LABEL1          = 1002
              #PBFORMS END CONSTANTS
              '------------------------------------------------------------------------------
              
              '------------------------------------------------------------------------------
              '   ** Declarations **
              '------------------------------------------------------------------------------
              DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
              DECLARE FUNCTION SampleTreeViewInsertItem(BYVAL hTree AS DWORD, BYVAL hParent _
                AS DWORD, sItem AS STRING) AS LONG
              DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
              #PBFORMS DECLARATIONS
              '------------------------------------------------------------------------------
              
              '------------------------------------------------------------------------------
              '   ** Main Application Entry Point **
              '------------------------------------------------------------------------------
              FUNCTION PBMAIN()
                PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
                  %ICC_INTERNET_CLASSES)
              
                ShowDIALOG1 %HWND_DESKTOP
              END FUNCTION
              '------------------------------------------------------------------------------
              
              '------------------------------------------------------------------------------
              '   ** CallBacks **
              '------------------------------------------------------------------------------
              CALLBACK FUNCTION ShowDIALOG1Proc()
                LOCAL ptnmhdr AS NMHDR PTR
                DIM lpTV AS NM_TREEVIEW PTR
                DIM pitem AS TV_ITEM
                DIM TmpAsciiz AS ASCIIZ * %MAX_PATH,tmpstring$
                STATIC itree AS LONG
                DIM dwpos as DWORD
                DIM intRet as integer
                  Local udtTV_HitTestInfo As TV_HITTESTINFO
                SELECT CASE AS LONG CBMSG
                  CASE %WM_INITDIALOG
                    ' Initialization handler
              
                  CASE %WM_NCACTIVATE
                    STATIC hWndSaveFocus AS DWORD
                    IF ISFALSE CBWPARAM THEN
                      ' Save control focus
                      hWndSaveFocus = GetFocus()
                    ELSEIF hWndSaveFocus THEN
                      ' Restore control focus
                      SetFocus(hWndSaveFocus)
                      hWndSaveFocus = 0
                    END IF
              
                  CASE %WM_NOTIFY
                    ptnmhdr = CBLPARAM
                    lpTV = CBLPARAM
              
                      IF @ptnmhdr.idfrom = %TRV_SYSTREEVIEW32_1 THEN
              
                          'IF @ptnmhdr.code = %NM_CLICK THEN
                          IF @lpTV.hdr.Code = %NM_CLICK THEN
                            itree = @lpTV.ItemNew.hItem          
                            pItem.hitem = itree
                            pItem.mask = %TVIF_TEXT
                            pItem.pszText = VARPTR(TmpAsciiz)
                            pItem.cchTextMax = SIZEOF(TmpAsciiz)
                            TreeView_GetItem @ptnmhdr.hwndfrom, pItem
                            TmpString$ = trim$(TmpAsciiz)
                            'SetWindowText CBHNDL, TRIM$(TmpString$) +  STR$(SIZEOF(TmpAsciiz)) + TIME$
                            dwPos = GetMessagePos()
                            intRet = LoWrd(dwpos)
                            udtTV_HitTestInfo.pt.x = intRet
                            intRet = HiWrd(dwpos)
                            udtTV_HitTestInfo.pt.y = intRet
                            Call MapWindowPoints(%HWND_DESKTOP, @ptnmhdr.hwndfrom, udtTV_HitTestInfo.pt, 1)
                            Call TreeView_HitTest(@ptnmhdr.hwndfrom, udtTV_HitTestInfo)
                            If udtTV_HitTestInfo.flags = %TVHT_ONITEMLABEL Then
                              SetWindowText CBHNDL,str$(udtTV_HitTestInfo.hItem) + "/" + STR$(@lpTV.ItemNew.hItem) + TIME$
                            End If
                                          
                          END IF
                          
                      END IF
              
              
                END SELECT
              END FUNCTION
              '------------------------------------------------------------------------------
              
              '------------------------------------------------------------------------------
              '   ** Sample Code **
              '------------------------------------------------------------------------------
              FUNCTION SampleTreeViewInsertItem(BYVAL hTree AS DWORD, BYVAL hParent AS _
                DWORD, sItem AS STRING) AS LONG
                LOCAL tTVItem   AS TV_ITEM
                LOCAL tTVInsert AS TV_INSERTSTRUCT
              
                IF hParent THEN
                  tTVItem.mask      = %TVIF_CHILDREN OR %TVIF_HANDLE
                  tTVItem.hItem     = hParent
                  tTVItem.cchildren = 1
                  TreeView_SetItem(hTree, tTVItem)
                END IF
              
                tTVInsert.hParent              = hParent
                tTVInsert.Item.Item.mask       = %TVIF_TEXT
                tTVInsert.Item.Item.pszText    = STRPTR(sItem)
                tTVInsert.Item.Item.cchTextMax = LEN(sItem)
              
                FUNCTION = TreeView_InsertItem(hTree, tTVInsert)
              END FUNCTION
              '------------------------------------------------------------------------------
              
              '------------------------------------------------------------------------------
              FUNCTION SampleTreeView(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL lCount _
                AS LONG) AS LONG
                LOCAL i       AS LONG
                LOCAL j       AS LONG
                LOCAL k       AS LONG
                LOCAL hCtl    AS DWORD
                LOCAL hRoot   AS DWORD
                LOCAL hParent AS DWORD
              
                CONTROL HANDLE hDlg, lID TO hCtl
              
                FOR i = 1 TO lCount
                  hRoot = SampleTreeViewInsertItem(hCtl, %NULL, USING$("Root#", i))
                  FOR j = 1 TO lCount
                    hParent = SampleTreeViewInsertItem(hCtl, hRoot, USING$("Item#", j))
                    FOR k = 1 TO lCount
                      CALL SampleTreeViewInsertItem(hCtl, hParent, USING$("SubItem#_.#", j, _
                        k))
                    NEXT k
                  NEXT j
                NEXT i
              END FUNCTION
              '------------------------------------------------------------------------------
              
              '------------------------------------------------------------------------------
              '   ** Dialogs **
              '------------------------------------------------------------------------------
              FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                LOCAL lRslt AS LONG
              
              #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                LOCAL hDlg  AS DWORD
              
                DIALOG NEW hParent, "Dialog1", 91, 70, 490, 338, %WS_POPUP OR %WS_BORDER OR _
                  %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR _
                  %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
                  %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
                  %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                CONTROL ADD "SysTreeView32", hDlg, %TRV_SYSTREEVIEW32_1, "SysTreeView32_1", _
                  135, 102, 221, 80, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
                  %TVS_HASBUTTONS OR %TVS_HASLINES OR %TVS_LINESATROOT OR _
                  %TVS_SHOWSELALWAYS, %WS_EX_LEFT OR %WS_EX_CLIENTEDGE OR _
                  %WS_EX_RIGHTSCROLLBAR
                CONTROL ADD LABEL, hDlg, %LBL_LABEL1, "Label1", 115, 34, 80, 14
              #PBFORMS END DIALOG
              
                SampleTreeView hDlg, %TRV_SYSTREEVIEW32_1, 3
              
                DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
              
              #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
              #PBFORMS END CLEANUP
              
                FUNCTION = lRslt
              END FUNCTION
              '------------------------------------------------------------------------------

              Comment


              • #8
                > but can't get the text with the hittest information passed back and/or don't know how

                What do you want? The text from the node upon which the click occurred?

                I do not understand this:
                pItem.hitem = itree

                What the heck is "itree?"

                You are using Treeview_HitTest precisely because it can find the hitem upon which the click occured.

                eg, On click:

                ----------
                Code:
                 GetCursorPos  pt      ' get screen coordinates where click occured 
                 ScreenToclient   @lptv.nhmdr.hwndFrom, pt    ' convert to client coordinates/TV control
                 udtTV_HitTestInfo.pt = pt    ' put that POINT struct into hit test UDT 
                 udtTV_HitTestInfo.flags   = %TVHT_ONITEM   ' or whatever you want  
                 iRet = treeview_HitTest  (@lpTv.NmHhdr.hWndFrom, udtTV_HitTestInfo)  ' hit test the pt
                 IF iRet THEN   ' cursor made a hit 
                     hItem of interest =      udtTv_HiTestInfo.hItem    ' where click occurred 
                     Use treeview_getItem   with this hitem to get info about the node which was clicked
                 ELSE
                     Message "You clicked on the treeview, but you missed all the items!" 
                 .......
                Lots of steps, but you get there.

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

                Comment


                • #9
                  I want the text from the node.

                  Itree is just a static long. The code I used as starter code did it this way. It may not be needed at all. It seems to be redundant now that I look at it.



                  Bob Mechler
                  Last edited by BOB MECHLER; 5 Oct 2009, 03:14 PM.

                  Comment


                  • #10
                    Oops, my bad. It's even easier....
                    Code:
                     
                     hItem of interest =      udtTv_HiTestInfo.hItem    ' where click occurred
                    Actually "iret" returned by Treeview_hittest IS the "hitem of interest"

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

                    Comment


                    • #11
                      That's what I was getting at. I'll try from there.

                      Bob Mechler

                      Comment


                      • #12
                        This works for what I want. Thanks, Michael.

                        Code:
                        #PBFORMS CREATED V1.51
                        #COMPILE EXE
                        #DIM ALL
                        '%SFF_TV_CHECKSTATECHANGE = %WM_USER + 100
                        '------------------------------------------------------------------------------
                        '   ** Includes **
                        '------------------------------------------------------------------------------
                        #PBFORMS BEGIN INCLUDES
                        '%USEMACROS = 1
                        #IF NOT %DEF(%WINAPI)
                          #INCLUDE "WIN32API.INC"
                        #ENDIF
                        #IF NOT %DEF(%COMMCTRL_INC)
                          #INCLUDE "COMMCTRL.INC"
                        #ENDIF
                        #INCLUDE "PBForms.INC"
                        #PBFORMS END INCLUDES
                        '------------------------------------------------------------------------------
                        
                        '------------------------------------------------------------------------------
                        '   ** Constants **
                        '------------------------------------------------------------------------------
                        #PBFORMS BEGIN CONSTANTS
                        %IDD_DIALOG1         =  101
                        %TRV_SYSTREEVIEW32_1 = 1001
                        %LBL_LABEL1          = 1002
                        #PBFORMS END CONSTANTS
                        '------------------------------------------------------------------------------
                        
                        '------------------------------------------------------------------------------
                        '   ** Declarations **
                        '------------------------------------------------------------------------------
                        DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                        DECLARE FUNCTION SampleTreeViewInsertItem(BYVAL hTree AS DWORD, BYVAL hParent _
                          AS DWORD, sItem AS STRING) AS LONG
                        DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                        #PBFORMS DECLARATIONS
                        '------------------------------------------------------------------------------
                        
                        '------------------------------------------------------------------------------
                        '   ** Main Application Entry Point **
                        '------------------------------------------------------------------------------
                        FUNCTION PBMAIN()
                          PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
                            %ICC_INTERNET_CLASSES)
                        
                          ShowDIALOG1 %HWND_DESKTOP
                        END FUNCTION
                        '------------------------------------------------------------------------------
                        
                        '------------------------------------------------------------------------------
                        '   ** CallBacks **
                        '------------------------------------------------------------------------------
                        CALLBACK FUNCTION ShowDIALOG1Proc()
                          LOCAL ptnmhdr AS NMHDR PTR
                          DIM lpTV AS NM_TREEVIEW PTR
                          DIM pitem AS TV_ITEM
                          DIM TmpAsciiz AS ASCIIZ * %MAX_PATH,tmpstring$
                          STATIC itree AS LONG
                          DIM dwpos as DWORD
                          DIM intRet as integer
                            Local udtTV_HitTestInfo As TV_HITTESTINFO
                          SELECT CASE AS LONG CBMSG
                            CASE %WM_INITDIALOG
                              ' Initialization handler
                        
                            CASE %WM_NCACTIVATE
                              STATIC hWndSaveFocus AS DWORD
                              IF ISFALSE CBWPARAM THEN
                                ' Save control focus
                                hWndSaveFocus = GetFocus()
                              ELSEIF hWndSaveFocus THEN
                                ' Restore control focus
                                SetFocus(hWndSaveFocus)
                                hWndSaveFocus = 0
                              END IF
                        
                            CASE %WM_NOTIFY
                              ptnmhdr = CBLPARAM
                              lpTV = CBLPARAM
                        
                                IF @ptnmhdr.idfrom = %TRV_SYSTREEVIEW32_1 THEN
                        
                                    IF @lpTV.hdr.Code = %NM_CLICK THEN
                                      dwPos = GetMessagePos()
                                      intRet = LoWrd(dwpos)
                                      udtTV_HitTestInfo.pt.x = intRet
                                      intRet = HiWrd(dwpos)
                                      udtTV_HitTestInfo.pt.y = intRet
                        
                                      Call MapWindowPoints(%HWND_DESKTOP, @ptnmhdr.hwndfrom, udtTV_HitTestInfo.pt, 1)
                                      Call TreeView_HitTest(@ptnmhdr.hwndfrom, udtTV_HitTestInfo)
                        
                                      If udtTV_HitTestInfo.flags = %TVHT_ONITEMLABEL Then
                                        pItem.hItem = udtTV_HitTestInfo.hitem
                                        pItem.mask = %TVIF_TEXT
                                        pItem.pszText = VARPTR(TmpAsciiz)
                                        pItem.cchTextMax = SIZEOF(TmpAsciiz)
                                        TreeView_GetItem @ptnmhdr.hwndfrom,pItem
                                        SetWindowText CBHNDL, TRIM$(TmpAsciiz) + "/" + TIME$
                                      End If
                                                    
                                    END IF
                                    
                                END IF  
                        END SELECT
                        END FUNCTION
                        '------------------------------------------------------------------------------
                        
                        '------------------------------------------------------------------------------
                        '   ** Sample Code **
                        '------------------------------------------------------------------------------
                        FUNCTION SampleTreeViewInsertItem(BYVAL hTree AS DWORD, BYVAL hParent AS _
                          DWORD, sItem AS STRING) AS LONG
                          LOCAL tTVItem   AS TV_ITEM
                          LOCAL tTVInsert AS TV_INSERTSTRUCT
                        
                          IF hParent THEN
                            tTVItem.mask      = %TVIF_CHILDREN OR %TVIF_HANDLE
                            tTVItem.hItem     = hParent
                            tTVItem.cchildren = 1
                            TreeView_SetItem(hTree, tTVItem)
                          END IF
                        
                          tTVInsert.hParent              = hParent
                          tTVInsert.Item.Item.mask       = %TVIF_TEXT
                          tTVInsert.Item.Item.pszText    = STRPTR(sItem)
                          tTVInsert.Item.Item.cchTextMax = LEN(sItem)
                        
                          FUNCTION = TreeView_InsertItem(hTree, tTVInsert)
                        END FUNCTION
                        '------------------------------------------------------------------------------
                        
                        '------------------------------------------------------------------------------
                        FUNCTION SampleTreeView(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL lCount _
                          AS LONG) AS LONG
                          LOCAL i       AS LONG
                          LOCAL j       AS LONG
                          LOCAL k       AS LONG
                          LOCAL hCtl    AS DWORD
                          LOCAL hRoot   AS DWORD
                          LOCAL hParent AS DWORD
                        
                          CONTROL HANDLE hDlg, lID TO hCtl
                        
                          FOR i = 1 TO lCount
                            hRoot = SampleTreeViewInsertItem(hCtl, %NULL, USING$("Root#", i))
                            FOR j = 1 TO lCount
                              hParent = SampleTreeViewInsertItem(hCtl, hRoot, USING$("Item#", j))
                              FOR k = 1 TO lCount
                                CALL SampleTreeViewInsertItem(hCtl, hParent, USING$("SubItem#_.#", j, _
                                  k))
                              NEXT k
                            NEXT j
                          NEXT i
                        END FUNCTION
                        '------------------------------------------------------------------------------
                        
                        '------------------------------------------------------------------------------
                        '   ** Dialogs **
                        '------------------------------------------------------------------------------
                        FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                          LOCAL lRslt AS LONG
                        
                        #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                          LOCAL hDlg  AS DWORD
                        
                          DIALOG NEW hParent, "Dialog1", 91, 70, 490, 338, %WS_POPUP OR %WS_BORDER OR _
                            %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR _
                            %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
                            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
                            %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                          CONTROL ADD "SysTreeView32", hDlg, %TRV_SYSTREEVIEW32_1, "SysTreeView32_1", _
                            135, 102, 221, 80, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
                            %TVS_HASBUTTONS OR %TVS_HASLINES OR %TVS_LINESATROOT OR _
                            %TVS_SHOWSELALWAYS, %WS_EX_LEFT OR %WS_EX_CLIENTEDGE OR _
                            %WS_EX_RIGHTSCROLLBAR
                          CONTROL ADD LABEL, hDlg, %LBL_LABEL1, "Label1", 115, 34, 80, 14
                        #PBFORMS END DIALOG
                        
                          SampleTreeView hDlg, %TRV_SYSTREEVIEW32_1, 3
                        
                          DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                        
                        #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                        #PBFORMS END CLEANUP
                        
                          FUNCTION = lRslt
                        END FUNCTION
                        '------------------------------------------------------------------------------

                        Comment


                        • #13
                          Wow, that oughtta learn me to try to do this stuff from memory.. sorry if I got you off track in a couple of places there....

                          I guess I had better R-T-F-M....
                          lpht
                          Pointer to a TVHITTESTINFO structure. When the message is sent, the pt member specifies the coordinates of the point to test. When the message returns, the hItem member is the handle to the item at the specified point or NULL if no item occupies the point. Also, when the message returns, the flags member is a hit test value that indicates the location of the specified point. For a list of hit test values, see the description of the TVHITTESTINFO structure.
                          MCM
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment

                          Working...
                          X