OK here is your code for the CSecondView class. I just copied/pasted from your comment, so it is more readable:
#include "stdafx.h"
#include "SecondView.h"
#include "ComputerDoc.h"
#include <afxwin.h>
#include <afxcview.h>
IMPLEMENT_DYNCREATE(CSecondView, CFormView)
CSecondView::CSecondView()
: CFormView(CSecondView::IDD)
{
}
CSecondView::~CSecondView()
{
}
void CSecondView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CSecondView, CFormView)
ON_BN_CLICKED(IDC_Browse_File, &CSecondView::OnBnClickedBrowsefile)
END_MESSAGE_MAP()
BOOL CSecondView::PreCreateWindow(CREATESTRUCT& cs)
{
return CFormView::PreCreateWindow(cs);
}
void CSecondView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
#ifdef _DEBUG
void CSecondView::AssertValid() const
{
CFormView::AssertValid();
}
CComputerDoc* CSecondView::GetDocument() const
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CComputerDoc)));
return (CComputerDoc*)m_pDocument;
}
#ifndef _WIN32_WCE
void CSecondView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif
#endif //_DEBUG
void CSecondView::OnBnClickedBrowsefile()
{
}
Since it is quite empty, there is not much to check:
- Check that your Form ID is correct (maybe you deleted the resource by mistake from the
.rc file
and the ID number is still defined in
resource.h
?).
- The problem may come from the 2 lines you added in
OnInitialUpdate
. Actually, since they are the only 2 lines you added, the problem must come from those lines...
Maybe the parent form is not fully initialized at that time and the call to
RecalcLayout
is too early. Try to remove them.