运行就出错,project logindemo.exe raised exception class eaccessviolation with message 'access violation at address 00456326 in module'logindemo.exe'.read of address 000002f4'.process stopped.use step or run to continue.这个是我在做点击按钮跳出新窗口时出现的...请高手指教!
调试欢乐多
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, StdCtrls,guessform;type
TForm1 = class(TForm)
Button1: TButton;
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
wndHandle: THandle; //用于存储指定窗口的句柄
wndClass: array[0..50] of Char; //用于存储类名
Tmp:integer;implementationuses FrmLogin;
{$R *.dfm}procedure TForm1.FormActivate(Sender: TObject);
begin
if FormLogin.ShowModal <> mrOk then //如果返回不成功
begin
Application.Terminate;//退出!
end;
begin
strPCopy(@wndClass[0], 'Shell_TrayWnd'); //获取任务栏类名
wndHandle := FindWindow(@wndClass[0],nil); //获取任务栏窗口的句柄
ShowWindow(wndHandle, SW_show); //显示Windows任务栏
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
GuessFm.Show;
end;end.
Forms,
FrmMain in 'FrmMain.pas' {Form1},
FrmLogin in 'FrmLogin.pas' {FormLogin};{$R *.res}begin
Application.Initialize;
Application.Title := '用户登陆系统';
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TFormLogin, FormLogin);
Application.Run;
end.
Application.CreateForm(TForm1, Form1);
//加入guessfm创建
Application.CreateForm(TFormLogin, FormLogin);
方法2with TGuessFm.Create(Owner) do
begin
show;
end;
with TGuessFm.Create(Owner) do
begin
GuessFm.Show;
end;