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

Thread: DestroyWindow and delete, different memory cleanup?

  1. #1
    Join Date
    Mar 2010
    Posts
    74

    DestroyWindow and delete, different memory cleanup?

    I have class A derived from CDialog.

    I have create and destroy objects of A many times I see different memory available after

    delete a; ( a = new A.....)
    and a->DestroyWindow();
    Looking like DestroyWindow doesnot free memory.

    Is it correct behaviour?
    Thanks

  2. #2
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: DestroyWindow and delete, different memory cleanup?

    Yes it is.

    DestroyWindow destroys the window (a MS Windows (TM) ) object. But it won't destroy the corresponding MFC object.

    On the other side delete a will destroy both because the destructor of CDialog will call DestroyWindow.

    Everytime think: Each new needs a corresponding delete.

    With regards
    Programartist
    Last edited by ProgramArtist; December 8th, 2010 at 07:41 AM. Reason: typo

  3. #3
    Join Date
    Mar 2010
    Posts
    74

    Re: DestroyWindow and delete, different memory cleanup?

    Thanks ProgramArtist
    it is Ok.
    delete is enough .

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)