枚舉並設置界面的Caption之多語言方法

2016-02-19 18:49 0 1 收藏

图老师设计创意栏目是一个分享最好最实用的教程的社区,我们拥有最用心的各种教程,今天就给大家分享枚舉並設置界面的Caption之多語言方法的教程,热爱PS的朋友们快点看过来吧!

【 tulaoshi.com - 编程语言 】

 

  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;
  

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

   

   

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

  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;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

来源:https://www.tulaoshi.com/n/20160219/1619092.html

延伸阅读
  ■ 多媒体 <BGSOUND <EMBED 欲明白本篇【HTML彻底剖析】之标记分类,请看 【标记一览】。 也请先明白围堵标记与空标记的分别,请看 【HTML概念】。 ■ <BGSOUND: <BGSOUND 是用来插入背景音乐,但只适用于 IE,其参数设定不多。如下 <BGSOUND ="your.mid" =true =infinite ="your....
QQ界面的模拟实现(上) 作者:小帅 下载源代码 大凡用过电脑,上过网的朋友都用过QQ,对QQ的一些交互界面可能垂慕已久,的确,无论是其生动的企鹅形象,还是“滴滴的”消息声音,以及“刷”的菜单等功能,简单单的消息发送,以及快速的回显和众多卡通的QQ头像等铸就了其在网络的良好地位,本人对其研究虽不够...
标签: Web开发
表单,我相信这是前端开发者工作中最难处理的一个作业了.表单设计中几乎涉及了所有前端各方面的思想与技术.其用户注册页面即为最典型的代表,我要说设计本身没有对与错只有好与坏,就好像人的脸,只有漂亮与不漂亮,不能说某人的脸长错了.当然这其中就会有尺度去衡量,但难就难在这个尺度本身没有标准.好的,我已经为我将要阐述的观点铺好了下去的...
清蒸鲫鱼的家常做法 方法竟如此之多 鲫鱼是生活当中最常见的一种鱼。鲫鱼不仅味道鲜美而且鱼肉的营养价值很高,再加上物美价廉,所以深受百姓的喜爱,可以炖汤也可以清蒸。想知道鲫鱼的做法大全以及鲫鱼怎么做好吃吗?那就一起来看看吧。 方法一 材料 鲫鱼、葱段、火腿、香菇块、盐、胡椒粉、黄酒...
界面是什么? 是的,有些时候,我就在想这个简单的问题,而那时我的答案还是:界面是对软件应用解决方案的显性,使用图形化符号,向使用者解释它的功能与任务。 但最近一些认知却让我对这个问题有了新的回答:界面就是软件应用它本身。它不是一份对软件应用功能的图形化说明书,不是对软件应用功能与任务的图形化翻译,它就是软件应用本身,并...

经验教程

420

收藏

51
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部