2014-03-26 88 views
1

我的项目存在问题。这是当我点击按钮,关闭应用程序,这个代码是模块'project.exe'中地址004EAE10的访问冲突地址00000004'

procedure Tflogin.btnKeluarClick(Sender: TObject); 
begin 
    application.Terminate; 
end; 

会“在模块地址00000004' 的‘project.exe’写地址004EAE10访问冲突”表现出梅格盒错误怎么解决?

这是我的项目代码dpr 程序NEW_SPJK;

uses 
    Forms, 
    Controls, 
    login in 'login.pas' {flogin}, 
    udm in 'header\udm.pas' {dm: TDataModule}, 
    umenu in 'header\umenu.pas' {fmenu}, 
    urelasi in 'header\urelasi.pas' {frelasi}, 
    ubagian in 'header\ubagian.pas' {fbagian}, 
    umetode in 'header\umetode.pas' {fmetode}, 
    utambahhasil in 'header\utambahhasil.pas' {ftambahhasil}, 
    utambahtanya in 'header\utambahtanya.pas' {ftambahtanya}, 
    udaftar in 'header\udaftar.pas' {fdaftar}, 
    ubiodata in 'header\ubiodata.pas' {fbiodata}, 
    ujawab in 'header\ujawab.pas' {Form2}, 
    uhasil in 'header\uhasil.pas' {fhasil}, 
    uinformasi in 'header\uinformasi.pas' {fdaftarsiswa}, 
    uabout in 'header\uabout.pas' {ftentang}, 
    upilihbagiaan in 'header\upilihbagiaan.pas' {fproses}, 
    umemo in 'header\umemo.pas' {fmemo}; 



{$R *.res} 
var LoginOK: Boolean; 
begin 
    Application.Initialize; 
    Application.CreateForm(Tdm, dm); 
    Application.CreateForm(Tfmenu, fmenu); 
    Application.CreateForm(Tflogin, flogin); 
    Application.CreateForm(Tfproses, fproses); 
    Application.CreateForm(TForm2, Form2); 
    Application.CreateForm(Tfhasil, fhasil); 
    Application.CreateForm(Tfbiodata, fbiodata); 
    with Tflogin.Create(nil) do begin 
    LoginOK:=(ShowModal=mrOK); 
    Application.CreateForm(Tfmenu, fmenu); 
    Free; 
    end; 
    if not LoginOK then Halt; 
    Application.Run; 
end. 
+0

您可以发表您在dpr文件中使用的代码吗? – Graymatter

+0

您的主窗体是否创建了“Tflogin”表单?你是否试图从弹出的模式窗口终止应用程序?这将有助于查看用于显示登录对话框的代码。 –

+2

您正在访问'nil'指针。我们看不到足够的代码。请出示SSCCE。 –

回答

3

中,您显示的代码最明显的错误是,你这样做了两次:

Application.CreateForm(Tfmenu, fmenu); 

我相信你的意思是只有一次这样做。

作为一般建议,只需要拨打Application.CreateForm一次,即可创建主窗体。剩下的时间你可以调用窗体的构造函数。而且我也建议你不要使用全局变量和自动创建的表单。在需要时创建窗体是一种更好的做法,并且在关闭窗体时将其销毁。

+0

谢谢mr.David ..这个问题解决了:) –

相关问题