No i nie dziw się że nie działa, bo zamiast jedynie dodać nowe sekcje w modułach - wszystko pomieszałeś...
- deklaracja klasy formularza musi być w sekcji
interface
,
- deklaracja zmiennej, będącej obiektem klasy formularza także musi być w sekcji
interface
;
Sekcja ta (interface
) jest widoczna dla innych modułów, natomiast implementation
nie, dlatego moduły w ogóle nie widzą obiektów Form1
oraz Form2
; Prawidłowa konstrukcja:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
BitBtn1: TBitBtn;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Login: TLabel;
Password: TLabel;
procedure Button1Click(Sender: TObject);
procedure Edit2Change(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
uses // tutaj miałeś jedynie dodać nową sekcję uses i moduł Unit2
Unit2;
{...}
end.
unit Unit2;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, Menus;
type
{ TForm2 }
TForm2 = class(TForm)
BitBtn1: TBitBtn;
Button1: TButton;
Label1: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Label1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.lfm}
uses // tutaj miałeś jedynie dodać nową sekcję uses i moduł Unit1
Unit1;
{...}
end.
Teraz powinno dać się skompilować; Na przyszłość najpierw się zastanów, a dopiero później wprowadzaj jakiekolwiek modyfikacje na własną rękę, ale przede wszystkim przeczytaj jakikolwiek kurs programowania w Object Pascalu, żeby znów nie trzeba było się głowić.