'textbox get line
'   获取TextBox 控件某行的文本 。
'   hWndControl: 控件的句柄 (例如  HWND_FORM1_TEXTBOX1)
'   nLineNumber: 要检索的行的从零开始的索引。
'   Returns:     从 TextBox 缓冲区的文本。
Function FF_TextBox_GetLine (ByVal hWndControl as HWnd,  ByVal nLineNumber as Long) as CWSTR 
    
    Dim nBufferSize as Long
    Dim nBuffer() as UByte 
    
    '检查窗口句柄是否有效
    If IsWindow(hWndControl) Then
       
       ' 得到的文本的长度
         nBufferSize = SendMessage(hWndControl, EM_LINELENGTH, nLineNumber, 0)
         If nBufferSize = 0 Then  return ""
       ' Add an extra character for the Nul terminator
         redim nBuffer (nBufferSize*2 + 2)
         
       ' Retrieve the text
         SendMessage hWndControl, EM_GETLINE, nLineNumber, Cast(LPARAM, @nBuffer(0))

         Function = *CPtr(WString ptr,@nBuffer(0))
         
    End If
    
End Function

