'treeview selected selection image
'   设置树视图所选项的图像。
'   hWndControl:    控件的句柄 (例如  HWND_FORM1_TREEVIEW1)   
'   hItem:          要设置为图像的项的句柄。
'   iSelectedImage: 指数在 TreeView 的 imagelist 为所选图像。
'   Returns:        如果成功返回 %TRUE 否则为 %FALSE 
Function FF_TreeView_SetSelectedImage (ByVal hWndControl as HWnd, _
                                       ByVal hItem as HANDLE, _
                                       ByVal iSelectedImage as Long) as Long

    Dim ti as TV_ITEM

    '检查窗口句柄是否有效
    If IsWindow(hWndControl) Then  
      
        ti.hItem          = hItem                                        
        ti.mask           = TVIF_HANDLE Or TVIF_SELECTEDIMAGE 
        ti.iSelectedImage = iSelectedImage
      
        If TreeView_SetItem (hWndControl, VarPtr(ti) ) = 0 Then
           Function = True
        End If   
    
    End If

End Function

