Felipe Monteiro de Carvalho schreef:
Hello,

I would like to create some official guidelines about how to implement
unicode support for win32 interface, so volunteers can base on those
to implement it and we get a uniform work. And I think that a good
example to create a guideline is by an example.

Consider the line 292 of the win32wsbuttons.pp file:

 GetTextExtentPoint32(hdcNewBitmap, LPSTR(ButtonCaption),
Length(ButtonCaption), TextSize);

My initial idea is to transform this into:

var
 WideText: PWideChar;
 AnsiText: string;
 WideSize: Integer;

 ........

{$ifdef UnicodeWinInterface}
 if UnicodeEnabledOS then
 begin
   WideSize := Utf8ToUnicode(nil, ButtonCaption, 0);
   WideText := GetMem(WideSize * 2);
   Utf8ToUnicode(WideText, ButtonCaption, WideSize);
GetTextExtentPoint32W(hdcNewBitmap, WideText, Length(WideText), TextSize);
   FreeMem(WideText);
 end
 else
 begin
   AnsiText := Utf8ToAnsi(ButtonCaption);
   GetTextExtentPoint32(hdcNewBitmap, LPSTR(AnsiText),
Length(AnsiText), TextSize);
 end;
{$else}
 GetTextExtentPoint32(hdcNewBitmap, LPSTR(ButtonCaption),
Length(ButtonCaption), TextSize);
{$endif}

Please comment, find bugs, improve, modify, etc.

Is the function GetTextExtentPoint32W always present in win9X version of windows? Or will that function be dynamically loaded?

I think I am still missing part of the puzzle. In what way is using Utf8ToUnicode better than Utf8ToAnsi? Is it because Utf8ToAnsi only supports one charset at a time while with Utf8ToUnicode you can show Arab, Cyrilic, Hebrew, Japanese and Latin (to name just a few) characters in one string?

Vincent

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to