Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

URGENT - Creating Forms - Access Violation Error

Posted on 2007-08-01
36
Medium Priority
?
233 Views
Last Modified: 2010-04-05
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
Comment
Question by:ST3VO
  • 15
  • 11
  • 8
  • +1
36 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 19608986
what's in constructor and/or OnCreate evenat handler of T2Form?

ziolko.
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19608993
Can you tell onClose and OnCreate Event of T2Form
0
 
LVL 21

Expert Comment

by:ziolko
ID: 19608998
... also try this:
with T@Form.Create(nil) do
  Show;

ziolko.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:dinilud
ID: 19609013
i think error with Constructor
0
 

Author Comment

by:ST3VO
ID: 19609038
I've put the form on the Project options Available forms.

I just need to call it!

0
 
LVL 21

Expert Comment

by:ziolko
ID: 19609053
... 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
 
LVL 10

Expert Comment

by:dinilud
ID: 19609073
Which Line gives you error

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

0
 

Author Comment

by:ST3VO
ID: 19609077
AV?

What does AV stand for?

0
 
LVL 10

Expert Comment

by:dinilud
ID: 19609079
sorry i duplicate the question
0
 

Author Comment

by:ST3VO
ID: 19609090
Error Description:

exception number  : 1
exception class   : EAccessViolation
exception message : Access violation at address 0065707B in module...
0
 

Author Comment

by:ST3VO
ID: 19609112
2Form:=T2Form.Create(self);

Is giving me the error!

I took off Show and the error still came out!

0
 
LVL 10

Expert Comment

by:dinilud
ID: 19609140
What are the components you are using.
Can you show OnCreate  Event
0
 

Author Comment

by:ST3VO
ID: 19609165
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
 
LVL 10

Expert Comment

by:dinilud
ID: 19609284
Put One break point and check OnCreate event is compliting or not
0
 

Author Comment

by:ST3VO
ID: 19609436
I put a break on the Create event of 2Form right after "begin" and I get a "Stream Read Error"

Any ideas?




0
 
LVL 26

Expert Comment

by:Tomas Helgi Johannsson
ID: 19609515
   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
 
LVL 10

Expert Comment

by:dinilud
ID: 19609528
what are the components you are using?
0
 
LVL 26

Expert Comment

by:Tomas Helgi Johannsson
ID: 19609547
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
 

Author Comment

by:ST3VO
ID: 19609588
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
 
LVL 21

Expert Comment

by:ziolko
ID: 19610473
>>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
 

Author Comment

by:ST3VO
ID: 19610995
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
 
LVL 21

Expert Comment

by:ziolko
ID: 19612226
>>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
 

Author Comment

by:ST3VO
ID: 19612289
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
 

Author Comment

by:ST3VO
ID: 19612306
Note:

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

Sorry about the spelling :)
0
 
LVL 21

Expert Comment

by:ziolko
ID: 19612340
yup moving rendering to OnShow or even OnActivate is good idea and yes it makes difference.

ziolko
0
 

Author Comment

by:ST3VO
ID: 19612379
I'll give it a shot! :)
0
 
LVL 21

Expert Comment

by:ziolko
ID: 19612411
ok, good luck and for me it's time to sleep:)

ziolko.
0
 

Author Comment

by:ST3VO
ID: 19612576
GNite and thanks!!!
0
 
LVL 21

Expert Comment

by:ziolko
ID: 19614908
keep in mind that OnShow will be triggered each time form will change it's visiblity while OnCreate is called only once:)

ziolko.
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19615294
any timer you are using.
0
 

Author Comment

by:ST3VO
ID: 19615355
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
 
LVL 10

Accepted Solution

by:
dinilud earned 1500 total points
ID: 19615441
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
 
LVL 10

Expert Comment

by:dinilud
ID: 19616049
is my gussing is correct or not?
0
 

Author Comment

by:ST3VO
ID: 19616162
I checked and Yes that's the way I had it set!

0
 
LVL 10

Expert Comment

by:dinilud
ID: 19616238
put a break point in OnTimer event  and OnCreate Event and check.
0
 

Author Comment

by:ST3VO
ID: 19616245
I'll Try...Cheers!!!

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question