⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 模拟了tec2000的所有功能
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "TEC2000.h"
#include"uasm.h"
#include "MainFrm.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)
	ON_COMMAND_EX(CG_ID_VIEW_CSTATUSDLG, OnBarCheck)
	ON_UPDATE_COMMAND_UI(CG_ID_VIEW_CSTATUSDLG, OnUpdateControlBarMenu)
	ON_COMMAND_EX(CG_ID_VIEW_VIEWHELPDLG, OnBarCheck)
	ON_UPDATE_COMMAND_UI(CG_ID_VIEW_VIEWHELPDLG, OnUpdateControlBarMenu)
	ON_COMMAND_EX(CG_ID_VIEW_VIEWREGISTERDLG, OnBarCheck)
	ON_UPDATE_COMMAND_UI(CG_ID_VIEW_VIEWREGISTERDLG, OnUpdateControlBarMenu)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_UNASM, OnUnasm)
	ON_COMMAND(ID_CHANGESKIN, OnChangeskin)
	ON_COMMAND(ID_MODE_ONLINE, OnModeOnline)
	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()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::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);

	// TODO: Add a menu item that will toggle the visibility of the	// dialog bar named "ViewRegisterDlg":	//   1. In ResourceView, open the menu resource that is used by	//      the CMainFrame class	//   2. Select the View submenu	//   3. Double-click on the blank item at the bottom of the submenu	//   4. Assign the new item an ID: CG_ID_VIEW_VIEWREGISTERDLG	//   5. Assign the item a Caption: ViewRegisterDlg	// TODO: Change the value of CG_ID_VIEW_VIEWREGISTERDLG to an appropriate value:	//   1. Open the file resource.h	// CG: The following block was inserted by the 'Dialog Bar' component	{		// Initialize dialog bar m_wndViewRegisterDlg		if (!m_wndViewRegisterDlg.Create(this, CG_IDD_VIEWREGISTERDLG,			CBRS_RIGHT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,			CG_ID_VIEW_VIEWREGISTERDLG))		{			TRACE0("Failed to create dialog bar m_wndViewRegisterDlg\n");			return -1;		// fail to create		}	}
	// TODO: Add a menu item that will toggle the visibility of the	// dialog bar named "ViewHelpDlg":	//   1. In ResourceView, open the menu resource that is used by	//      the CMainFrame class	//   2. Select the View submenu	//   3. Double-click on the blank item at the bottom of the submenu	//   4. Assign the new item an ID: CG_ID_VIEW_VIEWHELPDLG	//   5. Assign the item a Caption: ViewHelpDlg	// TODO: Change the value of CG_ID_VIEW_VIEWHELPDLG to an appropriate value:	//   1. Open the file resource.h	// CG: The following block was inserted by the 'Dialog Bar' component	{		// Initialize dialog bar m_wndViewHelpDlg		if (!m_wndViewHelpDlg.Create(this, CG_IDD_VIEWHELPDLG,			CBRS_LEFT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,			CG_ID_VIEW_VIEWHELPDLG))		{			TRACE0("Failed to create dialog bar m_wndViewHelpDlg\n");			return -1;		// fail to create		}	}
	// CG: The following line was added by the Splash Screen component.	//CSplashWnd::ShowSplashScreen(this);
	// TODO: Add a menu item that will toggle the visibility of the	// dialog bar named "CStatusDlg":	//   1. In ResourceView, open the menu resource that is used by	//      the CMainFrame class	//   2. Select the View submenu	//   3. Double-click on the blank item at the bottom of the submenu	//   4. Assign the new item an ID: CG_ID_VIEW_CSTATUSDLG	//   5. Assign the item a Caption: CStatusDlg	// TODO: Change the value of CG_ID_VIEW_CSTATUSDLG to an appropriate value:	//   1. Open the file resource.h	// CG: The following block was inserted by the 'Dialog Bar' component	{		// Initialize dialog bar m_wndCStatusDlg		if (!m_wndCStatusDlg.Create(this, CG_IDD_CSTATUSDLG,			CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,			CG_ID_VIEW_CSTATUSDLG))		{			TRACE0("Failed to create dialog bar m_wndCStatusDlg\n");			return -1;		// fail to create		}	}
	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
    UINT ClassStyle=CS_VREDRAW|CS_HREDRAW;
	cs.lpszName=" TEC2000模拟器";
	cs.style=cs.style&(~FWS_ADDTOTITLE);
    cs.lpszClass = AfxRegisterWndClass(ClassStyle,AfxGetApp()->LoadStandardCursor(IDC_ARROW), (HBRUSH)(COLOR_WINDOW+1),//for brush
	AfxGetApp()->LoadIcon(IDR_MAINFRAME));
	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


void CMainFrame::OnUnasm() 
{
	char *FilterStr = "COD Files (*.cod)|*.cod; *.cod|All Files (*.*)|*.*||";
	CFileDialog OpenFile(TRUE, ".cod", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,FilterStr, NULL); 
	CString OpenFileName;
	if (OpenFile.DoModal() == IDOK)
		OpenFileName = OpenFile.GetPathName();
	else return;
	
}

void CMainFrame::OnChangeskin() 
{
	char strExt[]= "SkinMagic Files(*.smf)|*.smf||";
    CFileDialog dlg( TRUE, "*.smf", "*.smf" , OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT
             , strExt ,  this );
    if( dlg.DoModal() == IDOK  )
	{
        LoadSkinFile( (char*)(LPCSTR)(dlg.GetPathName()) );
	}

	
}

void CMainFrame::OnModeOnline() 
{
	char buffer[100];
	GetCurrentDirectory(100,buffer);
	int len=strlen(buffer);
	buffer[len++]='\\';
	buffer[len++]='M';
	buffer[len++]='o';
	buffer[len++]='n';
	buffer[len++]='i';
	buffer[len++]='t';
	buffer[len++]='o';
	buffer[len++]='r';
	buffer[len++]='.';
	buffer[len++]='e';
	buffer[len++]='x';
	buffer[len++]='e';
	buffer[len]='\0';   
	ShellExecute(NULL , "open",buffer,NULL,NULL,SW_SHOW);
}

void CMainFrame::OnClose() 
{
//	ResetEvent(m_pMCompileDlg.m_wndScriptEdit.m_hEvent);// TODO: Add your message handler code here and/or call default
	
	CFrameWnd::OnClose();
}
/*
void CMainFrame::OnLoadcod() 
{
	char *FilterStr = "COD Files (*.cod)|*.cod; *.cod|All Files (*.*)|*.*||";
	CFileDialog OpenFile(TRUE, ".cod", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,FilterStr, NULL); 
	
	if (OpenFile.DoModal() == IDOK)
		m_pUnAsmDlg->OpenFileName = OpenFile.GetPathName();
	else return;


	char buffer1[300];
	strcpy(buffer1,OpenFileName);
	m_pUnAsmDlg->usm.outcod(buffer1);

    CString add=m_pUnAsmDlg->OpenFileName;
	UINT lengthadd=add.GetLength();
	add.SetAt(lengthadd-4,'.');
	add.SetAt(lengthadd-3,'t');
	add.SetAt(lengthadd-2,'x');
	add.SetAt(lengthadd-1,'t');
	
	strcpy(buffer1,add);
//	AfxMessageBox(buffer1);

	CString context;
	char buffer[256];
//	
    ifstream in_file(buffer1,ios::in);
	while(in_file.eof()==0){
    	in_file.getline(buffer,256,'\n');
    	context+=buffer;
		context+="\r\n";
	}
	m_pUnAsmDlg->m_ctrlEditCod.SetWindowText(context);


	context.Empty();
	add=OpenFileName;
   	lengthadd=add.GetLength();
   	add.SetAt(lengthadd-4,'#');
   	add.SetAt(lengthadd-3,'.');
   	add.SetAt(lengthadd-2,'a');
   	add.SetAt(lengthadd-1,'s');
	add+="m";
	strcpy(buffer1,add);

	ifstream in_file1(buffer1,ios::in);
   	while(in_file1.eof()==0){
       	in_file1.getline(buffer,256,'\n');
       	context+=buffer;
	   	context+="\r\n";
	}
   	m_pUnAsmDlg->m_ctrlEditPw.SetWindowText(context);



	CString context="jfklas";
//	m_pUnAsmDlg->m_ctrlEditPw.SetWindowText(context);

}
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -