Forum > General

How to use GetWindowText() correctly?

(1/1)

was:
Hello, I use GetWindowText() to get Application's title, but Non English characters cannot be displayed.


paweld:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);var  szText: WideString;begin  Edit1.Text := Caption;   if GetWindowTextW(GetForegroundWindow, PWideChar(szText), GetWindowTextLengthW(GetForegroundWindow)) > 0 then    Edit2.Text := szText;end;

PascalDragon:
@paweld: you should not mix PWideChar and WideString like this, cause GetWindowTextW won't allocate the buffer for you. So you should do (not tested):


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SetLength(szText, GetWindowTextLengthW(GetForegroundWindow));if GetWindowTextW(GetForegroundWindow, PWideChar(szText), Length(szText)) > 0 then

paweld:
@PascalDragon: thank you very much for the explanation

was:
@paweld, @PascalDragon: thank you very much.

Navigation

[0] Message Index

Go to full version