www.pudn.com > IEC104_codeamaterial.rar > DlgLink.cpp, change:2010-12-10,size:9959b
// DlgLink.cpp : implementation file // #include "stdafx.h" #include "Gb104.h" #include "DlgLink.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDlgLink dialog CDlgLink::CDlgLink(CWnd* pParent /*=NULL*/) : CDialog(CDlgLink::IDD, pParent) { //{{AFX_DATA_INIT(CDlgLink) m_ip = _T(""); m_addr = 0; m_port = 0; m_act = _T(""); m_type = _T(""); m_dot = 0; m_date = 0; m_time = 0; m_groupnum = 0; m_paradot = 0; m_paraval = 0; m_para = _T(""); m_ddflag = 0; m_frz = _T(""); //}}AFX_DATA_INIT } void CDlgLink::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlgLink) DDX_Text(pDX, IDC_EDIT1, m_ip); DDX_Text(pDX, IDC_EDIT3, m_addr); DDX_Text(pDX, IDC_EDIT2, m_port); DDX_CBString(pDX, IDC_COMBO1, m_act); DDX_CBString(pDX, IDC_COMBO2, m_type); DDX_Text(pDX, IDC_EDIT4, m_dot); DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_date); DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER2, m_time); DDX_Text(pDX, IDC_EDIT5, m_groupnum); DDX_Text(pDX, IDC_EDIT6, m_paradot); DDX_Text(pDX, IDC_EDIT7, m_paraval); DDX_CBString(pDX, IDC_COMBO3, m_para); DDX_Text(pDX, IDC_EDIT8, m_ddflag); DDX_CBString(pDX, IDC_COMBO4, m_frz); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDlgLink, CDialog) //{{AFX_MSG_MAP(CDlgLink) ON_WM_HSCROLL() ON_WM_VSCROLL() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 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_BUTTON6, OnButton6) ON_BN_CLICKED(IDC_BUTTON7, OnButton7) ON_BN_CLICKED(IDC_BUTTON8, OnButton8) ON_BN_CLICKED(IDC_BUTTON9, OnButton9) ON_BN_CLICKED(IDC_BUTTON10, OnButton10) ON_BN_CLICKED(IDC_BUTTON12, OnButton12) ON_BN_CLICKED(IDC_BUTTON11, OnButton11) ON_BN_CLICKED(IDC_BUTTON13, OnButton13) ON_BN_CLICKED(IDC_BUTTON14, OnButton14) ON_BN_CLICKED(IDC_BUTTON15, OnButton15) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDlgLink message handlers void CDlgLink::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default int nCurPos; int nPrevPos; CRect rect; GetClientRect(&rect); nPrevPos = GetScrollPos(SB_HORZ); nCurPos = nPrevPos; switch(nSBCode) { case SB_LEFT: SetScrollPos(SB_HORZ, 0); ScrollWindow(0, 0); break; case SB_RIGHT: SetScrollPos(SB_HORZ, 100); ScrollWindow(-rect.Width(), 0); break; case SB_PAGELEFT: nCurPos = nPrevPos - 10; if(nCurPos < 0) nCurPos = 0; SetScrollPos(SB_HORZ, nCurPos); break; case SB_PAGERIGHT: nCurPos = nPrevPos + 10; if(nCurPos > 100) nCurPos = 100; SetScrollPos(SB_HORZ, nCurPos); break; case SB_THUMBPOSITION: SetScrollPos(SB_HORZ, nPos); break; case SB_THUMBTRACK: break; case SB_LINELEFT: nCurPos = nPrevPos - 2; if(nCurPos < 0) nCurPos = 0; SetScrollPos(SB_HORZ, nCurPos); break; case SB_LINERIGHT: nCurPos = nPrevPos + 2; if(nCurPos > 100) nCurPos = 100; SetScrollPos(SB_HORZ, nCurPos); break; case SB_ENDSCROLL: break; } nCurPos = GetScrollPos(SB_HORZ); ScrollWindow(rect.Width() * (nPrevPos - nCurPos) / 100, 0); CDialog::OnHScroll(nSBCode, nPos, pScrollBar); } void CDlgLink::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default int nCurPos; int nPrevPos; CRect rect; GetClientRect(&rect); nPrevPos = GetScrollPos(SB_VERT); nCurPos = nPrevPos; switch(nSBCode) { case SB_LEFT: SetScrollPos(SB_VERT, 0); ScrollWindow(0, 0); break; case SB_RIGHT: SetScrollPos(SB_VERT, 100); ScrollWindow(-rect.Height(), 0); break; case SB_PAGELEFT: nCurPos = nPrevPos - 10; if(nCurPos < 0) nCurPos = 0; SetScrollPos(SB_VERT, nCurPos); break; case SB_PAGERIGHT: nCurPos = nPrevPos + 10; if(nCurPos > 100) nCurPos = 100; SetScrollPos(SB_VERT, nCurPos); break; case SB_THUMBPOSITION: SetScrollPos(SB_VERT, nPos); break; case SB_THUMBTRACK: break; case SB_LINELEFT: nCurPos = nPrevPos - 2; if(nCurPos < 0) nCurPos = 0; SetScrollPos(SB_VERT, nCurPos); break; case SB_LINERIGHT: nCurPos = nPrevPos + 2; if(nCurPos > 100) nCurPos = 100; SetScrollPos(SB_VERT, nCurPos); break; case SB_ENDSCROLL: break; } nCurPos = GetScrollPos(SB_VERT); ScrollWindow(0, rect.Height() * (nPrevPos - nCurPos) / 100); CDialog::OnVScroll(nSBCode, nPos, pScrollBar); } void CDlgLink::OnButton1() { // TODO: Add your control notification handler code here UpdateData(); ::PostMessage(hWnd,NET_LINK,0,0); } BOOL CDlgLink::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_ip="192.168.1.1"; m_port=2404; m_addr=254; m_date=CTime::GetCurrentTime(); m_time=CTime::GetCurrentTime(); UpdateData(false); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDlgLink::OnButton2() { // TODO: Add your control notification handler code here UpdateData(); ::PostMessage(hWnd,WIN_GB104,1,1); } void CDlgLink::OnButton3() { // TODO: Add your control notification handler code here UpdateData(); ::PostMessage(hWnd,WIN_GB104,2,2); } void CDlgLink::OnButton4() { // TODO: Add your control notification handler code here UpdateData(); DWORD tmp; if(m_act=="合") m_iact=1; else m_iact=0; if(m_act=="单点") m_itype=45; else m_itype=46; m_iact|=0x80; tmp=m_iact; tmp<<=8; tmp|=m_dot; tmp<<=8; tmp|=6; tmp<<=8; tmp|=m_itype; ::PostMessage(hWnd,WIN_GB104,3,tmp); } void CDlgLink::OnButton5() { // TODO: Add your control notification handler code here UpdateData(); DWORD tmp; if(m_act=="合") m_iact=1; else m_iact=0; if(m_act=="单点") m_itype=45; else m_itype=46; tmp=m_iact; tmp<<=8; tmp|=m_dot; tmp<<=8; tmp|=6; tmp<<=8; tmp|=m_itype; ::PostMessage(hWnd,WIN_GB104,3,tmp); } void CDlgLink::OnButton6() { // TODO: Add your control notification handler code here UpdateData(); DWORD tmp; if(m_act=="合") m_iact|=1; else m_iact&=0xfe; if(m_act=="单点") m_itype=45; else m_itype=46; tmp=m_iact; tmp<<=8; tmp|=m_dot; tmp<<=8; tmp|=8; tmp<<=8; tmp|=m_itype; ::PostMessage(hWnd,WIN_GB104,3,tmp); } void CDlgLink::OnButton7() { // TODO: Add your control notification handler code here UpdateData(); ::PostMessage(hWnd,WIN_GB104,4,m_groupnum+20); } void CDlgLink::OnButton8() { // TODO: Add your control notification handler code here DWORD tmp; UpdateData(); tmp=m_date.GetDay(); tmp<<=8; tmp|=m_time.GetHour(); tmp<<=8; tmp|=m_time.GetMinute(); tmp<<=8; tmp|=m_time.GetSecond(); ::PostMessage(hWnd,WIN_GB104,5,tmp); } void CDlgLink::OnButton9() { // TODO: Add your control notification handler code here UpdateData(); ::PostMessage(hWnd,WIN_GB104,6,m_groupnum+20); } void CDlgLink::OnButton10() { // TODO: Add your control notification handler code here ::PostMessage(hWnd,WIN_GB104,7,0); } void CDlgLink::OnButton12() { // TODO: Add your control notification handler code here UpdateData(); DWORD tmp; tmp=m_paradot/1000; tmp<<=4; m_paradot%=1000; tmp|=m_paradot/100; tmp<<=4; m_paradot%=100; tmp|=m_paradot/10; tmp<<=4; m_paradot%=10; tmp|=m_paradot; tmp<<=16; tmp|=m_paraval; ::PostMessage(hWnd,WIN_GB104,8,tmp); } void CDlgLink::OnButton11() { // TODO: Add your control notification handler code here UpdateData(); DWORD tmp; tmp=m_paradot/1000; tmp<<=4; m_paradot%=1000; tmp|=m_paradot/100; tmp<<=4; m_paradot%=100; tmp|=m_paradot/10; tmp<<=4; m_paradot%=10; tmp|=m_paradot; tmp<<=16; tmp|=m_paraval; if(m_para=="门限") { m_paraindex=1; } if(m_para=="滤波时间") { m_paraindex=2; } if(m_para=="上限") { m_paraindex=3; } if(m_para=="下限") { m_paraindex=4; } ::PostMessage(hWnd,WIN_GB104,0,(long)&m_paraindex); ::PostMessage(hWnd,WIN_GB104,9,tmp); } void CDlgLink::OnButton13() { // TODO: Add your control notification handler code here UpdateData(); DWORD tmp; tmp=m_paradot/1000; tmp<<=4; m_paradot%=1000; tmp|=m_paradot/100; tmp<<=4; m_paradot%=100; tmp|=m_paradot/10; tmp<<=4; m_paradot%=10; tmp|=m_paradot; ::PostMessage(hWnd,WIN_GB104,10,tmp); } void CDlgLink::OnButton14() { // TODO: Add your control notification handler code hered UpdateData(); DWORD tmp; if(m_frz=="3") tmp=2; else if(m_frz=="2") tmp=1; else tmp=0; tmp<<=6; tmp|=m_groupnum+1; tmp<<=8; tmp|=m_ddflag; ::PostMessage(hWnd,WIN_GB104,11,tmp); } void CDlgLink::OnButton15() { // TODO: Add your control notification handler code here ::PostMessage(hWnd,WIN_GB104,12,0); }