简体   繁体   中英

Delphi-FireMonkey-Undeclared Identifier 'TEdit' ;Undeclared Identifier 'TLabel';

I'm working on a practice Application in Firemonkey-RAD Studio XE3-Delphi. When implementing code I get the following errors:

Undeclared Identifier 'TEdit' Undeclared Identifier 'TLabel' 'TLabel' does not contain a member named 'caption' at line 35

I included the code form the project in the following body.

Any help is appreciated. Go easy on me..I'm new to Delphi.

 unit strcode1u1;

    interface

    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

    type
      Tstrcode1f1 = class(TForm)
        ePlainText: TEdit;
        laEncrypted: TLabel;
        procedure ePlainTextChange(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      strcode1f1: Tstrcode1f1;

    implementation

    {$R *.dfm}

    procedure Tstrcode1f1.ePlainTextChange(Sender: TObject);
    begin

    end;

    procedure Tstrcode1f1.FormCreate(Sender: TObject);
    begin
    laEncrypted.caption:=
        chr(72)+chr(101)+chr(108)+
        chr(108)+chr(111)+chr(32)+
        chr(87)+chr(111)+chr(114)+
        chr(108)+chr(100);
    end;
    end.

You say that you are creating a FireMonkey app, but your uses clause contains references to VCL units:

Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs

Instead of FireMonkey units:

FMX.Controls, FMX.Forms, FMX.Dialogs

In addtion to @Remy's answer, there's an additional issue. TLabel in FireMonkey doesn't have a caption, as you can see in the Object Inspector.

FMX TLabel否字幕对象检查器

It (and all of the other FMX controls) use Text instead.

在此处输入图片说明

Start by creating a new FireMonkey application (File->New->FireMonkey Desktop Application - Delphi from the IDE's main menu). When the next dialog appears, choose whether you want a FireMonkey HD or 3D application (the documentation can explain the difference between the two).

You can then drop a TLabel and TEdit on your form, name them properly in the Object Inspector, and change your code to this instead:

aEncrypted.Text:= chr(72)+chr(101)+chr(108)+
                  chr(108)+chr(111)+chr(32)+
                  chr(87)+chr(111)+chr(114)+
                  chr(108)+chr(100);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM