A
A
artemk1ter2020-05-06 11:43:36
Delphi
artemk1ter, 2020-05-06 11:43:36

When I try to add in delphi Form2.ShowModal(show form); writes an error: "Undeclared identifier 'Form2' at (indicates a line)" How to solve?

When I try to add in delphi Form2.ShowModal; writes an error: "Undeclared identifier 'Form2' at (indicates a line)"

Here is the unit1 code:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Gif  : TGifImage;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.Visible := false;
Form2.ShowModal;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Gif := TGifImage.Create;
  Gif.LoadFromFile('C:\Users\Artem\Desktop\vrr.3321\video\render\Untitled.gif');
  Gif.Animate := True;

  Image1.Picture.Assign(GIF);
end;

end.


Unit2(second form) code:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin

end;

end.


Please tell me what is the problem

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-05-06
@tsklab

var
  Form1: TForm1;
  Gif  : TGifImage;

implementation

{$R *.dfm}

uses Unit2;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question