zoukankan      html  css  js  c++  java
  • GetPropInfo Font Size

    设置font size,遍历所有控件,有的控件没有font属性,所以要用GetPropInfo判断

    if (GetPropInfo(cmp, "font"))

    function GetObjectProperty(

        const AObject   : TObject;

        const APropName : string

        ):TObject;

    var

      PropInfo:PPropInfo;

    begin

      Result  :=  nil;

      PropInfo:=GetPropInfo(AObject.ClassInfo,APropName);

      if Assigned(PropInfo) and

          (PropInfo^.PropType^.Kind = tkClass) then

        Result  :=  GetObjectProp(AObject,PropInfo);

    end;



    function SetIntegerPropertyIfExists(

        const AObject   : TObject;

        const APropName : string;

        const AValue    : integer

        ):Boolean;

    var

      PropInfo:PPropInfo;

    begin

      PropInfo:=GetPropInfo(AObject.ClassInfo,APropName);

      if Assigned(PropInfo) and

          (PropInfo^.PropType^.Kind = tkInteger) then

      begin

        SetOrdProp(AObject,PropInfo,AValue);

        Result:=True;

      end else

        Result:=False;

    end;



    //调用

    procedure TFrmTest.FormCreate(Sender: TObject);

    var

      objTemp : TObject;

    begin

      objTemp :=  GetObjectProperty(Self,'Font');

      if Assigned(objTemp) then

        SetIntegerPropertyIfExists(objTemp,'Size',9);

    end;

  • 相关阅读:
    AD20改变pcb图纸大小方式
    ceph相关概念
    五种IO模型和三种实现方式
    MongoDB入门
    GO通过sqlx库操作MySQL
    Go原生sql操作MySQL
    Traefik工作原理
    Redis主从
    Nginx入门
    Redis入门
  • 原文地址:https://www.cnblogs.com/cb168/p/3912546.html
Copyright © 2011-2022 走看看