• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

URGENT - Creating Forms - Access Violation Error

I'm having an Access Violation Error when creating a form.

I'm got a form --- 2Form  ... which is set to Available Forms:

From the Main Form I call it:

2Form:=T2Form.Create(self);
          2Form.Show;

It's not working...I get the Access Violation Error!

What am I don't whong please?

Thanks

ST3VO
0
ST3VO
Asked:
ST3VO
  • 15
  • 11
  • 8
  • +1
1 Solution
 
ziolkoCommented:
what's in constructor and/or OnCreate evenat handler of T2Form?

ziolko.
0
 
diniludCommented:
Can you tell onClose and OnCreate Event of T2Form
0
 
ziolkoCommented:
... also try this:
with T@Form.Create(nil) do
  Show;

ziolko.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
diniludCommented:
i think error with Constructor
0
 
ST3VOAuthor Commented:
I've put the form on the Project options Available forms.

I just need to call it!

0
 
ziolkoCommented:
... or maybe there are some components on T2Form that perform some activity when created.

but most important question is... is this AV thrown when creating or when showing form?:)

ziolko.
0
 
diniludCommented:
Which Line gives you error

2Form:=T2Form.Create(self);
or
2Form.Show;

0
 
ST3VOAuthor Commented:
AV?

What does AV stand for?

0
 
diniludCommented:
sorry i duplicate the question
0
 
ST3VOAuthor Commented:
Error Description:

exception number  : 1
exception class   : EAccessViolation
exception message : Access violation at address 0065707B in module...
0
 
ST3VOAuthor Commented:
2Form:=T2Form.Create(self);

Is giving me the error!

I took off Show and the error still came out!

0
 
diniludCommented:
What are the components you are using.
Can you show OnCreate  Event
0
 
ST3VOAuthor Commented:
There are lots of stuff called on 2Form's Create Event....Is that a problem?

It works when I set it as an Auto-Create form in the Project Options....what's the difference?

0
 
diniludCommented:
Put One break point and check OnCreate event is compliting or not
0
 
ST3VOAuthor Commented:
I put a break on the Create event of 2Form right after "begin" and I get a "Stream Read Error"

Any ideas?




0
 
Tomas Helgi JohannssonCommented:
   Hi!
>I've put the form on the Project options Available forms.

This means that the application creates the form at application startup.
Also I think you can't set the self keyword on a Form.Create. Use Application instead of Self.

Regards,
  Tomas Helgi
0
 
diniludCommented:
what are the components you are using?
0
 
Tomas Helgi JohannssonCommented:
I was wrong about the self keyword.
The problem is in the creation of the form in the application startup.
Try to take out the form from the Available list and se if the error still occurs.

Regards,
  Tomas Helgi
0
 
ST3VOAuthor Commented:
Yes...as I said before it I put the form on the Auto-create list it does work BUT I need to create this form at runtime.

0
 
ziolkoCommented:
>>I put the form on the Auto-create list it does work BUT I need to create this form at runtime

so remove 2Form from auto-create list:)

AV - stands for AcessViolation

>>I put a break on the Create event of 2Form right after "begin" and I get a "Stream Read Error"

it's caused by one of components that are on T2Form, remove them all and then place one-by-one to see which one is making trouble, or when AV pops-up see call stack to see where your problem is (only if you have source for all of your components)

ziolko.
0
 
ST3VOAuthor Commented:
Hmmm....there's too much coding involved for me to start removing everything....but I'll do some further testing!

>> so remove 2Form from auto-create list:)  I DID remove it from the auto-create list but that's when I get the problem occuring....

I basically need to be able to Create and destroy 2Form at runtime!
0
 
ziolkoCommented:
>>there's too much coding involved for me to start removing everything
start with non-standard VCL components

>>I'll do some further testing
thats part of creating apps... very big one:)

>>I basically need to be able to Create and destroy 2Form at runtime!
TForm and it's descendants are objects just like any other, give us some more info about T2Form it'll be easier for us to help you

ziolko.
0
 
ST3VOAuthor Commented:
Right....The Problem here is that it's Half Windows GUI and Half 3D Engine Programming...

When the From it Created it initializes the engine and loads all textures into memory...after that it rund on a loop that Renders every movement.

The Initilizing is done on OnCreate event...

What I could try and do is create a procedure that holds all the code from the OnCreate event and call the procedure on the OnShow event...

Would that make a difference?

Any opinions?

Thanks

- ST3VO
0
 
ST3VOAuthor Commented:
Note:

When the From it Created := When the Form is Created!

Sorry about the spelling :)
0
 
ziolkoCommented:
yup moving rendering to OnShow or even OnActivate is good idea and yes it makes difference.

ziolko
0
 
ST3VOAuthor Commented:
I'll give it a shot! :)
0
 
ziolkoCommented:
ok, good luck and for me it's time to sleep:)

ziolko.
0
 
ST3VOAuthor Commented:
GNite and thanks!!!
0
 
ziolkoCommented:
keep in mind that OnShow will be triggered each time form will change it's visiblity while OnCreate is called only once:)

ziolko.
0
 
diniludCommented:
any timer you are using.
0
 
ST3VOAuthor Commented:
Yes..there's 1 on 2Form and it is disabled when the form is closed BUT the one that's' getting to problem is Form1 which doesn't have a timer...Can there be a connection???

0
 
diniludCommented:
How you are Enableing the timer.


Set Timer1.Enable=False at design time.

at the end of OnCreate Event enable the timer

procedure T2Form.FormCreate(Sender: TObject);
begin
........
.......
Timer1.enabled:=true
end;
0
 
diniludCommented:
is my gussing is correct or not?
0
 
ST3VOAuthor Commented:
I checked and Yes that's the way I had it set!

0
 
diniludCommented:
put a break point in OnTimer event  and OnCreate Event and check.
0
 
ST3VOAuthor Commented:
I'll Try...Cheers!!!

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 15
  • 11
  • 8
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now