📄 简易编程器.cpp
字号:
// 简易编程器.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "简易编程器.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "简易编程器Doc.h"
#include "HexEditView.h"
#include "filedia\LastFileDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyApp
char CurChip[64];
CString m_strAppPath;
CMainFrame* pMainFrame;
BOOL m_bWin98;
char skin[20];
UINT m_LockBits;
BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
//{{AFX_MSG_MAP(CMyApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_OPEN, OnFileOpen)
//}}AFX_MSG_MAP
// Standard file based document commands
//ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
//ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
//ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyApp construction
CMyApp::CMyApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMyApp object
CMyApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMyApp initialization
BOOL CMyApp::InitInstance()
{
if(!m_ss.Create("简易编程器"))
return FALSE;
OSVERSIONINFO winInfo;
winInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(&winInfo);
TRACE("winInfo.dwMajorVersion:%d\n",winInfo.dwMajorVersion);
if(winInfo.dwMajorVersion==4)//是win98,win me
m_bWin98=TRUE;
else
m_bWin98=FALSE;
char strPath[200];//保存应用程序所在的目录
memset(strPath,0,200);
GetModuleFileName(m_hInstance,strPath,200);
for(int n=99;n>0;n--)
{
if(strPath[n]=='\\')
break;
}
memset(&strPath[n+1],0,198-n);
m_strAppPath=strPath;
CString strEasyIspIni;
strEasyIspIni.Format("%s%s",m_strAppPath,"简易编程器.ini");
//从简易编程器.ini文件获得配置信息
GetPrivateProfileString( "芯片","当前芯片","NULL",(char*)(LPCTSTR)CurChip,40,strEasyIspIni);
m_LockBits=GetPrivateProfileInt( "芯片","加密位",0,strEasyIspIni);
GetPrivateProfileString( "皮肤","当前皮肤","CORONA",skin,40,strEasyIspIni);
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
//////////////////////////////////////
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_MYTYPE,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CHexEditView));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
VERIFY( 1 == InitSkinMagicLib(AfxGetInstanceHandle(), "BIN" ,
NULL,
NULL ) );
VERIFY( 1 == LoadSkinFromResource( AfxGetInstanceHandle() , skin ,"SKINMAGIC") );
VERIFY( 1 == SetWindowSkin( m_pMainWnd->m_hWnd , "MainFrame" ));
VERIFY( 1 == SetDialogSkin( "Dialog" ) );
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CMyApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CMyApp message handlers
void CMyApp::OnFileOpen()
{
CString s;
s="所有程序文件|*.HEX;*.BIN;*.S;*.S2;*.S19;*.ROM;*.EEP|十六进制文件";
s+="*.HEX|*.HEX|二进制文件 *.BIN|*.BIN|ROM文件 *.ROM|*.ROM|EEPROM 文件";
s+="*.EEP|*.EEP|Motorola S Record *.S|*.S|Motorola S 16Bit *.S19|";
s+="*.S19|Motorola S 24Bit *.S2|*.S2|Motorola S 32Bit *.S3|*.S3|";
s+="所有文件|*.*||";
static CLastFileDialog m_FileDlg(TRUE,"bin",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,s);
if(m_FileDlg.DoModal()==IDOK)
{
s=m_FileDlg.GetLastFileName();
OpenDocumentFile(s);
}
}
void CMyApp::NewDoc(char *buf,ULONG Size)
{
OnFileNew();
CHexEditView *view;
view=(CHexEditView *)pMainFrame->GetActiveFrame()->GetActiveView();
view->SetText(buf,Size);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -