'listbox insert string
'   将一个字符串插入到一个列表框控件
'   hWndControl: 控件的句柄 (例如  HWND_FORM1_LISTBOX1)
'   nIndex:      The zero-based index position to insert the string
'                into. Use -1 to add at the end of the list (or use
'                the FF_ListBox_AddString function).
'   TheText:     要添加的实际文本。
'   Returns:     The index of the position at which the string was
'                inserted, or %LB_ERR if error occurred.
Function FF_ListBox_InsertString(ByVal hWndControl as HWnd, ByVal nIndex as Long, ByRef TheText as CWSTR) as Integer
   
   '检查窗口句柄是否有效
   If IsWindow(hWndControl) Then
      '设置文本并返回插入文本的位置。
      Function = SendMessageW(hWndControl, LB_INSERTSTRING, nIndex, Cast(LPARAM, TheText.vptr))
   Else
      Function = LB_ERR
   End If
   
End Function

