CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    Destructor never called - help !

    My CMainFrm class derived from CFrameWnd is created in the InitInstance() func. with 'new'. When i later on in the app by a keydown calls PostQuitMessage(0) the app exits but the CMainFrm class destructor never is called.. Why ?. Should all setupcode and cleanup ( except wnd creation ) be made in other funcs.??



  2. #2
    Join Date
    Jan 2000
    Posts
    7

    Re: Destructor never called - help !

    Hi!

    This is the main trouble with dynamic allocation. Since you created the object with new, you are responsible for deallocating (delete) it yourself, for example in OnDestroy(), or some destructor.

    Hope this helps!


  3. #3
    Guest

    Re: Destructor never called - help !

    Forget OnDestroy() - you should override PostNcDestroy() and insert

    delete this;


    Scott Tunstall
    [email protected]


  4. #4
    Join Date
    May 1999
    Posts
    13

    Re: Destructor never called - help !

    Excellent !!!

    This solved my memoryleak problem coz now my cleanup functions got called.. THANXXX!!!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured