On 10/27/06, Felipe Monteiro de Carvalho
<[EMAIL PROTECTED]> wrote:
Consider this code:
function TGDIWindow.GetTitle: String;
var
l: Integer;
begin
l := Windows.GetWindowTextLength(Handle);
SetLength(Result, l);
Windows.GetWindowText(Handle, @Result[1], l);
end;
Proposal to unicode it:
function TGDIWindow.GetTitle: String;
var
l: Integer;
AnsiBuffer: array of Char;
WideBuffer: array of WideChar;
begin
if UnicodeEnabledOS then
begin
l := Windows.GetWindowTextLengthW(Handle);
SetLength(WideBuffer, l);
Windows.GetWindowTextW(Handle, @WideBuffer, l);
Result := Utf8Encode(WideString(WideBuffer));
SetLength(WideBuffer, 0);
end
else
begin
l := Windows.GetWindowTextLength(Handle);
SetLength(AnsiBuffer, l);
Windows.GetWindowText(Handle, @AnsiBuffer, l);
Result := Utf8Encode(WideString(AnsiBuffer));
SetLength(AnsiBuffer, 0);
end;
end;
--
Felipe Monteiro de Carvalho
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives