关于MDI窗体的问题!恳请各位富翁援助!!!(100分)

  • 主题发起人 主题发起人 cpilq
  • 开始时间 开始时间
C

cpilq

Unregistered / Unconfirmed
GUEST, unregistred user!
工程文件代码如下:

program SQsoft;

uses
Forms,
SQsofta in 'SQsofta.pas' {MDIMainForm},
SQsoftb in 'SQsoftb.pas' {FormChild1},
SQsoftpwa in 'SQsoftpwa.pas' {FormPassword},
ISQsoft in 'ISQsoft.pas' {FormFlash};

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TFormFlash, FormFlash);
Application.CreateForm(TFormPassword, FormPassword);
Application.Run;
end.

启动界面代码如下:

unit ISQsoft;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls;

type
TFormFlash = class(TForm)
Image1: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FormFlash: TFormFlash;

implementation

uses SQsofta, SQsoftb, SQsoftpwa;

{$R *.dfm}

procedure TFormFlash.Timer1Timer(Sender: TObject);
begin
FormFlash.Hide;
FormFlash.Free;
FormPassword.ShowModal;
end;

end.

登陆界面代码如下:

unit SQsoftpwa;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, ExtCtrls, Buttons, DB, ADODB, Mask;

type
TFormPassword = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
ComboBox1: TComboBox;
MaskEdit1: TMaskEdit;
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FormPassword: TFormPassword;

implementation

uses ISQsoft, SQsofta, SQsoftb;

{$R *.dfm}

procedure TFormPassword.BitBtn2Click(Sender: TObject);
begin
Application.Terminate;
end;

procedure TFormPassword.FormShow(Sender: TObject);
begin
Combobox1.Items.Add('管理员');
Combobox1.Text:='管理员';
Combobox1.ItemIndex:=1;
Combobox1.Items.Add('会计');
Combobox1.Text:='会计';
Combobox1.ItemIndex:=2;
Combobox1.Items.Add('出纳');
Combobox1.Text:='出纳';
Combobox1.ItemIndex:=3;
end;

procedure TFormPassword.BitBtn1Click(Sender: TObject);
var
SQL_Cmd:string;
begin
sql_cmd:='select id,pw from pwa ';
sql_cmd:=sql_cmd+'where id='+#39+trim(combobox1.text)+#39;
sql_cmd:=sql_cmd+'and pw='+#39+trim(maskedit1.Text)+#39;
if (Combobox1.Text<>ADOQuery1.Fieldvalues['id']) or
(Maskedit1.Text<>ADOQuery1.Fieldvalues['pw']) then
showmessage('您的口令不正确,请重新输入')
else
begin
Formpassword.Hide;
MDIMainForm.Show;
end;
end;

end.

在输入正确口令的情况下。出现一下消息框

Access violation at address 0045e3d2 in module 'SQsoft.exe'.Read of address

000002f4

确定之后没有调用MDIMainForm.登陆界面也消失,只有程序进程。

在没有输入口令直接点击登陆按键的时候,出现showmessage里面的信息之后,也同样消失,
留下进程。

如果把登陆按键的代码改成直接启动MDIMainForm的话!没有将FormChild1调用出来!只有MDIM

ainForm而已!
在下是delphi初学者!请各位富翁帮忙!在线等待!
 
你把TFormPassword设成是showmodule的形式
通过相应的Moduleresult进行对应的操作例如:
if FormPassword.showmodule = mrok then
begin
//相应的显示主窗体的代码
end;
if FormPassword.showmodule = mrcancel then
begin
//相应的退出程序
end;
 
begin
Application.Initialize;
Application.CreateForm(TFormFlash, FormFlash);//这样FormFlash就是主窗口,释放它会退出程序
Application.CreateForm(TFormPassword, FormPassword);
Application.Run;
end.

begin
Application.Initialize;
FormFlash := TFormFlash.Create(Application);
FormFlash.Show;
Application.CreateForm(TFormPassword, FormPassword);
Application.Run;
end.


FormFlash.Hide;
FormFlash.Free;//把自己释放了先?
FormPassword.ShowModal


FormFlash.Hide;
FormPassword.ShowModal
FormFlash.Free;

 
FormFlash,FormPassword兩個都不是主窗口﹐
主窗口那里去了﹐你是設置那個為主窗口的


問題主要是你的主窗口設置錯了
 
请先设置好主窗体。
 
还是不明白!能够详细点嘛?
 
你是設置那個窗體為主窗體??
 
多人接受答案了。
 
后退
顶部