首 页 | 精品电影 | 音乐天堂 | 在线游戏 | Flash MTV | 三湘书屋 | 幽默笑话 | 三湘图库 | 美女写真 | IT知识库 | QQ贴图 | 加入书签

网页制作网络编程图形图象操作系统冲浪宝典软件教学网络安全认证考试通信技术电子商务业内动态书籍教程原码

最近更新 文章分类 多媒体类 精品软件

本站搜索:
您的位置:三湘时空 -> IT知识库 -> 文章分类 -> Delphi -> 枚舉並設置界面的Caption之多語言方法
枚舉並設置界面的Caption之多語言方法


文章类别:Delphi 来源: 作者: 发表日期:2006-2-4 字体:[ ]

小游戏 | 在线影院 | 幽默笑话 | 源码下载 | Flash MTV | 音乐试听 | 书屋 | 美女写真

 

uses
  ..., TypInfo;

function TForm1.IsAPropExist(AInst: TObject; const PropName: string): Boolean;
var
  PropInfo: PPropInfo;
begin
  Result := False;
  PropInfo := GetPropInfo(AInst, PropName);
  if PropInfo <> nil then
    Result := PropInfo.Name = PropName;
end;


procedure TForm1.Button2Click(Sender: TObject);
var
  i: Integer;
begin
  for i := 0 to Self.ComponentCount - 1 do
  begin
    if IsAPropExist(Self.Components[i], 'Caption') then
      SetPropValue(Self.Components[i], 'Caption', IntToStr(i));
  end;
end;

 

 

-------------------------------------------------------------------------------

uses
  ..., TypInfo;

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
  aComponent: TComponent;
  PropInfo: PPropInfo;
  ViewText, ViewHint: string;
begin
  ViewText := 'Hello world'; // for debug use, you should comment these 2 lines
  ViewHint := 'the hint';    //   and then implement GetInfoByName method.

  for i := 0 to ComponentCount - 1 do
  begin
    aComponent := Components[i];
    PropInfo := GetPropInfo(aComponent.ClassInfo, 'Caption');
    if not Assigned(PropInfo) then // Caption property of aComponent NOT exists
    begin
      // turn to search Text property
      PropInfo := GetPropInfo(aComponent.ClassInfo, 'Text');
      if not Assigned(PropInfo) then // Text property of aComponent NOT exists
        Continue;
    end;

    // comes here, either Caption or Text property must exists
    // first, find the ViewText and ViewHint of the aComponent by the name
    // GetInfoByName(aComponent.Name, ViewText, ViewHint);
    SetStrProp(aComponent, PropInfo, ViewText);

    // then, search Hint property
    PropInfo := GetPropInfo(aComponent.ClassInfo, 'Hint');
    if Assigned(PropInfo) then
      SetStrProp(aComponent, PropInfo, ViewHint);
  end;
end;

上一篇:使用HOOK随心监视Windows 下一篇:防止全局hook入侵Delphi版,2000以上系统适用(part2)
本栏目热门文章
·Delphi工具—反编译Delphi(三) 2006-2-4
·Delphi工具—反编译Delphi(二) 2006-2-4
·Delphi工具——反编译Delphi(一) 2006-2-4
·用FASTREPORT实现WEB应用中自定义报表 2006-2-4
·Delphi中ScriptControl的高级应用(一) 2006-2-4
·利用内存映射文件扩充程序可用的内存 2006-2-4
·QQ聊天记录器演示程序 2006-2-4
·Delphi与DirectShow&amp;DSPack/在 2006-2-4
·UltraEdit也支持Delphi语法高亮 2006-2-4
·DirectShow之接口实战篇(二) 2006-2-4
新近更新文章
·BPCS系统现金流量分析工具开发日志 2006-2-4
·程序间相互通讯问题的解决 2006-2-4
·如何获取本地HTML文件的标题,超级链接 2006-2-4
·建立自己的csdn知识管理库(1) 2006-2-4
·使用Delphi开发多媒体播放音轨问题的FAQ(原创) 2006-2-4
·监视资源管理器的文件变化 2006-2-4
·实现在virtualStringtree中编辑的标准步骤 2006-2-4
·WINDOWS编程技巧之DELPHI篇 2006-2-4
·DELPHI面向对象支持特点--保护级类成员的应用 2006-2-4
·取Run下所有值(原创) 2006-2-4
首 页 | 软件发布 | 广告联系 | 下载帮助 | 意见反馈 | 网站地图
  CopyRight? 2002-2004 WWW.SXSKY.NET? All Rights Reserved
三湘时空 站长QQ:82675303 Email: