' textbox text
'   获取从一个 TextBox 控件的文本。在整个文本缓冲区返回文本框。
'   hWndControl: 控件的句柄 (例如  HWND_FORM1_TEXTBOX1)
'   Returns:      从 TextBox 缓冲区的文本。
Function FF_TextBox_GetText (ByVal hWndControl As HWND) As CWSTR 
    
    Dim nBufferSize As Long
    Dim nBuffer() as UByte 
    
    '检查窗口句柄是否有效
    If IsWindow(hWndControl) Then
       
       ' 得到的文本的长度
         nBufferSize = GetWindowTextLength(hWndControl)
         If nBufferSize = 0 Then return ""
       ' Add an extra character for the Nul terminator
        redim nBuffer (nBufferSize*2 + 2)
         
       ' Retrieve the text
         GetWindowTextW hWndControl, Cast(WString ptr,  @nBuffer(0)), nBufferSize  
         
         Return *CPtr(WString ptr,@nBuffer(0))
         
    End If
       Return ""

End Function

