窗体为什么会自动关闭?(10分)

  • 主题发起人 主题发起人 ejie00
  • 开始时间 开始时间
E

ejie00

Unregistered / Unconfirmed
GUEST, unregistred user!
俩个单元文件,有俩个问题!
1。pubedit:tedit;为什么编译通过不了/
2。当登陆窗体提示密码错误时,点确定后,为什么程序自动关闭?
主窗口unit zhuyao;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls, Buttons, ExtCtrls;
type
Tzjmck = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
StatusBar1: TStatusBar;
Panel2: TPanel;
Panel3: TPanel;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
pubedit:tedit;//编译通过不了,为什么?;
end;

var
zjmck: Tzjmck;
implementation
uses denglu, cangkujinhuo;
{$R *.dfm}
procedure Tzjmck.SpeedButton10Click(Sender: TObject);
begin
if application.MessageBox(‘确认退出本系统吗?‘,‘系统提示‘,mb_iconquestion+mb_yesno)=id_yes then
application.terminate;
end;

procedure Tzjmck.SpeedButton3Click(Sender: TObject);
begin
ckjhjm:=tckjhjm.create(self);
ckjhjm.showmodal;
end;

end.
登陆窗口
unit denglu;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons, ExtCtrls;
type
Tdlck = class(TForm)
Panel1: TPanel;
Label2: TLabel;
Label3: TLabel;
edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
dlckqry: TADOQuery;
ComboBox1: TComboBox;
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject;
var Key: Char);
procedure BitBtn1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
dlck: Tdlck;
pass: array[0..20] of string;
//记录密码数组;
xm:array[0..20] of string;
//记录名称数组;
flat:boolean;
//这里有什么用不知道;
implementation
uses zhuyao;
{$R *.dfm}
procedure Tdlck.BitBtn2Click(Sender: TObject);
begin
if application.MessageBox(‘确认退出本系统吗?‘,‘系统提示‘,mb_iconquestion+mb_yesno)=id_yes then
application.Terminate ;
end;

procedure Tdlck.FormCreate(Sender: TObject);
var
i:integer;
begin
dlckqry.close;
flat:=false;
dlckqry.SQL.Clear;
dlckqry.SQL.Add(‘select * from yonghubiao‘);
dlckqry.Open;
dlckqry.first;
i:=0;
while not dlckqry.Eof do
begin
combobox1.Items.Add(dlckqry.fieldbyname(‘name‘).asstring);
pass:=dlckqry.fieldbyname(‘password‘).AsString;
xm:=dlckqry.fieldbyname(‘name‘).AsString ;
inc(i);
dlckqry.next;
end;
combobox1.text:=‘‘;
bitbtn1.enabled:=false;
end;

procedure Tdlck.ComboBox1Change(Sender: TObject);
begin
if combobox1.ItemIndex>-1 then
bitbtn1.Enabled :=true;
end;

procedure Tdlck.ComboBox1KeyPress(Sender: TObject;
var Key: Char);
begin
key:=#0;
//#是什么意思,0又代表什么?;
end;

procedure Tdlck.BitBtn1Click(Sender: TObject);
begin
if (edit1.text=Pass[combobox1.itemindex]) and (combobox1.text=xm[combobox1.ItemIndex]) then
begin
zjmck.show;
flat:=true;
self.close;
end
else
Application.MessageBox(‘密码错误!‘,‘提示‘, MB_OK+MB_ICONINFORMATION);
edit1.SetFocus;//运行到这里程序自动关闭,我原想的是关闭提示框,继续登陆窗口;
exit;
end;

俩个单元文件,有俩个问题!
1。pubedit:tedit;为什么编译通过不了/
2。当登陆窗体提示密码错误时,点确定后,为什么程序自动关闭?
主窗口unit zhuyao;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls, Buttons, ExtCtrls;
type
Tzjmck = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
StatusBar1: TStatusBar;
Panel2: TPanel;
Panel3: TPanel;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
pubedit:tedit;//编译通过不了,为什么?;
end;

var
zjmck: Tzjmck;
implementation
uses denglu, cangkujinhuo;
{$R *.dfm}
procedure Tzjmck.SpeedButton10Click(Sender: TObject);
begin
if application.MessageBox(‘确认退出本系统吗?‘,‘系统提示‘,mb_iconquestion+mb_yesno)=id_yes then
application.terminate;
end;

procedure Tzjmck.SpeedButton3Click(Sender: TObject);
begin
ckjhjm:=tckjhjm.create(self);
ckjhjm.showmodal;
end;

end.
登陆窗口
unit denglu;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons, ExtCtrls;
type
Tdlck = class(TForm)
Panel1: TPanel;
Label2: TLabel;
Label3: TLabel;
edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
dlckqry: TADOQuery;
ComboBox1: TComboBox;
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject;
var Key: Char);
procedure BitBtn1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
dlck: Tdlck;
pass: array[0..20] of string;
//记录密码数组;
xm:array[0..20] of string;
//记录名称数组;
flat:boolean;
//这里有什么用不知道;
implementation
uses zhuyao;
{$R *.dfm}
procedure Tdlck.BitBtn2Click(Sender: TObject);
begin
if application.MessageBox(‘确认退出本系统吗?‘,‘系统提示‘,mb_iconquestion+mb_yesno)=id_yes then
application.Terminate ;
end;
procedure Tdlck.FormCreate(Sender: TObject);
var
i:integer;
begin
dlckqry.close;
flat:=false;
dlckqry.SQL.Clear;
dlckqry.SQL.Add(‘select * from yonghubiao‘);
dlckqry.Open;
dlckqry.first;
i:=0;
while not dlckqry.Eof do
begin
combobox1.Items.Add(dlckqry.fieldbyname(‘name‘).asstring);
pass:=dlckqry.fieldbyname(‘password‘).AsString;
xm:=dlckqry.fieldbyname(‘name‘).AsString ;
inc(i);
dlckqry.next;
end;
combobox1.text:=‘‘;
bitbtn1.enabled:=false;
end;

procedure Tdlck.ComboBox1Change(Sender: TObject);
begin
if combobox1.ItemIndex>-1 then
bitbtn1.Enabled :=true;
end;

procedure Tdlck.ComboBox1KeyPress(Sender: TObject;
var Key: Char);
begin
key:=#0;
//#是什么意思,0又代表什么?;
end;
procedure Tdlck.BitBtn1Click(Sender: TObject);
begin
if (edit1.text=Pass[combobox1.itemindex]) and (combobox1.text=xm[combobox1.ItemIndex]) then
begin
zjmck.show;
flat:=true;
self.close;
end
else
Application.MessageBox(‘密码错误!‘,‘提示‘, MB_OK+MB_ICONINFORMATION);
edit1.SetFocus;//运行到这里程序自动关闭,我原想的是关闭提示框,继续登陆窗口;
exit;
end;
俩个单元文件,有俩个问题!
1。pubedit:tedit;为什么编译通过不了/
2。当登陆窗体提示密码错误时,点确定后,为什么程序自动关闭?
主窗口unit zhuyao;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls, Buttons, ExtCtrls;
type
Tzjmck = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
StatusBar1: TStatusBar;
Panel2: TPanel;
Panel3: TPanel;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
pubedit:tedit;//编译通过不了,为什么?;
end;

var
zjmck: Tzjmck;
implementation
uses denglu, cangkujinhuo;
{$R *.dfm}
procedure Tzjmck.SpeedButton10Click(Sender: TObject);
begin
if application.MessageBox(‘确认退出本系统吗?‘,‘系统提示‘,mb_iconquestion+mb_yesno)=id_yes then
application.terminate;
end;

procedure Tzjmck.SpeedButton3Click(Sender: TObject);
begin
ckjhjm:=tckjhjm.create(self);
ckjhjm.showmodal;
end;

end.
登陆窗口
unit denglu;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons, ExtCtrls;
type
Tdlck = class(TForm)
Panel1: TPanel;
Label2: TLabel;
Label3: TLabel;
edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
dlckqry: TADOQuery;
ComboBox1: TComboBox;
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject;
var Key: Char);
procedure BitBtn1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
dlck: Tdlck;
pass: array[0..20] of string;
//记录密码数组;
xm:array[0..20] of string;
//记录名称数组;
flat:boolean;
//这里有什么用不知道;
implementation
uses zhuyao;
{$R *.dfm}
procedure Tdlck.BitBtn2Click(Sender: TObject);
begin
if application.MessageBox(‘确认退出本系统吗?‘,‘系统提示‘,mb_iconquestion+mb_yesno)=id_yes then
application.Terminate ;
end;

procedure Tdlck.FormCreate(Sender: TObject);
var
i:integer;
begin
dlckqry.close;
flat:=false;
dlckqry.SQL.Clear;
dlckqry.SQL.Add(‘select * from yonghubiao‘);
dlckqry.Open;
dlckqry.first;
i:=0;
while not dlckqry.Eof do
begin
combobox1.Items.Add(dlckqry.fieldbyname(‘name‘).asstring);
pass:=dlckqry.fieldbyname(‘password‘).AsString;
xm:=dlckqry.fieldbyname(‘name‘).AsString ;
inc(i);
dlckqry.next;
end;
combobox1.text:=‘‘;
bitbtn1.enabled:=false;
end;

procedure Tdlck.ComboBox1Change(Sender: TObject);
begin
if combobox1.ItemIndex>-1 then
bitbtn1.Enabled :=true;
end;

procedure Tdlck.ComboBox1KeyPress(Sender: TObject;
var Key: Char);
begin
key:=#0;
//#是什么意思,0又代表什么?;
end;

procedure Tdlck.BitBtn1Click(Sender: TObject);
begin
if (edit1.text=Pass[combobox1.itemindex]) and (combobox1.text=xm[combobox1.ItemIndex]) then
begin
zjmck.show;
flat:=true;
self.close;
end
else
Application.MessageBox(‘密码错误!‘,‘提示‘, MB_OK+MB_ICONINFORMATION);
edit1.SetFocus;//运行到这里程序自动关闭,我原想的是关闭提示框,继续登陆窗口;
exit;
end;

procedure Tdlck.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if flat=false then
halt;
action:=cafree;
end;

end.

 
用的是D6吧,偶在用ADO时,
也遇到过这个问题,不知为啥
 
对,我用的是d6和access2000
那在主窗口申明的pubedit:tedit;
编译为什么不能通过,郁闷!
 
我自己试了试,声明
pubedit:tedit;
可以编译通过的。
 
哎,那奇怪了,我怎么不能通过,是在public里申明的吗?
小问题,但是就是解决不了,请高手指点!
 
TEdit需要uses StdCtrls;
key:=#0;
//#是什么意思,0又代表什么?;
看看key的类型为char,#表示字符。#0表示空字符,即什么都不输入。
在属性框中将BitBtn1的ModalResult设定为mrNone;
 
同意影子的!
 
>>>影 子
能告诉我将那个在属性框中将BitBtn1的ModalResult设定为mrNone
具体是什么意思吗?
还有,我试过在use里加上StdCtrls;可是,编译是use就通过不了!
小弟,谢谢各位fw·
 
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls, Buttons, ExtCtrls, [red]StdCtrls[/red];
ModalResult的问题看看帮助吧。 
不用郁闷,想提高自己的水平,首先要学会看帮助。
 
接受答案了.
 

Similar threads

I
回复
0
查看
709
import
I
I
回复
0
查看
566
import
I
I
回复
0
查看
763
import
I
后退
顶部