Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I love this site! It's so nice to know that there are so many people out there who are willing to share their knowledge..."

Geography

Where in the world do Tek-Tips members come from?

Access violation at address .... in module 'Project1'.Read of address Helpful Member! 

MrEARTHSHAcKER (Programmer)
10 Feb 12 9:18
Hi,

I have created the application which consists of several windows.
Except first window, all others are dynamically created.
They are created from windows before them and deleted after it's own closing ( they're deleted by themselves by button click ).

There is a problem.
When I wish to delete window, I get this error message : "Access violation at address 0A1826C8 in module 'Project1'.Read of address DD57D84A".

And it doesn't appear always, which is confusing. And it doesn't affect to the application, just displays the error.

Example of creating and deleting the window:

(withing 1st window)
MyTab= new TMyTab(Application);
MyTab->Show();

(withing window that'll be deleted - MyTab)

delete MyTab;


Thanks a lot, I need this because I don't want my game to be insane memory allocator.  
Helpful Member!  2ffat (Programmer)
10 Feb 12 12:16
Hmmmm. Do I understand you correctly that the window is trying to delete itself? I've been taught that the calling form should do the deleting. For example:

CODE

// Delete old log files
    TLogClearForm *CLF = new TLogClearForm(Application);
    try
    {
        CLF->Show();
    }
    __finally
    {
        delete CLF;
    }

 

James P. Cottingham
I'm number 1,229!
I'm number 1,229!

MrEARTHSHAcKER (Programmer)
10 Feb 12 13:00
Can you explain me how I should call and delete window from single form?

Thanks.
MrEARTHSHAcKER (Programmer)
10 Feb 12 13:09
For example if I use this method:

 

CODE

TForm1 *Cosmos = new TForm1(this);
 Cosmos->ShowModal();
 delete Cosmos;

How is Cosmos going to dynamically call another form while it closes/hides itself? The same way?
If so, when will Cosmos be deleted? After last form closes?

I have one main form in game, and 5 other forms which are supposed to be called over previous one MainTab->FirstTab->SecondTab->ThirdTab->FourthTab->FifthTab->MainTab

Well how would it be done? All from Main form?

Thanks again.
MrEARTHSHAcKER (Programmer)
10 Feb 12 14:53
I made several experiments and I realized how does this work.

I do this

CODE

TForm1 *Cosmos = new TForm1(this);
 Cosmos->ShowModal();
 delete Cosmos;

And as long as the last form that has been called by Cosmos doesn't close, Cosmos won't be deleted (that was confusing me).

Practically I have the solution for my game, but what if I wished to destroy a form after it dynamically creates a new one and opens it?
I guess it is not possible since if I destroyed Cosmos, who'll delete the form it created.

Please if you find my conclusion wrong, point me to the spot I am wrong at.
Thanks!
2ffat (Programmer)
10 Feb 12 16:41

Quote:

I guess it is not possible since if I destroyed Cosmos, who'll delete the form it created.
Correct. One option, though, is to have the compiler create the form for you and have it destroy the forms. There are pluses and minuses to either option.
 

James P. Cottingham
I'm number 1,229!
I'm number 1,229!

MrEARTHSHAcKER (Programmer)
11 Feb 12 10:01
All right!

What about creating WindowsMediaPlayer withing dynamically created form?

I get the same error like above.

I tried several solutions like:
 1.OnDestroy of form -> delete WindowsMediaPlayer1;;
 2.OnClose -> like previous option;
 3.Do nothing, just play it;
 4.OnClose -> WindowsMediaPlayer->controls->stop();

And it seems like none of these do anything since I always get the same error, sooner or later.

And to make it more confusing, the MediaPlayer1 which is playing on first form ( pre-created ) isn't making problems.

I don't understand what to do, and I'm sure it's error because of MediaPlayer in dynamically created form because error doesn't appear unless I play it.

Thanks!
MrEARTHSHAcKER (Programmer)
11 Feb 12 10:08
And one more problem.

Not always, but sometimes automatically when I close dynamically created form, it gives me the following error:


CODE

Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 6947CCC6 in
module 'wmp.dll'. Read of adress 00000009. Process stopped. Use Step or Run to continue.

I guess this is dll for WindowsMediaPlayer, but what can lead to the error I get?

I made isolated project with this situation and I get same errors.

 
MrEARTHSHAcKER (Programmer)
11 Feb 12 10:12
( I hope I won't be accused for spamming :D )

When I get first of those 2 errors, BCB points me to Forms.hpp and to the line:

CODE

    /* TCustomForm.Destroy */ inline __fastcall virtual ~TForm(void) { }

 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close