📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "DFYSimulator.h"
#include "OutputWindow.h"
#include "MemoryDlg.h"
#include "StackDlg.h"
#include "VariableDlg.h"
#include "RegisterDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT, OnUpdateViewOutput)
ON_WM_SIZE()
ON_WM_ACTIVATE()
ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput)
ON_WM_CLOSE()
//}}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()
{
m_pWndOutputWindow=NULL;
m_pMemoryDlg=NULL;
m_pStackDlg=NULL;
m_pVariableDlg=NULL;
m_pRegisterDlg=NULL;
m_pIRQDlg=NULL;
m_bShowOutputWindow=FALSE;
}
CMainFrame::~CMainFrame()
{
m_pWndOutputWindow=NULL;
m_pMemoryDlg=NULL;
m_pStackDlg=NULL;
m_pVariableDlg=NULL;
m_pRegisterDlg=NULL;
m_bShowOutputWindow=FALSE;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
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
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.x=0;
cs.y=0;
cs.cx=1024;
cs.cy=768;
if( !CMDIFrameWnd::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
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnViewOutput()
{
m_bShowOutputWindow=!m_bShowOutputWindow;
//First create OutputWindow
if(!m_pWndOutputWindow)
{
m_pWndOutputWindow=new COutputWindow();
if(!m_pWndOutputWindow)
{
MessageBox("not enough memory !","Fatal Error !",MB_OK);
return;
}
CRect clientRect;
if(!m_pWndOutputWindow->Create(0,NULL,WS_CHILD|WS_DLGFRAME|WS_OVERLAPPED\
|WS_HSCROLL|WS_TABSTOP|WS_VSCROLL,clientRect,this,\
NULL))
{
MessageBox("Failed to create Output Window !","Error!");
return;
}
GetClientRect(&clientRect);
m_pWndOutputWindow->SetWindowPos(NULL,clientRect.left,\
clientRect.bottom-160,clientRect.Width(),\
120,SWP_FRAMECHANGED|SWP_NOACTIVATE);
m_bShowOutputWindow=TRUE;
}
//judge the select state
//show the outputwindow if the menu is checked ,otherwise hide it
if(m_bShowOutputWindow)
{
m_pWndOutputWindow->ShowWindow(SW_SHOW);
m_pWndOutputWindow->UpdateWindow();
}
else
{
m_pWndOutputWindow->DestroyWindow();
m_pWndOutputWindow=NULL;
}
}
void CMainFrame::OnDestroy()
{
CMDIFrameWnd::OnDestroy();
if(m_pWndOutputWindow)delete m_pWndOutputWindow;
if(m_pMemoryDlg)delete m_pMemoryDlg;
if(m_pStackDlg)delete m_pStackDlg;
if(m_pVariableDlg)delete m_pVariableDlg;
if(m_pRegisterDlg)delete m_pRegisterDlg;
}
void CMainFrame::OnUpdateViewOutput(CCmdUI* pCmdUI)
{
if(m_bShowOutputWindow)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CMDIFrameWnd::OnSize(nType, cx, cy);
if(m_pWndOutputWindow)//if the outputwindow had been created
{
CRect clientRect;
GetClientRect(&clientRect);
m_pWndOutputWindow->SetWindowPos(NULL,clientRect.left,\
clientRect.bottom-160,clientRect.Width(),\
120,SWP_FRAMECHANGED|SWP_NOACTIVATE);
}
}
void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CMDIFrameWnd::OnActivate(nState, pWndOther, bMinimized);
if(!m_pWndOutputWindow)//if the outputwindow haven't been created,
//create a outputwindow and display it
{
m_pWndOutputWindow=new COutputWindow();
if(!m_pWndOutputWindow)
{
MessageBox("not enough memory !","Fatal error!");
return;
}
CRect clientRect;
if(!m_pWndOutputWindow->Create(0,NULL,WS_CHILD|WS_DLGFRAME|WS_OVERLAPPED\
|WS_HSCROLL|WS_TABSTOP|WS_VSCROLL,clientRect,this,\
NULL))
{
MessageBox("Failed to create Output window");
return;
}
GetClientRect(&clientRect);
m_pWndOutputWindow->SetWindowPos(NULL,clientRect.left,\
clientRect.bottom-160,clientRect.Width(),\
120,SWP_FRAMECHANGED|SWP_NOACTIVATE);
m_bShowOutputWindow=TRUE;
m_pWndOutputWindow->ShowWindow(SW_SHOW);
m_pWndOutputWindow->UpdateWindow();
}
}
void CMainFrame::OnClose()
{
CDFYSimulatorApp* pApp=(CDFYSimulatorApp*)AfxGetApp();
pApp->SetExeFrameState(FALSE);//means the excute frame is not exist
CMDIFrameWnd::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -