'combo combobox gettext
'   从组合框列表中的项中检索一个字符串。
'   hWndControl: 控件的句柄 (例如  HWND_FORM1_COMBO1)                  
'   nIndex:      从零开始的索引。
'   Returns:     If an error occurs, %CB_ERR is returned, otherwise
'                the length of the string is returned.
Function FF_ComboBox_GetText(hWndControl as HWnd, nIndex as Long) as CWSTR
   Dim nBufferSize as Long
   Dim nBuffer() as UByte
   '检查窗口句柄是否有效
   If IsWindow(hWndControl) Then
      '得到的文本的长度
      nBufferSize = SendMessageW(hWndControl, CB_GETLBTEXTLEN, nIndex, 0)
      If (nBufferSize = 0) Or (nBufferSize = CB_ERR) Then return ""
      'Add an extra character for the Nul terminator
      redim nBuffer(nBufferSize * 2 + 2)
      ''发消息给控件
      If SendMessageW(hWndControl, CB_GETLBTEXT, nIndex, Cast(LPARAM, @nBuffer(0))) = CB_ERR Then return ""
      'Remove the Null
      Return *CPtr(WString ptr, @nBuffer(0))
   End If
   Return ""
End Function

