📄 reatedevicedlg.cpp
字号:
// reateDevicedlg.cpp : implementation file
//
#include "stdafx.h"
#include "MDIDemo.h"
#include "reateDevicedlg.h"
#include "DeviceManager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CreateDevicedlg dialog
CreateDevicedlg::CreateDevicedlg(CWnd* pParent /*=NULL*/)
: CDialog(CreateDevicedlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CreateDevicedlg)
//}}AFX_DATA_INIT
}
void CreateDevicedlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CreateDevicedlg)
DDX_Control(pDX, IDC_SerBus, m_sbus);
DDX_Control(pDX, IDC_MEMLIST, m_mem);
DDX_Control(pDX, IDC_CPULIST, m_cpuctrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CreateDevicedlg, CDialog)
//{{AFX_MSG_MAP(CreateDevicedlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_WM_LBUTTONDOWN()
ON_WM_CREATE()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CreateDevicedlg message handlers
BYTE CreateDevicedlg::iscreate=0;
void CreateDevicedlg::OnButton1()
{
// TODO: Add your control notification handler code here
NAMEDLG dlg;
dlg.m_staticstr.Format("请填写8051处理器名称");
dlg.m_str.Format("处理器%d",DeviceMag.DTCB[ID_TYPE_8051CPU].Currentpos);
dlg.DoModal();
if(dlg.OK!=1)
{
return ;
}
DeviceMag.CreateDevice(ID_TYPE_8051CPU,dlg.m_str.GetBuffer(dlg.m_str.GetLength()));
CString str,str1;
m_cpuctrl.SetSel(0,-1,TRUE);
m_cpuctrl.Clear();
str.Empty();
str+="8051CPU列表\r\n";
for(int i=0;i<DeviceMag.DTCB[ID_TYPE_8051CPU].Currentpos;i++)
{
str+=DeviceMag.DTCB[ID_TYPE_8051CPU].DEVICEINFO[i].pDeviceName;
str+="\r\n";
}
str1.Format("总计%d个8051处理器",DeviceMag.DTCB[ID_TYPE_8051CPU].Currentpos);
str+=str1;
//m_cpuctrl.UpdateData(FALSE);
this->UpdateData(FALSE);
m_cpuctrl.SendMessage(EM_REPLACESEL,0,(LPARAM)str.GetBuffer(str.GetLength()));
//CWnd *pwnd =this->GetDlgItem(IDC_CPULIST);
//AfxMessageBox(dlg.m_str);
//dlg.UpdateData();
}
void CreateDevicedlg::OnButton2()
{
// TODO: Add your control notification handler code here
NAMEDLG dlg;
dlg.m_staticstr.Format("请填写RS232串行总线名称");
dlg.m_str.Format("RS232串行总线%d",DeviceMag.DTCB[ID_TYPE_SerialBus].Currentpos);
dlg.DoModal();
if(dlg.OK!=1)
{
return ;
}
DeviceMag.CreateDevice(ID_TYPE_SerialBus,dlg.m_str.GetBuffer(dlg.m_str.GetLength()));
CString str,str1;
m_sbus.SetSel(0,-1,TRUE);
m_sbus.Clear();
str.Empty();
str+="RS232串行总线列表\r\n";
for(int i=0;i<DeviceMag.DTCB[ID_TYPE_SerialBus].Currentpos;i++)
{
str+=DeviceMag.DTCB[ID_TYPE_SerialBus].DEVICEINFO[i].pDeviceName;
str+="\r\n";
}
str1.Format("总计%d个RS232串行总线",DeviceMag.DTCB[ID_TYPE_SerialBus].Currentpos);
str+=str1;
//m_cpuctrl.UpdateData(FALSE);
this->UpdateData(FALSE);
m_sbus.SendMessage(EM_REPLACESEL,0,(LPARAM)str.GetBuffer(str.GetLength()));
}
void CreateDevicedlg::OnButton3()
{
// TODO: Add your control notification handler code here
NAMEDLG dlg;
dlg.m_staticstr.Format("请填写需要新建内存的名称,大小固定为64KB,可以为EPROM或者RAM");
dlg.m_str.Format("EPROM or RAM%d",DeviceMag.DTCB[ID_TYPE_MEM].Currentpos);
dlg.DoModal();
if(dlg.OK!=1)
{
return ;
}
DeviceMag.CreateDevice(ID_TYPE_MEM,dlg.m_str.GetBuffer(dlg.m_str.GetLength()));
CString str,str1;
m_mem.SetSel(0,-1,TRUE);
m_mem.Clear();
str.Empty();
str+="EPROM 或者 RAM列表\r\n";
for(int i=0;i<DeviceMag.DTCB[ID_TYPE_MEM].Currentpos;i++)
{
str+=DeviceMag.DTCB[ID_TYPE_MEM].DEVICEINFO[i].pDeviceName;
str+="\r\n";
}
str1.Format("总计%d个EPROM或者RAM",DeviceMag.DTCB[ID_TYPE_MEM].Currentpos);
str+=str1;
//m_cpuctrl.UpdateData(FALSE);
this->UpdateData(FALSE);
m_mem.SendMessage(EM_REPLACESEL,0,(LPARAM)str.GetBuffer(str.GetLength()));
}
void CreateDevicedlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y));
//this->ShowWindow(SW_HIDE);
//::SetWindowPos(this->m_hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW|SWP_FRAMECHANGED);
//this->SetWindowPos(this,0,0,0,0,
// RECT rect;
// this->GetWindowRect(&rect);
this->Invalidate();
this->UpdateWindow();
this->ShowWindow(SW_SHOW);
//::SendMessage(this->GetParent()->m_hWnd,WM_PRINT,0,0);
CDialog::OnLButtonDown(nFlags, point);
}
int CreateDevicedlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
if(iscreate)
{
AfxMessageBox("创建设备窗口已经运行");
return -1;
}
iscreate ++;
return 0;
}
void CreateDevicedlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
//AfxMessageBox("");
iscreate=0;
CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -