1 頁 (共 1 頁)

[轉貼]如何取得unicode text control 的內容(test) (WM_GETTEXT)

發表於 : 2008年 11月 28日, 14:01
tim
請參考,
http://www.delphipraxis.net/topic37467_ ... icode.html

代碼: 選擇全部

     
    function GetWindowText(wnd: HWND): WideString; 
    var  
      TextLength: Integer;  
      Text: PWideChar;  
    begin 
      Result := '';  
      if wnd = 0 then  
        Exit; 
      TextLength := SendMessageW(wnd, WM_GETTEXTLENGTH, 0, 0); 
      if TextLength <> 0 then  
      begin  
        GetMem(Text, TextLength * 2  + 1);  
        SendMessageW(wnd, WM_GETTEXT, TextLength + 1, Integer(Text));  
        Result := Text;  
        FreeMem(Text);  
      end;  
    end;