mainfrm.cpp
来自「vc编程实现bp神经网络」· C++ 代码 · 共 224 行
CPP
224 行
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "OptSoftWare.h"
#include "MainFrm.h"
#include "NNMod.h"
#include "GAOpt.h"
#include "LinearRegressionFRMV.h"
#include "VariableInfoDlg.h"
#include "UserDataDlg.h"
#include "Splash.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_NNMod, OnNNMod)
ON_UPDATE_COMMAND_UI(ID_NNMod, OnUpdateNNMod)
ON_COMMAND(ID_GAOpt, OnGAOpt)
// ON_COMMAND(ID_DEFVARIABLE, OnDefvariable)
ON_COMMAND(ID_LINEREGRESSION, OnLineregression)
ON_COMMAND(ID_VARIABLEDEF, OnVariabledef)
ON_COMMAND(ID_INFO, OnInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// CG: The following line was added by the Splash Screen component. CSplashWnd::ShowSplashScreen(this);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
HWND CMainFrame::ReplaceView(CRuntimeClass *pViewClass)
{
CCreateContext context;
CView * pCurrentView;
if ((pCurrentView=GetActiveView())==NULL)
return 0;
if ((pCurrentView->IsKindOf(pViewClass))==TRUE)
return pCurrentView->m_hWnd;
CDocument * pDoc= pCurrentView->GetDocument();
BOOL bAutoDelete=pDoc->m_bAutoDelete;
pDoc->m_bAutoDelete=FALSE;
pCurrentView->DestroyWindow();
pDoc->m_bAutoDelete=bAutoDelete;
context.m_pNewViewClass=pViewClass;
context.m_pCurrentDoc=pDoc;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=this;
CView * pNewView = (CView *) pViewClass->CreateObject();
if (pNewView == NULL)
{
TRACE1("Warning: Dynamic create of view type %Fs failed\n", pViewClass->m_lpszClassName);
return 0;
}
if (!pNewView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0,0,0,0), this, AFX_IDW_PANE_FIRST,&context))
{
TRACE0("Warning: couldn't create view for frame\n");
return 0; // Programmer can assume 0 return value
// from this function means that there
// isn't a view.
}
RecalcLayout();
SetActiveView(pNewView);
pNewView->UpdateWindow();
return pNewView->m_hWnd;
}
void CMainFrame::OnNNMod()
{
// TODO: Add your command handler code here
CRuntimeClass* pRuntimeClass=RUNTIME_CLASS(CNNMod);
if(ReplaceView(pRuntimeClass)==0)
{
AfxMessageBox("您已进入了神经网络建模界面!");
}
(AfxGetMainWnd())->ShowWindow(SW_SHOWMAXIMIZED);
show_flags=0;
CFrameWnd* pFrame=(CFrameWnd*)AfxGetMainWnd();
::PostMessage(pFrame->m_hWnd,ID_NNMod,0,0);
}
void CMainFrame::OnUpdateNNMod(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
// if (show_flags==0)
// pCmdUI->Enable(FALSE);
// else
// pCmdUI->Enable(TRUE);
}
void CMainFrame::OnGAOpt()
{
// TODO: Add your command handler code here
CRuntimeClass* pRuntimeClass=RUNTIME_CLASS(CGAOpt);
if(ReplaceView(pRuntimeClass)==0)
{
}
(AfxGetMainWnd())->ShowWindow(SW_SHOWMAXIMIZED);
show_flags=0;
CFrameWnd* pFrame=(CFrameWnd*)AfxGetMainWnd();
::PostMessage(pFrame->m_hWnd,ID_GAOpt,0,0);
}
void CMainFrame::OnLineregression()
{
// TODO: Add your command handler code here
CRuntimeClass* pRuntimeClass=RUNTIME_CLASS(CLinearRegressionFRMV);
ReplaceView(pRuntimeClass);
(AfxGetMainWnd())->ShowWindow(SW_SHOWMAXIMIZED);
show_flags=0;
CFrameWnd* pFrame=(CFrameWnd*)AfxGetMainWnd();
::PostMessage(pFrame->m_hWnd,ID_LINEREGRESSION,0,0);
}
void CMainFrame::OnVariabledef()
{
// TODO: Add your command handler code here
CVariableInfoDlg VariableInfoDlg;
VariableInfoDlg.DoModal();
}
void CMainFrame::OnInfo()
{
// TODO: Add your command handler code here
CUserDataDlg UserDataDlg;
UserDataDlg.DoModal();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?