![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
delphi выдает ошибку
project Project1.exe raised exception class eaccessviolation with message 'Access violation at address 0044B342 in module 'Project1.exe'. Read of address 000002F4". Код:
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3},
Unit4 in 'Unit4.pas' {Form4};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm3, Form3);
Application.CreateForm(TForm4, Form4); вот сюда показывает стрелочка
Application.Run;
end.
Первая форма
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, XPMan, jpeg, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label2: TLabel;
XPManifest1: TXPManifest;
PopupMenu1: TPopupMenu;
N4: TMenuItem;
Image1: TImage;
Label1: TLabel;
OpenDialog1: TOpenDialog;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure Button1Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Form2: TForm;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2:=TForm2.Create(application);
Form2.ShowModal;
end;
procedure TForm1.N4Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.N2Click(Sender: TObject);
begin
OpenDialog1.Execute;
image1.Picture.LoadFromFile(opendialog1.filename);
end;
end.
Вторая форма
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, jpeg;
type
TForm2 = class(TForm)
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Timer1: TTimer;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
i:integer;
implementation
uses Unit4, Unit3, Unit1;
{$R *.dfm}
procedure TForm2.RadioButton2Click(Sender: TObject);
begin
form4.showmodal;
end;
procedure TForm2.RadioButton1Click(Sender: TObject);
begin
form3.showmodal;
end;
procedure TForm2.RadioButton3Click(Sender: TObject);
begin
form4.showmodal;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
Form1.Visible:=false;
timer1.Enabled:=true;
i:=30;
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
i:=i-1;
label2.Caption:='залишилось '+ inttostr(i)+ ' сек ';
if i=0 then
begin
Timer1.Enabled:=false;
Form4.Show;
end;
if radiobutton1.Checked then
Timer1.Enabled:=false;
if radiobutton2.Checked then
Timer1.Enabled:=false;
if radiobutton3.Checked then
Timer1.Enabled:=false;
end;
procedure TForm2.N1Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
Третья форма
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;
type
TForm3 = class(TForm)
Image1: TImage;
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
Form2.Visible:=false;
end;
end.
Четвертая форма
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, StdCtrls;
type
TForm4 = class(TForm)
Image1: TImage;
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm4.FormCreate(Sender: TObject);
begin
Form2.Visible:=false;
end;
end.Последний раз редактировалось M.A.D.M.A.N., 03.11.2013 в 16:41. |
|
#2
|
|||
|
|||
|
Экстрасенсы в отпуске. На какой строке выдает ошибку?
|
|
#3
|
|||
|
|||
|
Application.CreateForm(TForm4, Form4);
Показывает стрелку на эту строку |
|
#4
|
||||
|
||||
|
Цитата:
|
|
#5
|
|||
|
|||
|
точно, спасибо большое)
|
|
#6
|
||||
|
||||
|
Код:
procedure TForm1.N2Click(Sender: TObject); begin OpenDialog1.Execute; image1.Picture.LoadFromFile(opendialog1.filename); end; Код:
procedure TForm1.N2Click(Sender: TObject); begin if not OpenDialog1.Execute then Exit; image1.Picture.LoadFromFile(opendialog1.filename); end; Кроме того, для отображения/скрытия форм есть стандартные методы Show/Hide, а свойство Visible обычно используют для логических операций. Так-что вместо: Form2.Visible:=false; корректнее использовать: Form2.Hide; Последний раз редактировалось Страдалецъ, 04.11.2013 в 15:47. |