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

📄 tmgmondlg.cpp

📁 PNX系列设备驱动 PNX系列设备驱动
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// tmgmonDlg.cpp : implementation file
//

#include <direct.h>
#include <io.h>
#include "stdafx.h"
#include "tmgmon.h"
#include <shlobj.h>

#include "tmmanapi.h"
#include "tmcrt.h"
#include "verinfo.h"

#include "tmmon.h"

#define constTMGmonRegistryPath  TEXT("SOFTWARE\\PhilipsSemiconductors\\TriMedia\\TMGmon")
#define constMaxRegistryEntries  10

CTmmon *pcTmmon;

BOOL tracefull=FALSE;
DWORD dwDSPCount;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

char infostr[100],verstr[100];

/////////////////////////////////////////////////////////////////////////////
//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)
	virtual BOOL OnInitDialog();
	//}}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)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetDlgItemText(IDC_STATIC2,verstr);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

/////////////////////////////////////////////////////////////////////////////
// CTmgmonDlg dialog

CTmgmonDlg::CTmgmonDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTmgmonDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTmgmonDlg)
	m_taskFile = _T("");
	m_taskArguments = _T("");
	m_phymem = _T("");
	m_memoption = -1;
	m_debugsdram = FALSE;
	m_debugmono = FALSE;
	m_debugpcmem = FALSE;
	m_stdinfile = _T("");
	m_stdoutfile = _T("");
	m_stderrfile = _T("");
	m_stdin = FALSE;
	m_stdout = FALSE;
	m_stderr = FALSE;
	m_trace = FALSE;
	m_tracefile = _T("");
	m_taskloaded=FALSE;
	m_checkappdir = TRUE;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTmgmonDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTmgmonDlg)
	DDX_Control(pDX, IDC_WORKING_DIR, m_browseWorkingDir);
	DDX_Control(pDX, IDC_EDIT_WD, m_workingDir);
	DDX_Control(pDX, IDC_COMBO2, m_taskArgumentsList);
	DDX_Control(pDX, IDC_COMBO1, m_taskFileList);
	DDX_Text(pDX, IDC_EDIT2, m_phymem);
	DDV_MaxChars(pDX, m_phymem, 8);
	DDX_Radio(pDX, IDC_RADIO1, m_memoption);
	DDX_Text(pDX, IDC_EDIT3, m_stdinfile);
	DDX_Text(pDX, IDC_EDIT4, m_stdoutfile);
	DDX_Text(pDX, IDC_EDIT5, m_stderrfile);
	DDX_Check(pDX, IDC_CHECK4, m_stdin);
	DDX_Check(pDX, IDC_CHECK5, m_stdout);
	DDX_Check(pDX, IDC_CHECK6, m_stderr);
	DDX_Check(pDX, IDC_CHECK1, m_trace);
	DDX_Text(pDX, IDC_EDIT8, m_tracefile);
	DDX_Check(pDX, IDC_CHECK_APPDIR, m_checkappdir);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTmgmonDlg, CDialog)
	//{{AFX_MSG_MAP(CTmgmonDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
	ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
	ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_CHECK4, OnCheck4)
	ON_BN_CLICKED(IDC_CHECK5, OnCheck5)
	ON_BN_CLICKED(IDC_CHECK6, OnCheck6)
	ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
	ON_EN_ERRSPACE(IDC_EDIT6, OnErrspaceEdit6)
	ON_BN_CLICKED(IDC_BUTTON11, OnButton11)
	ON_EN_MAXTEXT(IDC_EDIT6, OnMaxtextEdit6)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPINNUM, OnDeltaposSpinnum)
	ON_WM_CLOSE()
	ON_WM_DESTROY()
    ON_WM_ENDSESSION()
	ON_BN_CLICKED(IDC_WORKING_DIR, OnWorkingDir)
	ON_BN_CLICKED(IDC_CHECK_APPDIR, OnCheckAppDir)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTmgmonDlg message handlers

BOOL CTmgmonDlg::OnInitDialog()
{
    char workingDir[MAX_PATH];
    CCommandLineInfo cmdInfo;

	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	pcTmmon = (CTmmon *) new CTmmon;//cTmmon;

	
	// TODO: Add extra initialization here
	if(pcTmmon->ctc_main(this,verstr))			// Successful
	{
	dwDSPCount = tmmanDSPGetNum();    //^^^^

//	dwDSPCount = 5;
	((CSpinButtonCtrl *)GetDlgItem(IDC_SPINNUM))->SetBuddy(GetDlgItem(IDC_NUM));
	((CSpinButtonCtrl *)GetDlgItem(IDC_SPINNUM))->SetRange(0,dwDSPCount-1);
	m_tracewin.SubclassDlgItem(IDC_EDIT6,this);
	// Set the font of edit window
	CFont font;
	CFont* pFont;
//	CEdit* pEdit=(CEdit*)GetDlgItem(IDC_EDIT6);
	pFont=font.FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT));

//	pEdit->SetFont(pFont);
	m_tracewin.SetFont(pFont);

//	((CEdit*)GetDlgItem(IDC_EDIT1))->SetFocus();
    m_taskFileList.SetFocus();
	}
	else
		PostQuitMessage(0);
	
	((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(1);

    GetCurrentDirectory(MAX_PATH,workingDir);
    m_workingDir.SetWindowText(workingDir);
    AfxGetApp()->ParseCommandLine(cmdInfo);
    m_taskFileList.SetWindowText(cmdInfo.m_strFileName);
    RegistryRead();
	return FALSE;  // return TRUE  unless you set the focus to a control
}

void CTmgmonDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CTmgmonDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CTmgmonDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}


void CTmgmonDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	char	*pFileName;
    m_taskFileList.GetWindowText(m_taskFile);
	if(m_taskFile.IsEmpty() || m_checkappdir)
		pFileName = NULL;
	else
		pFileName = (char*)(const char*)m_taskFile;

    CFileDialog dlg(
		TRUE,										// Open File Dialog
		NULL,									// Default extension
        pFileName,
//		NULL,										// No default filename
		OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,		// OPENFILENAME flags
		"Task Files (*.out) |*.out|App Files (*.app) |*.app|All Files|*.*||");	// Filter strings
	
	if (dlg.DoModal() == IDOK)
        m_taskFileList.SetWindowText(dlg.GetPathName());
    return;
}

// Button "Stdin"
void CTmgmonDlg::OnButton6() 
{
	// TODO: Add your control notification handler code here
	CFileDialog dlg(
		TRUE,										// Open File Dialog
		NULL,									// Default extension
		NULL,										// No default filename
		OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR,	// OPENFILENAME flags
		"All Files|*.*||");	// Filter strings
	
	if (dlg.DoModal() == IDOK)
		SetDlgItemText(IDC_EDIT3,dlg.GetPathName());
}

// Button "Stdout"
void CTmgmonDlg::OnButton7() 
{
	// TODO: Add your control notification handler code here
		CFileDialog dlg(
		TRUE,										// Open File Dialog
		NULL,									// Default extension
		NULL,										// No default filename
		OFN_HIDEREADONLY  | OFN_NOCHANGEDIR, 		// OPENFILENAME flags
		"All Files|*.*||");	// Filter strings
	
	if (dlg.DoModal() == IDOK)
		SetDlgItemText(IDC_EDIT4,dlg.GetPathName());
}

// Button "Stderr"
void CTmgmonDlg::OnButton8() 
{
	// TODO: Add your control notification handler code here
	CFileDialog dlg(
		TRUE,										// Open File Dialog
		NULL,									// Default extension
		NULL,										// No default filename
		OFN_HIDEREADONLY  | OFN_NOCHANGEDIR,		// OPENFILENAME flags
		"All Files|*.*||");	// Filter strings
	
	if (dlg.DoModal() == IDOK)
		SetDlgItemText(IDC_EDIT5,dlg.GetPathName());
}

// button "Download"
void CTmgmonDlg::OnButton2() 
{
	// TODO: Add your control notification handler code here

    m_taskFileList.GetWindowText(m_taskFile);
    m_taskArgumentsList.GetWindowText(m_taskArguments);
	if(!m_taskFile.IsEmpty())
	{
	pcTmmon->ExeLoad(m_taskFile.GetBuffer(_MAX_PATH),m_taskArguments.GetBuffer(_MAX_PATH));
	m_taskFile.ReleaseBuffer();
	m_taskArguments.ReleaseBuffer();
	}
}

// Button "Go"
void CTmgmonDlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
    char path_buffer[_MAX_PATH];   char drive[_MAX_DRIVE];   char dir[_MAX_DIR];
    char fname[_MAX_FNAME];   char ext[_MAX_EXT];
    char workingDir[MAX_PATH];
    CString listText;
    int i;

    m_taskFileList.GetWindowText(m_taskFile);
    m_taskArgumentsList.GetWindowText(m_taskArguments);

// Save task file in list. Do not save blank
    if (!m_taskFile.IsEmpty())
    {
        for(i=0;i<m_taskFileList.GetCount();i++)
        {
            m_taskFileList.GetLBText(i,listText);
            if(m_taskFile == listText)
                break;
        }
        if(i == m_taskFileList.GetCount())
            m_taskFileList.InsertString(0,(LPCTSTR)m_taskFile.GetBuffer(_MAX_PATH));
    }

// Save argument in list. Do not save blank
    if (!m_taskArguments.IsEmpty())
    {
        for(i=0;i<m_taskArgumentsList.GetCount();i++)
        {
            m_taskArgumentsList.GetLBText(i,listText);
            if(m_taskArguments == listText)
                break;
        }
        if(i == m_taskArgumentsList.GetCount())
            m_taskArgumentsList.InsertString(0,(LPCTSTR)m_taskArguments.GetBuffer(_MAX_PATH));
    }

    strcpy(path_buffer,m_taskFile.GetBuffer(_MAX_PATH));
    if(m_checkappdir)
    {
        if(access(path_buffer,0) != -1)
        {
            _splitpath( path_buffer, drive, dir, fname, ext );
            _chdir(drive);
            _chdir(dir);
        }
    }
    else
    {
        m_workingDir.GetWindowText(workingDir,MAX_PATH);
        if(!SetCurrentDirectory(workingDir))
        {
            AfxMessageBox("Error in switching to working directory");
            return;

⌨️ 快捷键说明

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