?? eprodlg.cpp
字號:
// EProDlg.cpp : implementation file
//
#include "stdafx.h"
#include "EPro.h"
#include "EProDlg.h"
#include "FuncCode.h"
#include "LastFileDialog.h"
#include "winuser.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
extern CString m_strAppPath;
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)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEProDlg dialog
CEProDlg::CEProDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEProDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEProDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bWorkDetectPro=FALSE;
m_bWorkOpenFile=FALSE;
m_bWorkDetectChip=FALSE;
m_bWorkErase=FALSE;
m_bWorkWrite=FALSE;
m_bWorkRead=FALSE;
m_bWorkCheck=FALSE;
m_bAutoWork=FALSE;
m_nWrCount=0;
m_nMsg=0;
}
void CEProDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEProDlg)
DDX_Control(pDX, IDC_PROGRESS, m_Progress);
DDX_Control(pDX, IDC_LIST_MSG, m_listMsg);
DDX_Control(pDX, IDC_EDIT_BUF2, m_editBuf2);
DDX_Control(pDX, IDC_EDIT_BUF1, m_editBuf1);
DDX_Control(pDX, IDC_TAB, m_Tab);
DDX_Control(pDX, IDC_CHIPS, m_hlChips);
DDX_Control(pDX, IDC_COMBO_LOCKBITS, m_comboLockBits);
DDX_Control(pDX, IDC_COMBO_CHIPTYPE, m_comboChipType);
DDX_Control(pDX, IDC_BUTTON_LOCK, m_btLock);
DDX_Control(pDX, IDC_BUTTON_CHIPDETECT, m_btDetectChip);
DDX_Control(pDX, IDC_BUTTON_WRITE, m_btWrite);
DDX_Control(pDX, IDC_BUTTON_SAVEFILE, m_btSaveFile);
DDX_Control(pDX, IDC_BUTTON_READ, m_btRead);
DDX_Control(pDX, IDC_BUTTON_OPENFILE, m_btOpenFile);
DDX_Control(pDX, IDC_BUTTON_ERASE, m_btErase);
DDX_Control(pDX, IDC_BUTTON_CHECK, m_btCheck);
DDX_Control(pDX, IDC_BUTTON_AUTO, m_btAuto);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEProDlg, CDialog)
//{{AFX_MSG_MAP(CEProDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_MESSAGE(TCN_XT_SELCHANGE, OnTabSelChange)
ON_MESSAGE(XTWM_PROPERTYGRID_NOTIFY, OnGridNotify)
ON_MESSAGE(WM_PRO_MSG,OnProMsg)
ON_BN_CLICKED(IDC_BUTTON_OPENFILE, OnButtonOpenfile)
ON_BN_CLICKED(IDC_BUTTON_CHIPDETECT, OnButtonChipdetect)
ON_BN_CLICKED(IDC_BUTTON_SAVEFILE, OnButtonSavefile)
ON_BN_CLICKED(IDC_BUTTON_ERASE, OnButtonErase)
ON_BN_CLICKED(IDC_BUTTON_WRITE, OnButtonWrite)
ON_BN_CLICKED(IDC_BUTTON_READ, OnButtonRead)
ON_BN_CLICKED(IDC_BUTTON_CHECK, OnButtonCheck)
ON_BN_CLICKED(IDC_BUTTON_AUTO, OnButtonAuto)
ON_BN_CLICKED(IDC_BUTTON_LOCK, OnButtonLock)
ON_BN_CLICKED(IDC_CHIPS, OnChips)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEProDlg message handlers
BOOL CEProDlg::OnInitDialog()
{
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
// TODO: Add extra initialization here
InitInterface();
m_Pro.m_nSerialPort=m_nPortSel;
m_Pro.m_nBaudSel=m_nBaudSel;
TRACE("m_nProType:%d\n",m_nProType);
m_Pro.InitPro(this,m_nProType,m_nIspSpd);
m_Pro.LoadChipList();
m_comboChipType.SetCurSel(m_InfoSave.m_nChipSel);
EnableHotKey(m_bHotKey);
return TRUE; // return TRUE unless you set the focus to a control
}
void CEProDlg::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 CEProDlg::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 CEProDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CEProDlg::OnCancel()
{
// TODO: Add extra cleanup here
SaveInfoSave();
CDialog::OnCancel();
}
void CEProDlg::OnOK()
{
OnButtonAuto();
}
void CEProDlg::InitInterface()//初始化界面
{
// Enable/Disable XP GUI Mode
xtAfxData.bXPMode = TRUE;
// Enable/Disable Menu Shadows
xtAfxData.bMenuShadows = TRUE;
//初始化指示按鈕控件
m_btOpenFile.InitButton(this,TRUE,TRUE,IDI_OPENFILE);
m_btSaveFile.InitButton(this,FALSE,FALSE,IDI_SAVEFILE);
m_btErase.InitButton(this,TRUE,TRUE,IDI_ERASE,IDI_ERASE2);
m_btWrite.InitButton(this,TRUE,TRUE,IDI_WRITE,IDI_WRITE2);
m_btRead.InitButton(this,TRUE,TRUE,IDI_READ,IDI_READ2);
m_btCheck.InitButton(this,TRUE,TRUE,IDI_CHECK,IDI_CHECK2);
m_btAuto.InitButton(this,FALSE,TRUE,IDI_AUTO);
m_btDetectChip.InitButton(this);
m_btLock.InitButton(this);
m_Tab.InsertItem(0,"緩沖1");
m_Tab.InsertItem(1,"緩沖2");
m_Tab.InsertItem(2,"狀態(tài)");
m_Tab.InsertItem(3,"設(shè)置");
m_Grid.Create(CRect(2000,2000,2000,2000),this,IDI_GRID);
m_pProSetting=m_Grid.AddCategory("編程器");
m_pSelPro=m_pProSetting->AddChildItem(new CXTPropertyGridItem("編程器類型",""));
m_pSelPro->SetDescription("選擇Easy 51Pro串行編程器還是并口下載線?(重啟程序生效)");
m_pProList = m_pSelPro->GetConstraints();
m_pProList->AddConstraint("使用Easy 51Pro串行編程器");
m_pProList->AddConstraint("使用Easy ISP下載線");
m_pProList->AddConstraint("使用Atmel ByteBlaster下載線");
m_pProList->AddConstraint("使用Altera ByteBlaster 下載線");
m_pSelPro->SetFlags(pgiHasComboButton);
m_pSelPort = m_pProSetting->AddChildItem(new CXTPropertyGridItem("串口",""));
m_pSelPort->SetDescription("選擇Easy 51Pro串行編程器使用的端口.(重啟程序生效)");
m_pPortList= m_pSelPort->GetConstraints();
m_pPortList->AddConstraint("COM 1");
m_pPortList->AddConstraint("COM 2");
m_pPortList->AddConstraint("COM 3");
m_pPortList->AddConstraint("COM 4");
SetPortSel(0);
m_pSelPort->SetFlags(pgiHasComboButton);
m_pSelBaud = m_pProSetting->AddChildItem(new CXTPropertyGridItem("波特率",""));
m_pSelBaud->SetDescription("選擇Easy 51Pro串行編程器通訊時使用的波特率.(重啟程序生效)");
m_pBaudList= m_pSelBaud->GetConstraints();
m_pBaudList->AddConstraint("9600");
m_pBaudList->AddConstraint("19200");
m_pBaudList->AddConstraint("28800");
m_pBaudList->AddConstraint("57600");
SetBaudSel(0);
m_pSelBaud->SetFlags(pgiHasComboButton);
m_pSelIspSpd = m_pProSetting->AddChildItem(new CXTPropertyGridItem("下載線性能",""));
m_pSelIspSpd->SetDescription("根據(jù)下載線的穩(wěn)定狀況設(shè)置速度.(重啟程序生效)");
m_pIspSpdList = m_pSelIspSpd->GetConstraints();
m_pIspSpdList->AddConstraint("一般");
m_pIspSpdList->AddConstraint("較快");
m_pIspSpdList->AddConstraint("最快");
m_pSelIspSpd->SetFlags(pgiHasComboButton);
m_pProSetting->Expand();
m_pSysSetting=m_Grid.AddCategory("系統(tǒng)");
m_pDetectBegin=m_pSysSetting->AddChildItem(new CXTPropertyGridItemBool("自動檢測器件",TRUE));
m_pDetectBegin->SetDescription("[自動完成]時是否先檢測器件?");
m_pSound=m_pSysSetting->AddChildItem(new CXTPropertyGridItemBool("使用聲音提示",TRUE));
m_pSound->SetDescription("編程成功或失敗將會有不同的聲音提示.");
m_pHotKey=m_pSysSetting->AddChildItem(new CXTPropertyGridItemBool("使用熱鍵",TRUE));
m_pHotKey->SetDescription("按下熱鍵后相當(dāng)于點擊了[自動完成].");
m_pSysSetting->Expand();
m_Grid.SetCustomColors( RGB(182, 189,210), 0, RGB(182, 189,210,), RGB(233, 243,247 ), 0);
m_editBuf1.SetData(m_Pro.m_pWriteBuf,0x10000,0x10000);
m_editBuf1.SetOptions(TRUE, TRUE, TRUE, FALSE);
m_editBuf1.SetBPR(8);
m_editBuf1.EnableCaret(TRUE);
m_editBuf1.SetAddressBase(0);
m_editBuf1.RedrawWindow();
m_editBuf1.m_bAllowDeletes=FALSE;
m_editBuf2.SetData(m_Pro.m_pReadBuf,0x10000,0x10000);
m_editBuf2.SetOptions(TRUE, TRUE, TRUE, FALSE);
m_editBuf2.SetBPR(8);
m_editBuf2.EnableCaret(TRUE);
m_editBuf2.SetAddressBase(0);
m_editBuf2.RedrawWindow();
m_editBuf2.m_bAllowDeletes=FALSE;
m_comboLockBits.InsertString(0,"Lock Bit-1");
m_comboLockBits.InsertString(1,"Lock Bit-2");
m_comboLockBits.InsertString(2,"Lock Bit-3");
m_comboLockBits.SetCurSel(0);
m_Progress.ShowWindow(SW_HIDE);
LoadInfoSave();
EnableCtrl(TRUE);
}
void CEProDlg::SelWnd(int nSel)//選擇窗口
{
m_Tab.SetCurSel(nSel);
m_nWndSel=nSel;
CRect CtrlRect,CtrlRect2;
m_Tab.GetChildRect(CtrlRect2);
m_Tab.GetWindowRect(&CtrlRect);
ScreenToClient( &CtrlRect );
CtrlRect.SetRect(CtrlRect.left+3,CtrlRect.top+3,CtrlRect.left+CtrlRect2.Width()+3,CtrlRect.top+CtrlRect2.Height()+3);
if(nSel==0)
{
m_editBuf1.SetWindowPos(NULL,CtrlRect.left,CtrlRect.top,CtrlRect.Width(),CtrlRect.Height(),SWP_SHOWWINDOW);
m_editBuf2.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
m_listMsg.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
m_Grid.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
}
else if(nSel==1)
{
m_editBuf2.SetWindowPos(NULL,CtrlRect.left,CtrlRect.top,CtrlRect.Width(),CtrlRect.Height(),SWP_SHOWWINDOW);
m_editBuf1.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
m_listMsg.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
m_Grid.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
}
else if(nSel==2)
{
//m_edBuf1.ShowWindow(SW_HIDE);
//m_edBuf2.ShowWindow(SW_HIDE);
//m_List.ShowWindow(SW_SHOW);
m_listMsg.SetWindowPos(NULL,CtrlRect.left,CtrlRect.top,CtrlRect.Width(),CtrlRect.Height(),SWP_SHOWWINDOW);
m_editBuf2.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
m_editBuf1.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
m_Grid.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
}
else if(nSel==3)
{
m_Grid.SetWindowPos(NULL,CtrlRect.left-1,CtrlRect.top-1,CtrlRect.Width()+2,CtrlRect.Height()+2,SWP_SHOWWINDOW);
m_editBuf2.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
m_editBuf1.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
m_listMsg.SetWindowPos(NULL,2000,2000,0,0,SWP_HIDEWINDOW);
}
}
UINT CEProDlg::OnTabSelChange(WPARAM wParam, LPARAM lParam)
{
//AfxMessageBox("OnTabSelChange");
//CXTTabCtrl* pTabCtrl = (CXTTabCtrl*)lParam;
int nSel=m_Tab.GetCurSel();
SelWnd(nSel);
return 0;
}
int CEProDlg::GetProType()
{
return m_nProType=m_pProList->GetCurrent();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -