0

I have just inherited a project of code, and for some reason the executable it builds closes immediately after running. No one knows why this is, as apprently before the project was given to me it built and ran fine, but that's neither here nor there.

So with no idea how the project works, I have approached trying to debug this problem and whittled it down to the inclusion of this code:

CMyApp* pApp = (CMyApp*)AfxGetApp();
ShowWindow(SW_SHOW);
UpdateWindow();
if ( !pApp->RestoreWindowPos( this, MAINFRAME_POSITION_ENTRYNAME ) )
{
    MoveWindow( CRect(0,0,636,470) );
}

CRect rect(0,0,0,0);
GetClientRect(&rect);

int nWidth = pApp->GetProfileInt(_T("Settings"), QUEUESVIEW_SPLITTER_WIDTH, 200 );
m_wndSplitter.SetColumnInfo( 0, nWidth, 50 );
nWidth = pApp->GetProfileInt(_T("Settings"), EXTENSIONSVIEW_SPLITTER_WIDTH, 200 );
m_wndSplitter.SetColumnInfo( 1, nWidth, 50 );
m_wndSplitter.RecalcLayout();

Now, the window that loads is supposed to be split into four panels (two columns, two rows), and one can see that this clearly deals with the positioning and size of each. The problem is specifically caused by the last line m_wndSplitter.RecalcLayout(). If I comment out that single line, then the window loads fine, but all of the buttons are greyed out and if I try and resize the panels then the application crashes.

I am sorry I cannot be more detailed, but I am a stranger to this code myself. So my question is can anyone think of any circumstance where the inclusion of that line can cause this effect? Since there has been apparently no change to the code since it was last working I have nothing to go on besides what I have explained.

Thanks for any help anyone can offer!

Raiden616
  • 1,545
  • 3
  • 18
  • 42
  • 1
    Does it "crash" or Assert? Have you stepped through the RecalcLayout code in the debugger? – rrirower Aug 12 '14 at 12:44
  • If I try and debug it I get the following error: `Debug Assertion Failed! : :C\...\MFC\SRC\VIEWFORM.CPP, line 69`. If I go there then this is line 69: `if (!_AfxCheckDialogTemplate(m_lpszTemplateName, TRUE)) { ASSERT(FALSE); // invalid dialog template name PostNcDestroy(); // cleanup if Create fails too soon return FALSE; }` – Raiden616 Aug 12 '14 at 13:20
  • If I try and debug in release mode then it just does what I describe: loads and then immediately closes. – Raiden616 Aug 12 '14 at 13:23
  • It would appear that _AfxCheckDialogTemplate is failing. Debugging through that code should reveal why. In fact, it looks like you should see some sort of reason in the debug output window when it fails. – rrirower Aug 12 '14 at 13:43
  • Okay thanks I had a look at that. Sorry to be a pain; the error I can see in the output is : `"Dialog with IDD 0x008A must have the child style"`. Any idea what this means? – Raiden616 Aug 13 '14 at 09:50

0 Answers0