From 46ca8750043f08a0b58b4083fd485700856648c1 Mon Sep 17 00:00:00 2001 From: vincents Date: Tue, 11 Dec 2007 15:37:28 +0000 Subject: [PATCH] win32 interface: made ListBox.Item[0] := 'bla' unicode aware git-svn-id: trunk@13278 - --- lcl/interfaces/win32/win32listsl.inc | 38 +++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lcl/interfaces/win32/win32listsl.inc b/lcl/interfaces/win32/win32listsl.inc index c81d2f35e4..0765f53910 100644 --- a/lcl/interfaces/win32/win32listsl.inc +++ b/lcl/interfaces/win32/win32listsl.inc @@ -27,21 +27,6 @@ {$UNDEF H_PLUS} {$ENDIF} -{*************************************************************} -{ Default compare function } -{*************************************************************} - -Function DefaultCompareFunc(A, B: HWND): Integer; CDecl; -Var - AStr, BStr: PChar; -Begin - AStr:=nil; - BStr:=nil; - GetWindowText(A, AStr, GetWindowTextLength(A) + 1); - GetWindowText(B, BStr, GetWindowTextLength(B) + 1); - Result := StrComp(AStr, BStr); -end; - {*************************************************************} { TWin32ListStringList methods } {*************************************************************} @@ -165,17 +150,36 @@ end; ------------------------------------------------------------------------------} Function TWin32ListStringList.Get(Index: Integer): String; Var +{$ifdef WindowsUnicodeSupport} + s: string; + w: widestring; +{$else} Item: PChar; +{$endif} Begin If (Index < 0) Or (Index >= Count) Then Raise Exception.Create('Out of bounds.') Else Begin + {$ifdef WindowsUnicodeSupport} + if UnicodeEnabledOS then begin + SetLength(w, Windows.SendMessageW(FWin32List, FFlagGetTextLen, Index, 0)); + Windows.SendMessageW(FWin32List, FFlagGetText, Index, LPARAM(PWideChar(w))); + Result := UTF8Encode(w); + end + else + begin + SetLength(s, Windows.SendMessage(FWin32List, FFlagGetTextLen, Index, 0)); + Windows.SendMessage(FWin32List, FFlagGetText, Index, LPARAM(PChar(s))); + Result := AnsiToUtf8(s); + end; + {$else} Getmem(Item, Windows.SendMessage(FWin32List, FFlagGetTextLen, Index, 0)+1); Windows.SendMessage(FWin32List, FFlagGetText, Index, LPARAM(Item)); + Result := Item; + FreeMem(Item); + {$endif} End; - Result := StrPas(Item); - Dispose(Item); End; {------------------------------------------------------------------------------