Announcement

Collapse
No announcement yet.

Alle Caption in der Form auslesen u. setzen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Alle Caption in der Form auslesen u. setzen

    Hallo, <br>
    um eine Anwendung zur Laufzeit auf eine andere Sprache umzuschalten, möchte ich alle Komponenten mit der Eigenschaft Caption ausfindig machen und diese neu setzen. Wer hat eine Lösung?<br>
    Helmut

  • #2
    <pre>

    <code><font size=2 face="Courier New"><b>unit </b>Unit3;
    <br>
    <b>interface
    <br>
    uses
    </b>Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls;
    <br>
    <b>type
    </b>TForm1 = <b>class</b>(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    <b>procedure </b>Button1Click(Sender: TObject);
    <b>private
    procedure </b>DoExit(Sender: TObject);
    <b>public
    </b><font color="#008080"><i>{ Public-Deklarationen }
    </i></font><b>end</b>;
    <br>
    <b>var
    </b>Form1: TForm1;
    <br>
    <b>implementation
    <br>
    </b><font color="#008080"><i>{$R *.DFM}
    <br>
    </i></font><b>uses </b>TypInfo;
    <br>
    <b>procedure </b>SetProperties(Component: TComponent; <b>const </b>DoExit: TMethod);
    <b>var
    </b>I: Integer;
    P: PPropInfo;
    <b>begin
    </b><font color="#008080"><i>// Beispiel f&uuml;r Torsten
    </i></font>P := GetPropInfo(Component, <font color="#0000FF">'OnExit'</font>, [tkMethod]);
    <b>if </b>P &lt;&gt; <b>nil then </b>SetMethodProp(Component, P, DoExit);
    <br>
    <font color="#008080"><i>// Beispiel f&uuml;r Helmut
    </i></font>P := GetPropInfo(Component, <font color="#0000FF">'Caption'</font>);
    <b>if </b>P &lt;&gt; <b>nil then </b>SetStrProp(Component, P, <font color="#0000FF">'Test'</font>);
    <br>
    <b>for </b>I := <font color="#0000FF">0 </font><b>to </b>Component.ComponentCount -<font color="#0000FF">1 </font><b>do
    </b>SetProperties(Component.Components[I], DoExit);
    <b>end</b>;
    <br>
    <b>procedure </b>TForm1.Button1Click(Sender: TObject);
    <b>var
    </b>E: TMethod;
    <b>begin
    </b>TNotifyEvent(E) := DoExit;
    Setproperties(Self, E);
    <b>end</b>;
    <br>
    <b>procedure </b>TForm1.DoExit(Sender: TObject);
    <b>begin
    </b>MessageBox(Handle, <font color="#0000FF">'OnExit'</font>, <b>nil</b>, <font color="#0000FF">0</font>);
    <b>end</b>;
    <br>
    <b>end</b>.
    </font>
    </code></pre&gt

    Comment


    • #3
      Super!! -:

      Comment

      Working...
      X