📄 ezmr.cpp
字号:
////////////////////////////////////////////////////////////////////////////////
// EzMr.cpp : Defines the class behaviors for the application (app main).
// $Header: /USB/Util/EzMr/EzMr.cpp 26 6/27/01 3:28p Tpm $
// Copyright (c) 2000 Cypress Semiconductor. May not be reproduced without permission.
// See the EzUsb Developer's Kit license agreement for more details.
////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "EzMr.h"
#include "MainFrm.h"
#include "EzMrFrm.h" //TPMDo: Add ToolBar manually
#include "EzMrDoc.h"
#include "EzMrView.h"
#include "HxEdFrm.h" //TPMDo: Add HxEd manually
#include "HxEdDoc.h"
#include "HxEdView.h"
#include "RTreDoc.h"
#include "RTreView.h"
#include "splitter.h"
#include "main.h" //for bOpenDriver
#include "DlgTest.h"
#include "DlgTargetSel.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEzMrApp
BEGIN_MESSAGE_MAP(CEzMrApp, CWinApp)
//{{AFX_MSG_MAP(CEzMrApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_FILE_OPEN_ALL_DEVS, OnFileOpenAllDevs)
ON_COMMAND(ID_FILE_GPIFTOOL, OnFileGpifTool)
ON_COMMAND(ID_FILE_UPDATE_ALL_DEVS, OnFileUpdateAllDevs)
ON_COMMAND(ID_HELP_GOTOUPDATEONWEB, OnHelpGotoupdateonweb)
ON_COMMAND(ID_HELP_CONTACTANCHORCHIPS, OnHelpContactanchorchips)
ON_COMMAND(ID_HELP_CONTENTSANDTUTORIAL, OnHelpContentsandtutorial)
ON_COMMAND(ID_HELP_CONTROLPANELUSERGUIDE, OnHelpControlpaneluserguide)
ON_UPDATE_COMMAND_UI(ID_FILE_GPIFTOOL, OnUpdateFileGpiftool)
ON_COMMAND(ID_OPTIONS_FX2, OnOptionsFx2)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CEzMrApp construction
CEzMrApp::CEzMrApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CEzMrApp object
CEzMrApp theApp;
//#include "EzMrGlob.h"
/////////////////////////////////////////////////////////////////////////////
// CEzMrApp initialization
BOOL CEzMrApp::InitInstance()
{
CDlgTargetSel dlg;
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
#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.
SetRegistryKey(_T("Cypress"));
m_nVerbose = 1;
m_nPopUpOps = 0;
m_bThreaded = 1;
m_nMaxOpsPending = 3;
m_nAutoHoldRun = 1;
m_nPollPorts = 0;
m_nQuietMode = 0; //don't supress popups
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// initialize application wide resource strings
m_strPathExe = __targv[0]; // handy path to exe
m_strPathExe = theApp.m_strPathExe.Left(theApp.m_strPathExe.ReverseFind('\\'));
if(theApp.m_strPathExe.Find("Bin") != -1)
m_strPathUSBRoot = theApp.m_strPathExe.Left(theApp.m_strPathExe.Find("\\Bin"));
else if(theApp.m_strPathExe.Find("Util") != -1)
m_strPathUSBRoot = theApp.m_strPathExe.Left(theApp.m_strPathExe.Find("\\Util"));
else
m_strPathUSBRoot = "C:\\Cypress\\Usb";
m_strHexEdFileName = "\\0SRV1\\Users\\Eng\tpm\\dld\\hexwrk\\hexwrk\\hworks32.exe";
m_strLoopTestFileName = m_strPathUSBRoot + "\\Examples\\Ezusb\\ep_pair\\ep_pair.hex";
// initialize application persistant settings
// theApp.m_strMonFileName = theApp.GetProfileString("Settings", "m_strMonFileName",
// m_strPathUSBRoot + "\\Target\\Monitor\\mon-ext-sio1-c0.hex");
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
m_pUSBDocTemplate = new CMultiDocTemplate(
IDR_EZMRTYPE,
RUNTIME_CLASS(CEzMrDoc),
//RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CEzMrFrame), // custom MDI child frame
RUNTIME_CLASS(CEzMrView));
m_pUSBDocTemplate->SetContainerInfo(IDR_EZMRTYPE_CNTR_IP);
AddDocTemplate(m_pUSBDocTemplate);
m_pHxEdDocTemplate = new CMultiDocTemplate(
IDR_HXEDTYPE,
RUNTIME_CLASS(CHxEdDoc),
RUNTIME_CLASS(CHxEdFrm), // custom MDI child frame
RUNTIME_CLASS(CHxEdView));
m_pHxEdDocTemplate->SetContainerInfo(IDR_EZMRTYPE_CNTR_IP);
AddDocTemplate(m_pHxEdDocTemplate);
m_pUsbDevsTemplate = new CMultiDocTemplate(
IDR_USBDTYPE,
RUNTIME_CLASS(CRTreDoc),
RUNTIME_CLASS(CSplitterFrame), // custom MDI child frame
RUNTIME_CLASS(CRTreView));
AddDocTemplate(m_pUsbDevsTemplate);
/*
m_pUsbBldTemplate = new CMultiDocTemplate(
IDR_USBBTYPE,
RUNTIME_CLASS(CUTreDoc),
RUNTIME_CLASS(CUTreFrm), // custom MDI child frame
RUNTIME_CLASS(CUTreView));
AddDocTemplate(m_pUsbBldTemplate);
*/
// Set EzUSB Vs FX2
theApp.m_strTargetName = theApp.GetProfileString("Settings", "m_strTargetName", "UNKNOWN");
if(theApp.m_strTargetName == "EZ-USB")
m_nTarg = 0; // set default target to EZ-USB
else if(theApp.m_strTargetName == "Fx2")
m_nTarg = 1; // set default target to Fx2
else if(theApp.m_strTargetName == "Sx2")
m_nTarg = 2; // set default target to Sx2
else
{ // UNKNOWN Target - ask user
dlg.m_nTargSel = 0;
dlg.DoModal();
m_nTarg = dlg.m_nTargSel;
}
OnOptionsFx2(); // Select appropriate target
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
char argc;
char args[5][320];
for(argc=0; (argc<__argc)&&(argc<5); argc++)
{
TRACE("%s:%3d: EzMr.cpp: __targv[%d]=%s\n", __FILE__, __LINE__, argc, __targv[argc]);
sprintf(args[argc], __targv[argc]);
}
theApp.pm_wndToolBar->LoadBitmap(IDR_MAINFRAME);
// DON'T display a new MDI child window during startup!!!
// Dispatch commands specified on the command line
// if (!ProcessShellCommand(cmdInfo))
// return FALSE;
// The main window has been initialized, so show and update it.
if(!strcmp(args[1], "-c"))
{
pMainFrame->ShowWindow(SW_MINIMIZE);
OnOptionsRunCableTest();
}
else
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
OnFileOpenAllDevs();
//TPMTPMTPM m_pUsbBldTemplate->OpenDocumentFile(NULL); // open USB frame view
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)
// No message handlers
//}}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
//CListBox* pList = (CListBox*)(this->GetDlgItem(IDC_LIST_PRODUCT_VERSION));
//pList->AddString("Version 2.10 [700]");
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CEzMrApp::OnAppAbout()
{
CAboutDlg aboutDlg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -