Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Violation while TCustomForm creates :((

Status
Not open for further replies.

ludeck

Programmer
Jul 1, 2001
1
IE
I have an MDI application with a number of child windows open. When you click a particular button on one such child form, we call Create on another one of my child forms, and up it should come. This has worked fine on dozens of other occasions, but for some reason I am getting an Access Violation error which is occurring during the call to "inherited Create" (of TCustomForm). Whether I use my own constructor, and call "inherited Create(AOwner)", or I don't use any constructor, so this call is made implicitely, I am getting the same error. Any ideas?
 
Some common Access Violation Causes (AV) are:

1) Not initializing a varaiable

procedure TForm1.Button1.Click(Sender: TObject);
var
List := TStringList;
begin
List.Add('Test');
end;

the initializing should be List := TStringList.Create;


2) Another variant is

procedure TForm1.Button1.Click(Sender: TObject);
var
List := TStringList;
begin
List.Create;
List.Add('Test');
end;

List.create does not create a new stringlist, but only reinitialize an existing variable


3) Trying to use a variable which is already released (free)

procedure TForm1.Button1.Click(Sender: TObject);
var
List := TStringList;
begin
List := TStringList.Create;
List.Add('Test');
List.Free
List.Add('Another Test');
end;

Using Menu merging also can create AV's, check out my reply about merging menus. I discovered it by accident.


S. van Els
SAvanEls@cq-link.sr
 
I'd guess that the form may alreay be created, and that when it tries to create it again you are getting the access violation, although I've never had this problem when creating forms, only when freeing them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top