mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 14:56:00 +02:00
Fixed getting unicode strings from TMemo on win32
git-svn-id: trunk@13008 -
This commit is contained in:
parent
d8ef375589
commit
a2bedef1b0
@ -34,7 +34,7 @@ type
|
|||||||
|
|
||||||
function TWin32MemoStrings.GetLineLength(Index: Integer): Integer;
|
function TWin32MemoStrings.GetLineLength(Index: Integer): Integer;
|
||||||
begin
|
begin
|
||||||
Result := SendMessage(fHandle, EM_LINELENGTH, SendMessage(fHandle, EM_LINEINDEX, Index, 0),0);
|
Result := SendMessage(fHandle, EM_LINELENGTH, SendMessage(fHandle, EM_LINEINDEX, Index, 0), 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWin32MemoStrings.GetLineStart(Index: Integer): Integer;
|
function TWin32MemoStrings.GetLineStart(Index: Integer): Integer;
|
||||||
@ -70,8 +70,27 @@ end;
|
|||||||
function TWin32MemoStrings.Get(Index: Integer): string;
|
function TWin32MemoStrings.Get(Index: Integer): string;
|
||||||
var
|
var
|
||||||
len: Integer;
|
len: Integer;
|
||||||
|
WideBuffer: WideString;
|
||||||
|
AnsiBuffer: string;
|
||||||
begin
|
begin
|
||||||
len := GetLineLength(Index);
|
len := GetLineLength(Index);
|
||||||
|
|
||||||
|
{$ifdef WindowsUnicodeSupport}
|
||||||
|
if UnicodeEnabledOS then
|
||||||
|
begin
|
||||||
|
Setlength(WideBuffer, len);
|
||||||
|
len := SendMessageW(fHandle, EM_GETLINE, Index, lparam(PWideChar(WideBuffer)));
|
||||||
|
|
||||||
|
Result := Utf8Encode(WideBuffer);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Setlength(AnsiBuffer, len);
|
||||||
|
len := SendMessage(fHandle, EM_GETLINE, Index, lparam(PChar(AnsiBuffer)));
|
||||||
|
|
||||||
|
Result := AnsiToUtf8(AnsiBuffer);
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
Setlength(Result, len);
|
Setlength(Result, len);
|
||||||
if len = 0 then Exit;
|
if len = 0 then Exit;
|
||||||
|
|
||||||
@ -79,8 +98,10 @@ begin
|
|||||||
// the result is without null terminator.
|
// the result is without null terminator.
|
||||||
PWord(@Result[1])^ := len+1;
|
PWord(@Result[1])^ := len+1;
|
||||||
len := SendMessage(fHandle, EM_GETLINE, Index, lparam(pchar(Result)));
|
len := SendMessage(fHandle, EM_GETLINE, Index, lparam(pchar(Result)));
|
||||||
// readjust length in case something went wrong
|
|
||||||
|
// read just length in case something went wrong
|
||||||
Setlength(Result, len);
|
Setlength(Result, len);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWin32MemoStrings.SetUpdateState(Updating: Boolean);
|
procedure TWin32MemoStrings.SetUpdateState(Updating: Boolean);
|
||||||
|
Loading…
Reference in New Issue
Block a user