CSplitterWnd:RecalcLayout causing window to close

360 views Asked by At

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!

0

There are 0 answers