CFormivew create casuing Heap Corruption on exit.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: CFormivew create casuing Heap Corruption on exit.

  1. #1
    Join Date
    Dec 2009
    Posts
    3

    CFormivew create casuing Heap Corruption on exit.

    Good Morning,

    I have created a SDI with the Wizard in VS2008 using the MFC libraries and it is preloaded with the 'visual studio' dockable windows. What I am looking to do replace the dockable windows that were provided with my own. And it is going rather well, almost.

    I added a formview dialog resource with the controls (widgets) I want on the screen, and used the class wizard to add the CFormView class to the resource. Now I have created a CDockablePane to hold onto the form in the main frame. After bumbling around for a little bit I got the pane attached and drawing the form in the main frame. The problem comes when I exit program. I get a error window that says that there is corruption in the heap.

    I have narrowed it down the creation of the form. I have the form declared as a member of the dockablepane, and isn't dynamically allocated, so it is created on the heap.

    I am creating it with:
    // here is teh test. Create the view in the pane.
    if (!m_wndTtest.Create(NULL,NULL,LBS_NOINTEGRALHEIGHT|WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL,rectDummy,this, 1,NULL)){
    TRACE0("Failed to create secondary window\n");
    return -1;
    }

    If I comment this out, then the heap error goes away.

    I know that I am missing something REALLY basic here but I can't for the life of me find it and any help would be appreciated.

    A little background on me. I was, until very recently, a Linux programmer that used QT for the vast majority of his software development. I am REALLY new to VS2008, and microsoft programming as a whole and it is very weird and confusing for me.

    Cheers,
    Wayne

  2. #2
    Join Date
    Apr 1999
    Posts
    27,426

    Re: CFormivew create casuing Heap Corruption on exit.

    Quote Originally Posted by Cmorhead View Post
    After bumbling around for a little bit
    Was the program working correctly before you attempted to make changes? Since you are not familiar with MFC, did you compile and test frequently, starting from when the wizard created a skeleton application?

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; December 18th, 2009 at 12:11 PM.

  3. #3
    Join Date
    Dec 2009
    Posts
    3

    Re: CFormivew create casuing Heap Corruption on exit.

    Before I added the pane and frame the program was working without any heap corruption.

    The program as a whole works fine, even with my new pane/form in it. The problem comes when I exit the program; I get a heap corruption error. Which I take to means that some memory somewhere was being deallocated more then once.

    When the create function isn't called there is no heap corruption, and also no form.

    I am not doing a good job

  4. #4
    Join Date
    Apr 1999
    Posts
    27,426

    Re: CFormivew create casuing Heap Corruption on exit.

    Quote Originally Posted by Cmorhead View Post
    Before I added the pane and frame the program was working without any heap corruption.

    The program as a whole works fine, even with my new pane/form in it. The problem comes when I exit the program; I get a heap corruption error.
    I'm no MFC expert, but from what I do know, MFC is very particular in where, when, and who deallocates MFC objects.

    If you set a breakpoint in the destructor of each of these objects, is it called for the same instance more than once? Again, I am no expert, but if I were to diagnose this with little knowledge of MFC, that is where I would start.

    Regards,

    Paul McKenzie

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center