Click here to Skip to main content
15,897,187 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Build error with Visual C++ 2010 Pin
Falconapollo8-Jun-12 23:35
Falconapollo8-Jun-12 23:35 
AnswerRe: Build error with Visual C++ 2010 Pin
Stephen Hewitt10-Jun-12 1:17
Stephen Hewitt10-Jun-12 1:17 
QuestionIf CDialog is destroyed is UI CWinThread created While object was alive get destroyed as Well Pin
ForNow8-Jun-12 2:31
ForNow8-Jun-12 2:31 
AnswerRe: If CDialog is destroyed is UI CWinThread created While object was alive get destroyed as Well Pin
«_Superman_»8-Jun-12 2:46
professional«_Superman_»8-Jun-12 2:46 
GeneralRe: If CDialog is destroyed is UI CWinThread created While object was alive get destroyed as Well Pin
ForNow8-Jun-12 10:52
ForNow8-Jun-12 10:52 
GeneralRe: If CDialog is destroyed is UI CWinThread created While object was alive get destroyed as Well Pin
«_Superman_»8-Jun-12 16:11
professional«_Superman_»8-Jun-12 16:11 
AnswerRe: If CDialog is destroyed is UI CWinThread created While object was alive get destroyed as Well Pin
Albert Holguin8-Jun-12 4:33
professionalAlbert Holguin8-Jun-12 4:33 
QuestionCorruption of the heap. Why ? Pin
sdancer757-Jun-12 23:49
sdancer757-Jun-12 23:49 
Hi,

I have a CFormView derived class named CCatalogView. The Dialog Form was designed using the VS2008 resource editor.

I also created a new method inside the CCatalogView like the follow :

C++
CWnd* CCatalogView::CreatePane(CWnd* pParentWnd)
{
  if (GetSafeHwnd() == 0){
      VERIFY(Create(_T("CatalogView"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CXTPEmptyRect(), pParentWnd, NULL, 0));
				 
  }
  return this;
}


While I can show the content of this FormView inside a pane, when I exit from the application I get a memory error :
===================================
Windows has triggered a breakpoint in Test.exe.

This may be due to a corruption of the heap, which indicates a bug in Test.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while Test.exe has focus.

The output window may have more diagnostic information.

====================================

I have already found a solution, and that was to use the
create 
method, outside of the class CCatalogView as with the following code :


C++
m_pFormFrame = new CFrameWnd;
CCreateContext context;
context.m_pNewViewClass = RUNTIME_CLASS(CCatalogView);
context.m_pCurrentDoc = NULL;

m_pFormFrame->Create(NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CRect(0, 0, 0, 0), this, NULL, 0, &context);
 m_pFormFrame->SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
 pPane->Attach(m_pFormFrame);


Now the question is : Why the 1st part of the code corrupts the heap ? I suspect the the "Create" is constructed to the heap instead of the stack that I assume.

If that is true, can I modify the code to make it work ?

Best Regards,
sdancer75

AnswerRe: Corruption of the heap. Why ? Pin
Rolf Kristensen8-Jun-12 2:01
Rolf Kristensen8-Jun-12 2:01 
GeneralRe: Corruption of the heap. Why ? Pin
Erudite_Eric8-Jun-12 2:35
Erudite_Eric8-Jun-12 2:35 
GeneralRe: Corruption of the heap. Why ? Pin
sdancer758-Jun-12 6:02
sdancer758-Jun-12 6:02 
AnswerRe: Corruption of the heap. Why ? Pin
Aescleal8-Jun-12 3:00
Aescleal8-Jun-12 3:00 
GeneralRe: Corruption of the heap. Why ? Pin
sdancer758-Jun-12 6:03
sdancer758-Jun-12 6:03 
GeneralRe: Corruption of the heap. Why ? Pin
sdancer759-Jun-12 3:43
sdancer759-Jun-12 3:43 
GeneralRe: Corruption of the heap. Why ? Pin
Aescleal9-Jun-12 9:51
Aescleal9-Jun-12 9:51 
GeneralRe: Corruption of the heap. Why ? Pin
sdancer759-Jun-12 23:58
sdancer759-Jun-12 23:58 
GeneralRe: Corruption of the heap. Why ? Pin
sdancer7512-Jun-12 3:18
sdancer7512-Jun-12 3:18 
QuestionException when debugging Multithread Pin
ForNow7-Jun-12 19:04
ForNow7-Jun-12 19:04 
AnswerRe: Exception when debugging Multithread Pin
«_Superman_»7-Jun-12 19:15
professional«_Superman_»7-Jun-12 19:15 
GeneralRe: Exception when debugging Multithread Pin
ForNow7-Jun-12 23:53
ForNow7-Jun-12 23:53 
GeneralRe: Exception when debugging Multithread Pin
ForNow7-Jun-12 23:58
ForNow7-Jun-12 23:58 
AnswerRe: Exception when debugging Multithread Pin
Erudite_Eric7-Jun-12 20:34
Erudite_Eric7-Jun-12 20:34 
AnswerRe: Exception when debugging Multithread Pin
Richard MacCutchan7-Jun-12 21:53
mveRichard MacCutchan7-Jun-12 21:53 
GeneralRe: Exception when debugging Multithread Pin
Erudite_Eric7-Jun-12 23:35
Erudite_Eric7-Jun-12 23:35 
GeneralRe: Exception when debugging Multithread Pin
Richard MacCutchan8-Jun-12 0:19
mveRichard MacCutchan8-Jun-12 0:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.