Multi-language method for enumerating and seting interface of CAPTION

xiaoxiao2021-03-06  40

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) THENSTSTSTRPROP (ACOMPONENT, PROPINFO, VIEWHINT); END; END; ************** *********************************************************** *********************** Function 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 setLang; var i: Integer; strValue: string; StrObj: string; StrCaption: String; begin for i: =

转载请注明原文地址:https://www.9cbs.com/read-61980.html

New Post(0)