'treeview text
'   设置指定项目的文本。
'   hWndControl: 控件的句柄 (例如  HWND_FORM1_TREEVIEW1)   
'   hItem:       The handle of the item to set the text for.
'   TheText:     A string representing the text to display.
'   Returns:     %TRUE if successful, %FALSE if otherwise
Function FF_TreeView_SetText (ByVal hWndControl as HWnd, _
                              ByVal hItem as HANDLE, _
                              ByRef TheText as CWSTR ) as Long

    Dim ti as TV_ITEM

    '检查窗口句柄是否有效
    If IsWindow(hWndControl) Then  
      
        ti.hItem      = hItem                                        
        ti.mask       = TVIF_TEXT                   
        ti.cchTextMax = Len(TheText)
        ti.pszText    = TheText.vptr
      
        If TreeView_SetItem (hWndControl, VarPtr(ti) ) = 0 Then
           Function = True
        End If   
    
    End If
    
End Function

