好的我正在写一个使用不同形式的教育计划。这是我第一次用多种形式编码,因为我还是一名新手程序员。
点击我的“登录”按钮后,它会打开新表单,但会显示访问冲突代码。
unit SignInNew_u;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, xpman;
type
TSignInNew = class(TForm)
Panel1: TPanel;
Label2: TLabel;
Label3: TLabel;
Label1: TLabel;
Label4: TLabel;
edtName: TEdit;
edtSurname: TEdit;
btnSignIn: TButton;
help: TButton;
procedure btnSignInClick(Sender: TObject);
procedure helpClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
SignInNew: TSignInNew;
implementation
uses HelpNew_u, ElementsNew;
{$R *.dfm}
procedure TSignInNew.btnSignInClick(Sender: TObject);
var
sName,sSurname,text:string;
User:TextFile;
begin
ElementsNew.TMain.Create(self);
ElementsNew.Main.Show;
Main.WindowState:= wsMaximized;
end;
procedure TSignInNew.helpClick(Sender: TObject);
begin
HelpNew := THelpNew.Create(self);
HelpNew.Show;
HelpNew.Width:=281;
HelpNew.Height:=481;
end;
end.
任何帮助将不胜感激。
答案 0 :(得分:-1)
查看代码,您正在实例化一个类(TMain)
ElementsNew.TMain.Create(self);
但从未将其分配给变量。您使用的是nil var(Main)
ElementsNew.Main.Show;
Main.WindowState:= wsMaximized;
解决这个问题:
Main := ElementsNew.TMain.Create(self);
Main.Show;