MainFrm.cpp
上传用户:asikq0571
上传日期:2014-07-12
资源大小:528k
文件大小:19k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "Peugeot.h"
- #include "MainFrm.h"
- #include "PeugeotDoc.h"
- #include "PeugeotView.h"
- ////////////////
- #include "YXData.h"
- #include "YCData.h"
- #include "YMData.h"
- #include "YKData.h"
- #include "SettingCmmDlg.h"
- #include "SettingPrtDlg.h"
- /////////////////
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_COMMAND(ID_SET_CMMPORT, OnSetCmmPort)
- ON_COMMAND(ID_SET_PROTOCOL, OnSetProtocol)
- ON_COMMAND(ID_COMMAND_CONCMM, OnConnectCmm)
- ON_COMMAND(ID_COMMAND_DISCONCMM, OnDisconncmm)
- ON_UPDATE_COMMAND_UI(ID_COMMAND_CONCMM, OnUpdateConcmm)
- ON_UPDATE_COMMAND_UI(ID_COMMAND_DISCONCMM, OnUpdateDisconcmm)
- ON_WM_CLOSE()
- ON_COMMAND(ID_VIEW_DATA, OnViewData)
- ON_COMMAND(ID_VIEW_MESSAGE, OnViewMessage)
- ON_UPDATE_COMMAND_UI(ID_VIEW_DATA, OnUpdateViewData)
- ON_UPDATE_COMMAND_UI(ID_VIEW_MESSAGE, OnUpdateViewMessage)
- ON_COMMAND(ID_COMMAND_PAUSE_DSP, OnPauseDsp)
- ON_COMMAND(ID_COMMAND_REFLASH_DSP, OnReflashDsp)
- ON_UPDATE_COMMAND_UI(ID_COMMAND_PAUSE_DSP, OnUpdatePauseDsp)
- ON_UPDATE_COMMAND_UI(ID_COMMAND_REFLASH_DSP, OnUpdateReflashDsp)
- ON_COMMAND(ID_COMMAND_CLEAR_DSP, OnClearDsp)
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- IsCmmConnect = false;
- IsReflashMsg = true;
- IsFrameCreat = false;
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- HBITMAP hbm = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDB_TOOLBAR), //加载IDB_TOOLBAR
- IMAGE_BITMAP, //按位图格式
- 0,0, // cx,cy
- LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS );
- HBITMAP hbm2 = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDB_GRAYTOOLBAR), //加载IDB_TOOLBAR
- IMAGE_BITMAP, //按位图格式
- 0,0, // cx,cy
- LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS );
- CBitmap bm,bm2;
- bm.Attach(hbm);
- bm2.Attach(hbm2);
- m_ToolBar.Create(24,24,ILC_COLOR16, 12, 0);
- m_ToolBar.Add(&bm,(CBitmap*)NULL);
- m_GrayToolBar.Create(24,24,ILC_COLOR16, 12, 0);
- m_GrayToolBar.Add(&bm2,(CBitmap*)NULL);
-
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
-
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- m_wndToolBar.GetToolBarCtrl().SetImageList(&m_ToolBar);
- m_wndToolBar.GetToolBarCtrl().SetDisabledImageList(&m_GrayToolBar);
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- //m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- //EnableDocking(CBRS_ALIGN_ANY);
- //DockControlBar(&m_wndToolBar);
- ///////////////////
- if (!m_wndMyBar1.Create(_T("数字显示窗口"), this, CSize(291,260),TRUE,123))
- {
- TRACE0("Failed to create mybarn");
- return -1;
- }
- if (!m_wndMyBar2.Create(_T("信息提示窗口"), this,CSize(200,100),TRUE,124))
- {
- TRACE0("Failed to create mybarn");
- return -1;
- }
- //////////////////////////////////////
- m_wndToolBar.SetButtonText(0,"打开");
- m_wndToolBar.SetButtonText(1,"保存");
- m_wndToolBar.SetButtonText(3,"规约");
- m_wndToolBar.SetButtonText(4,"端口");
- m_wndToolBar.SetButtonText(6,"连接");
- m_wndToolBar.SetButtonText(7,"断开");
- m_wndToolBar.SetButtonText(9,"数据");
- m_wndToolBar.SetButtonText(10,"消息");
- m_wndToolBar.SetButtonText(12,"暂停");
- m_wndToolBar.SetButtonText(13,"刷新");
- m_wndToolBar.SetButtonText(14,"清空");
- m_wndToolBar.SetButtonText(16,"关于");
- /////////////调整工具条/////////////////
- CRect rc(0, 0, 0, 0);
- CSize sizeMax(0, 0);
- CToolBarCtrl& bar = m_wndToolBar.GetToolBarCtrl();
- for (int nIndex = bar.GetButtonCount() - 1; nIndex >= 0; nIndex--)
- {
- bar.GetItemRect(nIndex, rc);
- rc.NormalizeRect();
- sizeMax.cx = __max(rc.Size().cx, sizeMax.cx);
- sizeMax.cy = __max(rc.Size().cy, sizeMax.cy);
- }
- m_wndToolBar.SetSizes(sizeMax, CSize(24,24));
- ////////////创建TAB Control,并把它加入到ControlBar中
- /// 需要注意的是:同一个ControlBar只能加入一个"一级子窗口"
- m_TabCtrl.Create(TCS_DOWN|WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),&m_wndMyBar1,125);
-
- m_TabCtrl.AddPage(RUNTIME_CLASS(CYXData),IDD_YXDATA,"遥信",IDI_ICON_yx);
- m_TabCtrl.AddPage(RUNTIME_CLASS(CYCData),IDD_YCDATA,"遥测",IDI_ICON_yc);
- m_TabCtrl.AddPage(RUNTIME_CLASS(CYMData),IDD_YMDATA,"电度",IDI_ICON_ym);
- m_TabCtrl.AddPage(RUNTIME_CLASS(CYKData),IDD_YKDATA,"遥控",IDI_ICON_yk);
- m_TabCtrl.UpdateWindow();
- ////////////创建LIST Control,并把它加入到ControlBar中LVS_REPORT
- m_MsgList.Create(WS_THICKFRAME | WS_VSCROLL | WS_CHILD | WS_VISIBLE | LVS_REPORT,CRect(0,0,0,0),&m_wndMyBar2,126);
-
- DWORD styles = m_MsgList.GetExtendedStyle();
- m_MsgList.SetExtendedStyle(styles|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); //整行选择和网格条纹
- LVCOLUMN column[3];
- int i;
- for (i=0; i<3; i++)
- {
- column[i].mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH | LVCF_ORDER;
- column[i].fmt = LVCFMT_LEFT;
- column[i].iSubItem = i;
- column[i].iOrder = i;
- }
- column[0].pszText = "时间";
- column[1].pszText = "消息类型";
- column[2].pszText = "内容";
- column[0].cx = 120;
- column[1].cx = 120;
- column[2].cx = 360;
- for (i=0; i<3; i++)
- m_MsgList.InsertColumn(i, column+i);
-
- ///////////////两个WNDBAR的停靠控制///////////////////
- m_wndMyBar1.SetBarStyle(m_wndMyBar1.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndMyBar2.SetBarStyle(m_wndMyBar2.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
-
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); //使工具栏可停靠
- m_wndMyBar1.EnableDocking(CBRS_ALIGN_ANY);
- m_wndMyBar2.EnableDocking(CBRS_ALIGN_ANY);
-
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar); //3个工具栏停靠方式
- DockControlBar(&m_wndMyBar1, AFX_IDW_DOCKBAR_LEFT);
- DockControlBar(&m_wndMyBar2, AFX_IDW_DOCKBAR_BOTTOM);
- /////////使浮动与停靠显示相同的头部////
- #ifdef _SCB_REPLACE_MINIFRAME
- m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd);
- #endif //_SCB_REPLACE_MINIFRAME
- ///////////////////
- IsFrameCreat = true;
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::OnSetCmmPort()
- {
- SetCmmPort();
- }
- void CMainFrame::OnSetProtocol()
- {
- CSettingPrtDlg PrtDlg;
- if (PrtDlg.DoModal()==IDOK) // TODO: 保存通讯对话框设置的参数
- {
- CPeugeotDoc* pDoc;
- pDoc = (CPeugeotDoc*)GetActiveDocument();
- ASSERT_VALID(pDoc);
-
- switch (PrtDlg.m_PrtType) //选中通讯规约
- {
- case 0:
- pDoc->m_PrtType = pDoc->IEC101_M;
- pDoc->m_MasterFlag = true;
- break;
- case 1:
- pDoc->m_PrtType = pDoc->IEC101_S;
- pDoc->m_MasterFlag = false;
- break;
- case 2:
- pDoc->m_PrtType = pDoc->Modbus_M;
- pDoc->m_MasterFlag = true;
- break;
- case 3:
- pDoc->m_PrtType = pDoc->Modbus_S;
- pDoc->m_MasterFlag = false;
- break;
- default:
- pDoc->m_PrtType = pDoc->IEC101_S;
- pDoc->m_MasterFlag = false;
- break;
- }
- //信息体寄存器地址、数量情况
- pDoc->m_YXAddr = PrtDlg.m_YXAddr;
- pDoc->m_YCAddr = PrtDlg.m_YCAddr;
- pDoc->m_YMAddr = PrtDlg.m_YMAddr;
- pDoc->m_YXNum = PrtDlg.m_YXNum;
- pDoc->m_YCNum = PrtDlg.m_YCNum;
- pDoc->m_YMNum = PrtDlg.m_YMNum;
- if ((pDoc->m_PrtType == pDoc->IEC101_M) || (pDoc->m_PrtType == pDoc->IEC101_S))
- {//保存IEC101规约参数
- pDoc->m_PrtIEC101.m_Addr = PrtDlg.m_IEC101Addr;
- pDoc->m_PrtIEC101.m_CauseOfTranLen = PrtDlg.m_IEC101CauseLen;
- pDoc->m_PrtIEC101.m_CommAddrLen = PrtDlg.m_IEC101ASDULen;
- pDoc->m_PrtIEC101.m_MsgAddrLen = PrtDlg.m_IEC101MsgLen;
- }
- else
- {//保存MODBUS规约参数
- pDoc->m_PrtModbus.m_Addr = PrtDlg.m_ModbusAddr;
- pDoc->m_PrtModbus.m_CallIntv = PrtDlg.m_ModbusCallInt;
- pDoc->m_PrtModbus.m_YXFunc = PrtDlg.m_ModbusYXFunc;
- pDoc->m_PrtModbus.m_YCFunc = PrtDlg.m_ModbusYCFunc;
- pDoc->m_PrtModbus.m_YCSize = PrtDlg.m_ModbusYCSize;
- }
-
- pDoc->NewStackAddr(); //生成实时库空间
- DrawGrid(); //绘制电子表格
-
- if (pDoc->m_pYXData != NULL)
- UpdateYXGrid();
- if (pDoc->m_pYCData != NULL)
- UpdateYCGrid();
- if (pDoc->m_pYMData != NULL)
- UpdateYMGrid();
-
- }
- }
- void CMainFrame::OnConnectCmm()
- {
- CPeugeotDoc* pDoc = (CPeugeotDoc*)GetActiveDocument(); //文档指针 主框架类函数;
- CPeugeotView* pView = (CPeugeotView*)GetActiveView(); //视图指针;
- // OnDisconncmm();
- if (pDoc->m_PrtType == pDoc->Blank) //若协议为空,先选中可用协议
- OnSetProtocol();
-
- if (pDoc->m_PrtType == pDoc->Blank) //如协议对话框中,按‘取消’,仍未选中协议
- {
- AfxMessageBox("请先选择/设置通讯协议");
- return;
- }
-
- if ( (pDoc->m_PrtType == pDoc->IEC101_M) || ((pDoc->m_PrtType == pDoc->IEC101_S)) )
- pView->m_pPrtObj = &(pDoc->m_PrtIEC101); //协议对象指向IEC101协议
- else
- pView->m_pPrtObj = &(pDoc->m_PrtModbus); //协议对象指向MODBUS协议
-
- pView->m_pPrtObj->InitPrt(); //规约初始化
-
- if (pDoc->m_CmmPortType == pDoc->CommPort)
- { //串口通讯方式
- pDoc->m_ComObj.m_hOwner = pView->GetSafeHwnd(); //串口消息发到该句柄的窗口
-
- if (pDoc->m_ComObj.OpenPort())
- {
- if ( (pView->m_pPrtObj != NULL) && (pDoc->m_MasterFlag) ) //主站时启动召唤定时器
- pView->m_pPrtObj->StartTimer();
-
- IsCmmConnect = true;
- }
- else
- {
- AfxMessageBox("无法打开" + pDoc->m_ComObj.m_szPortName + "rn" + "请选择其它端口");
- return;
- }
- }
- else
- { //网口通讯方式
- switch (pDoc->m_NetParam.TCPPrtType)
- {
- case pDoc->m_NetParam.TCPServer:
- pDoc->m_pSrvSocketObj = new CDAServerSocket(pView->GetSafeHwnd());
- if ( pDoc->m_pSrvSocketObj->OpenPort(pDoc->m_NetParam.LocalIPPort,pDoc->m_NetParam.LocalIPAddr) )
- IsCmmConnect = true;
- else
- {
- AfxMessageBox("无法创建 " + pDoc->m_NetParam.LocalIPAddr + "服务端口");
- return;
- }
- break;
-
- case pDoc->m_NetParam.TCPClient:
-
- if(pDoc->m_pCltSocketObj != NULL)
- {
- pDoc->m_pCltSocketObj->ClosePort();
- delete pDoc->m_pCltSocketObj;
- pDoc->m_pCltSocketObj = NULL;
- }
-
- pDoc->m_pCltSocketObj = new CDAClientSocket(pView->GetSafeHwnd());
- if (pDoc->m_pCltSocketObj->OpenPort(pDoc->m_NetParam.RemoteIPPort,pDoc->m_NetParam.RemoteIPAddr))
- {
- }
- else
- {
- AfxMessageBox("无法创建网络端口");
- return;
- }
- break;
-
- case pDoc->m_NetParam.UDP:
- pDoc->m_pUDPSocketObj = new CDAUDPSocket(pView->GetSafeHwnd());
- if ( pDoc->m_pUDPSocketObj->OpenPort(pDoc->m_NetParam.LocalIPPort) )
- {
- IsCmmConnect = true;
- pView->m_pSocketObj = (CAsyncSocket*)pDoc->m_pUDPSocketObj;
- if ( (pView->m_pPrtObj != NULL) && (pDoc->m_MasterFlag) ) //主站时启动召唤定时器
- pView->m_pPrtObj->StartTimer();
- }
- else
- {
- AfxMessageBox("无法打开网络端口,请重试 ");
- return;
- }
- break;
-
- default:
- break;
- }
- }
- }
- //绘制各页的电子表格; 及遥控对话窗口
- void CMainFrame::DrawGrid()
- {
- CYXData* pYXDlg;
- CYCData* pYCDlg;
- CYMData* pYMDlg;
- CYKData* pYKDlg;
-
- //获取各页的指针
- pYXDlg = (CYXData*)m_TabCtrl.GetPagePoint(0);
- pYCDlg = (CYCData*)m_TabCtrl.GetPagePoint(1);
- pYMDlg = (CYMData*)m_TabCtrl.GetPagePoint(2);
- pYKDlg = (CYKData*)m_TabCtrl.GetPagePoint(3);
-
- //各页绘制表格
- pYXDlg->DrawYXGrid();
- pYCDlg->DrawYCGrid();
- pYMDlg->DrawYMGrid();
- //加载各页控件参数
- pYXDlg->UpdateYXChara(FALSE);
- pYKDlg->UpdateYKChara(FALSE);
- }
- //更新YX电子表格数据
- void CMainFrame::UpdateYXGrid()
- {
- CYXData* pYXDlg;
- pYXDlg = (CYXData*)m_TabCtrl.GetPagePoint(0);
- pYXDlg->UpdateYXGrid();
- }
- void CMainFrame::UpdateYCGrid()
- {
- CYCData* pYCDlg;
- pYCDlg = (CYCData*)m_TabCtrl.GetPagePoint(1);
- pYCDlg->UpdateYCGrid();
- }
- void CMainFrame::UpdateYMGrid()
- {
- CYMData* pYMDlg;
- pYMDlg = (CYMData*)m_TabCtrl.GetPagePoint(2);
- pYMDlg->UpdateYMGrid();
- }
- //断开通讯连接
- void CMainFrame::OnDisconncmm()
- {
- CPeugeotDoc* pDoc = (CPeugeotDoc*)GetActiveDocument(); //文档指针 主框架类函数;
- CPeugeotView* pView = (CPeugeotView*)GetActiveView(); //视图指针;
-
- if ( (pView->m_pPrtObj != NULL) && (pDoc->m_MasterFlag) ) //主站时关闭召唤定时器
- pView->m_pPrtObj->CloseTimer();
- pView->m_pSocketObj = NULL;
- if (pDoc->m_CmmPortType == pDoc->CommPort)
- pDoc->m_ComObj.ClosePort();
- else
- { //网口通讯方式
- if(pDoc->m_pSrvSocketObj != NULL)
- {
- pDoc->m_pSrvSocketObj->ClosePort();
- delete pDoc->m_pSrvSocketObj;
- pDoc->m_pSrvSocketObj = NULL;
- }
- if(pDoc->m_pCltSocketObj != NULL)
- {
- pDoc->m_pCltSocketObj->ClosePort();
- delete pDoc->m_pCltSocketObj;
- pDoc->m_pCltSocketObj = NULL;
- }
- if(pDoc->m_pUDPSocketObj != NULL)
- {
- pDoc->m_pUDPSocketObj->ClosePort();
- delete pDoc->m_pUDPSocketObj;
- pDoc->m_pUDPSocketObj = NULL;
- }
- }
- IsCmmConnect = false;
- }
- void CMainFrame::OnUpdateConcmm(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(!IsCmmConnect);
- }
- void CMainFrame::OnUpdateDisconcmm(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(IsCmmConnect);
- }
- void CMainFrame::OnClose()
- {
- if (IsCmmConnect)
- OnDisconncmm();
- CFrameWnd::OnClose();
- }
- //底部消息窗口显示信息
- void CMainFrame::DisplayEvent(UINT nflag, CString s2)
- {
- CTime t = CTime::GetCurrentTime();
- CString s0;
- CString s1;
- s0 = t.Format("%y-%m-%d %H:%M:%S");
- if (nflag == 1)
- s1 = "主站操作";
- else if (nflag == 2)
- s1 = "子站应答";
- else if (nflag == 3)
- s1 = "通道事件";
- else
- s1 = "其它类型";
-
- m_MsgList.InsertItem(LVIF_TEXT|LVIF_STATE, 0, s0, 0, LVIS_SELECTED,0, 0);
- m_MsgList.SetItemText(0,1,s1);
- m_MsgList.SetItemText(0,2,s2);
-
- int i;
- i = m_MsgList.GetItemCount();
- if (i>8)
- m_MsgList.DeleteItem(i-1);
- }
- void CMainFrame::OnViewData()
- {
- ShowControlBar(&m_wndMyBar1, !m_wndMyBar1.IsVisible(), FALSE);
- }
- void CMainFrame::OnViewMessage()
- {
- ShowControlBar(&m_wndMyBar2, !m_wndMyBar2.IsVisible(), FALSE);
- }
- void CMainFrame::OnUpdateViewData(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable();
- pCmdUI->SetCheck(m_wndMyBar1.IsVisible());
- }
- void CMainFrame::OnUpdateViewMessage(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable();
- pCmdUI->SetCheck(m_wndMyBar2.IsVisible());
- }
- void CMainFrame::OnPauseDsp()
- {
- IsReflashMsg = false;
- }
- void CMainFrame::OnReflashDsp()
- {
- IsReflashMsg = true;
- }
- void CMainFrame::OnUpdatePauseDsp(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(IsReflashMsg);
- }
- void CMainFrame::OnUpdateReflashDsp(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(!IsReflashMsg);
- }
- void CMainFrame::OnClearDsp()
- {
- CPeugeotView* pView = (CPeugeotView*)GetActiveView(); //视图指针;
- pView->ClearMsg();
- }
- void CMainFrame::SetCmmPort()
- {
- CSettingCmmDlg CmmDlg;
- if (CmmDlg.DoModal()==IDOK) // TODO: 保存通讯对话框设置的参数
- {
- CPeugeotDoc* pDoc;
- pDoc = (CPeugeotDoc*)GetActiveDocument();
- ASSERT_VALID(pDoc);
-
- if (CmmDlg.m_CmmType == 0)
- { // 串口参数 dcb
- pDoc->m_CmmPortType = pDoc->CommPort;
- pDoc->m_ComObj.m_szPortName = CmmDlg.m_sPortName ;
- pDoc->m_ComObj.m_nParity = CmmDlg.m_Parity ;
- pDoc->m_ComObj.m_nDataBits = CmmDlg.m_ByteSize+4 ;
- pDoc->m_ComObj.m_nStopBits = CmmDlg.m_StopBits ;
- switch (CmmDlg.m_BaudRate)
- {
- case 0:
- pDoc->m_ComObj.m_nBaudRate = CBR_300;
- break;
- case 1:
- pDoc->m_ComObj.m_nBaudRate = CBR_600;
- break;
- case 2:
- pDoc->m_ComObj.m_nBaudRate = CBR_1200;
- break;
- case 3:
- pDoc->m_ComObj.m_nBaudRate = CBR_2400;
- break;
- case 4:
- pDoc->m_ComObj.m_nBaudRate = CBR_4800;
- break;
- case 5:
- pDoc->m_ComObj.m_nBaudRate = CBR_9600;
- break;
- case 6:
- pDoc->m_ComObj.m_nBaudRate = CBR_14400;
- break;
- case 7:
- pDoc->m_ComObj.m_nBaudRate = CBR_19200;
- break;
- case 8:
- pDoc->m_ComObj.m_nBaudRate = CBR_38400;
- break;
- case 9:
- pDoc->m_ComObj.m_nBaudRate = CBR_56000;
- break;
- case 10:
- pDoc->m_ComObj.m_nBaudRate = CBR_57600;
- break;
- case 11:
- pDoc->m_ComObj.m_nBaudRate = CBR_115200;
- break;
- default:
- pDoc->m_ComObj.m_nBaudRate = CBR_9600;
- break;
- }
- }
- else
- { // 网口参数
- pDoc->m_CmmPortType = pDoc->NetPort;
- switch (CmmDlg.m_TCPIPPrtType)
- {
- case 0:
- pDoc->m_NetParam.TCPPrtType = pDoc->m_NetParam.TCPServer;
- break;
- case 1:
- pDoc->m_NetParam.TCPPrtType = pDoc->m_NetParam.TCPClient;
- break;
- case 2:
- pDoc->m_NetParam.TCPPrtType = pDoc->m_NetParam.UDP;
- break;
- default:
- pDoc->m_NetParam.TCPPrtType = pDoc->m_NetParam.TCPServer;
- break;
- }
- pDoc->m_NetParam.RemoteIPPort = CmmDlg.m_RemoteIPPort;
- pDoc->m_NetParam.LocalIPPort = CmmDlg.m_LocalIPPort;
- pDoc->m_NetParam.RemoteIPAddr = CmmDlg.m_sRemoteIPAddr;
- pDoc->m_NetParam.LocalIPAddr = CmmDlg.m_sLocalIPAddr;
- }
- }
- }
- void CMainFrame::OnSize(UINT nType, int cx, int cy)
- {
- CFrameWnd::OnSize(nType, cx, cy);
-
- if (!IsFrameCreat)
- return;
- else
- {
- CYXData* pYXDlg;
- CYCData* pYCDlg;
- CYMData* pYMDlg;
- // CYKData* pYKDlg;
-
- //获取各页的指针
- pYXDlg = (CYXData*)m_TabCtrl.GetPagePoint(0);
- pYCDlg = (CYCData*)m_TabCtrl.GetPagePoint(1);
- pYMDlg = (CYMData*)m_TabCtrl.GetPagePoint(2);
- // pYKDlg = (CYKData*)m_TabCtrl.GetPagePoint(3);
-
- //各页绘制表格
- pYXDlg->ReDrawCtr();
- pYCDlg->ReDrawCtr();
- pYMDlg->ReDrawCtr();
- }
- }