' listbox replace string
'用新文本替换指定的列表框文本。
'//
'//  用新文本替换指定的列表框文本。
'//
Function FF_ListBox_ReplaceString(ByVal hWndControl as HWnd, ByVal nIndex as Long, ByRef sNewText as CWSTR , ByVal nNewData as Long) as Integer
   
   If IsWindow(hWndControl) = 0 Then Exit Function
   
   'Delete the item at the specified location
   SendMessage hWndControl, LB_DELETESTRING, nIndex, 0
   nIndex = SendMessage(hWndControl, LB_INSERTSTRING, nIndex, Cast(LPARAM, sNewText.vptr))
   SendMessage hWndControl, LB_SETITEMDATA, nIndex, nNewData
   
   If (GetWindowLongPtr(hWndControl, GWL_STYLE) And LBS_MULTIPLESEL) Then
      SendMessage hWndControl, LB_SETSEL, nIndex, 0
   Else
      SendMessage hWndControl, LB_SETCURSEL, nIndex, 0
   End If
   
   Return 0
   
End Function
