DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: randy522732557
今日帖子: 21
在线用户: 10
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 easycase (easycase) ★☆☆☆☆ -
盒子活跃会员
2003/12/15 18:51:44
标题:
ThemeEngine的中文支持如何搞? 浏览:1903
加入我的收藏
楼主: 我不是说现成的控件,而是想知道如何进行修改。
te_utils.pas 中

function TextWidth(Canvas: TCanvas; AText: WideString; Flags: Integer = 0): integer;
var
  R: TRect;
  Size: TSize;
  AnsiText: string;
begin
  R := Rect(0, 0, 0, 0);

  if IsWinNT and false then
  begin
    Windows.DrawTextW(Canvas.Handle, PWideChar(AText), Length(AText), R, DT_CALCRECT or Flags);
    Result := R.Right;
  end
  else
  begin
    if Flags = 0 then
    begin
      GetTextExtentPoint32W(Canvas.Handle, PWideChar(AText), Length(AText), Size);
      Result := Size.cx;
    end
    else
    begin
      SetLength(AnsiText, Length(AText));
      WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, PWideChar(AText), Length(AText), PChar(AnsiText), Length(AText), nil, nil);
      Windows.DrawText(Canvas.Handle, PChar(AnsiText), Length(AnsiText), R, DT_CALCRECT or Flags);
      Result := R.Right;
    end;
  end;
end;
这段代码如何修改才能解决呢????
http://www.2ccc.com/idea/index.asp?articleid=94 的方法没看懂是怎么回事!

----------------------------------------------
-
作者:
男 easycase (easycase) ★☆☆☆☆ -
盒子活跃会员
2003/12/15 20:24:24
1楼: Sorry!

原来站长大人同时发布了修改,感谢感谢

Only in 1: deploy
Common subdirectories: 1/packages and 2/packages
diff -an 1/te_controls.pas 2/te_controls.pas
d11360 1
a11360 2
    WholeTextWidth := Canvas.TextWidth(Copy(Text, 1, Length(Text)));

//    WholeTextWidth := TextWidth(Canvas, Copy(Text, 1, Length(Text)), DT_NOPREFIX);

d11389 1
a11389 2
        Result := Result + Canvas.TextWidth(Copy(Text, FFirstVisibleChar, a - FFirstVisibleChar + 1))

//        Result := Result + TextWidth(Canvas, Copy(Text, FFirstVisibleChar, a - FFirstVisibleChar + 1), DT_NOPREFIX)

d11391 1
a11391 2
        Result := Result + Canvas.TextWidth(Copy(Text, FFirstVisibleChar, Length(Text) - FFirstVisibleChar + 1));

//        Result := Result + TextWidth(Canvas, Copy(Text, FFirstVisibleChar, Length(Text) - FFirstVisibleChar + 1), DT_NOPREFIX);

d11415 1
a11415 1
    WholeTextWidth := Length(Text) * GetPasswordCharWidth

d11417 1
a11417 2
    WholeTextWidth := Canvas.TextWidth(Copy(Text, 1, Length(Text)));

//    WholeTextWidth := TextWidth(Canvas, Copy(Text, 1, Length(Text)), DT_NOPREFIX);

d11442 1
a11442 2
      CurX := CurX + Canvas.TextWidth(Text[Result + 1]) / 2;

//      CurX := CurX + TextWidth(Canvas, Text[Result + 1], DT_NOPREFIX) / 2;

d11444 1
a11444 2
        CurX := CurX + Canvas.TextWidth(Text[Result + 1 + 1]) / 2;

//        CurX := CurX + TextWidth(Canvas, Text[Result + 1 + 1], DT_NOPREFIX) / 2;

Only in 2: te_utils.~pas
Only in 1: tefx_buttons.pas
Only in 1: tefx_reg.pas
Only in 1: tefx_version.pas

----------------------------------------------
-
作者:
男 easycase (easycase) ★☆☆☆☆ -
盒子活跃会员
2003/12/16 3:27:56
2楼: 再来一个fix..有可能这个fix将出现在下一个版本的TE哦! ;p

I think it's better to fix te_utils.pas, there's TextWidth() function, where
I replaced:

----------
    begin
      SetLength(AnsiText, Length(AText));
      WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, PWideChar(AText),
Length(AText), PChar(AnsiText), Length(AText), nil, nil)

      Windows.DrawText(Canvas.Handle, PChar(AnsiText), Length(AnsiText), R,
DT_CALCRECT or Flags);
      Result := R.Right;
    end;
-----------

by

-----------
    begin
      if IsWinNT then
      begin
        Windows.DrawTextW(Canvas.Handle, PWideChar(AText), Length(AText), R,
DT_CALCRECT or Flags);
        Result := R.Right;
      end
      else
      begin
        SetLength(AnsiText, Length(AText));
        WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, PWideChar(AText),
Length(AText), PChar(AnsiText), Length(AText), nil, ni
);
        Windows.DrawText(Canvas.Handle, PChar(AnsiText), Length(AnsiText),
R, DT_CALCRECT or Flags);
        Result := R.Right;
      end;
    end;
-----------

Hope it gets to the next TE release.

Jiri


----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行66.40625毫秒 RSS