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

📄 plcwnddlg.cpp

📁 波峰焊后台控制软件-中文版
💻 CPP
字号:
// PlcWndDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "PlcWndDlg.h"
#include "FLADS.h"
#include "PlcInDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPlcWndDlg dialog

extern CFLADSApp theApp;
CPlcWndDlg::CPlcWndDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPlcWndDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPlcWndDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CPlcWndDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPlcWndDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPlcWndDlg, CDialog)
	//{{AFX_MSG_MAP(CPlcWndDlg)
	ON_WM_PAINT()
	ON_WM_DESTROY()
	ON_WM_LBUTTONUP()
	ON_WM_LBUTTONDBLCLK()
	ON_WM_TIMER()
	ON_EN_CHANGE(IDC_YXNUM, OnChangeYxnum)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPlcWndDlg message handlers

BOOL CPlcWndDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString  string;

    theApp.ControlMode= Plc_Window;
	string.Format(_T("%5d"),theApp.yxnum_test);
	SetDlgItemText(IDC_YXNUM,  string);

    SetTimer (Plc_TIMER,1000,NULL);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPlcWndDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	int i,j;
	LOGFONT lf;
	CFont Font, *pOldFont;
	CRect rect,mm_rect;
	CString  string;

   	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 12;
	lstrcpy(lf.lfFaceName, _T("宋体"));
	Font.CreateFontIndirect(&lf); 
    pOldFont = dc.SelectObject(&Font);


	dc.SetTextColor(RGB(0, 0, 255));
	dc.SetBkMode(TRANSPARENT);
    rect.DeflateRect(20, 20); 
	for(j=0;j<8;j++)
	{
		for(i=0;i<32;i++)
		{
		   rect.left=i*24+16;      rect.right =rect.left+16;
		   rect.top=10+j*36;       rect.bottom=rect.top+20;
		   if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,i+j*32))
		   {
		        dc.FillSolidRect(rect,RGB(255,0,0));
				dc.Draw3dRect(rect,RGB(255,255,255),RGB(96,0,0));//红色
		   }else
		   {
		        dc.FillSolidRect(rect,RGB(0,255,0));
				dc.Draw3dRect(rect,RGB(255,255,255),RGB(0,96,0));//绿色
		   }
		   string.Format(_T("%03d"),i+1+j*32);
		   ExtTextOut(dc,rect.left,rect.bottom+2,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
		}
	}

/*	dc.SetTextColor(RGB(255, 0, 255));
	for(j=0;j<2;j++)
	{
		for(i=0;i<32;i++)
		{
		   rect.left=i*24+16;          rect.right =rect.left+16;
		   rect.top=10+360+j*36;       rect.bottom=rect.top+20;
		   if(theApp.yxtask.BitTestChar(theApp.yxtask.outbuf,i+j*32))
		   {
		        dc.FillSolidRect(rect,RGB(255,0,0));
				dc.Draw3dRect(rect,RGB(255,255,255),RGB(96,0,0));//红色
		   }else
		   {
		        dc.FillSolidRect(rect,RGB(0,255,0));
				dc.Draw3dRect(rect,RGB(255,255,255),RGB(0,96,0));//绿色
		   }
		   string.Format(_T("%03d"),i+1+j*32);
		   ExtTextOut(dc,rect.left,rect.bottom+2,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
		}
	}
	*/
	dc.SelectObject(pOldFont);

}

	





void CPlcWndDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
    KillTimer(Plc_TIMER);	
}

void CPlcWndDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	int i,j,x,y;
	CRect rect;
	x=point.x;
	y=point.y;

	for(j=0;j<8;j++)
	{
		for(i=0;i<32;i++)
		{
		   rect.left=i*24+16;      rect.right =rect.left+16;
		   rect.top=10+j*36;       rect.bottom=rect.top+20;
		   if((x>rect.left)&&(x<rect.right))
		   {
				if((y<rect.bottom)&&(y>rect.top))
				{
					    theApp.krnum=i+j*32;
						CPlcInDlg	dlg;
						dlg.DoModal();
				}
		   }
		}
	}

	
/*	for(j=0;j<2;j++)
	{
		for(i=0;i<32;i++)
		{
		   rect.left=i*24+16;          rect.right =rect.left+16;
		   rect.top=10+360+j*36;       rect.bottom=rect.top+20;
		   if((x>rect.left)&&(x<rect.right))
		   {
				if((y<rect.bottom)&&(y>rect.top))
				{
						CPlcInDlg	dlg;
						dlg.DoModal();					
				}
		   }
		}
	}*/
	CDialog::OnLButtonUp(nFlags, point);
}

void CPlcWndDlg::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	AfxMessageBox(_T("MOUSE"));
	int i,j,x,y;
	CRect rect;
	x=point.x;
	y=point.y;

	for(j=0;j<8;j++)
	{
		for(i=0;i<32;i++)
		{
		   rect.left=i*24+16;      rect.right =rect.left+16;
		   rect.top=10+j*36;       rect.bottom=rect.top+20;
		   if((x>rect.left)&&(x<rect.right))
		   {
				if((y<rect.bottom)&&(y>rect.top))
				{
						CPlcInDlg	dlg;
						dlg.DoModal();
				}
		   }
		}
	}

	
/*	for(j=0;j<2;j++)
	{
		for(i=0;i<32;i++)
		{
		   rect.left=i*24+16;          rect.right =rect.left+16;
		   rect.top=10+360+j*36;       rect.bottom=rect.top+20;
		   if((x>rect.left)&&(x<rect.right))
		   {
				if((y<rect.bottom)&&(y>rect.top))
				{
						CPlcInDlg	dlg;
						dlg.DoModal();					
				}
		   }
		}
	}
*/	
	CDialog::OnLButtonDblClk(nFlags, point);
}

void CPlcWndDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CString  string;
	int i,j;

	Invalidate(false);
	string.Format(_T("%6.3f"),theApp.yxtask.dms/1000);
	SetDlgItemText(IDC_TEST,  string);
	i=theApp.yxnum_test/8;
	j=theApp.yxnum_test%8;


	string.Format(_T("%03x"),theApp.yxtask.newkr[i]);
	SetDlgItemText(IDC_NEWBUF,  string);

	string.Format(_T("%03x"),theApp.yxtask.yxbuf[i]);
	SetDlgItemText(IDC_YXBUF,  string);

	string.Format(_T("%03x"),theApp.yxtask.con_in[theApp.yxnum_test].B.type);
	SetDlgItemText(IDC_TYPE,  string);

	string.Format(_T("%03x"),theApp.yxtask.con_in[theApp.yxnum_test].B.kgbf);
	SetDlgItemText(IDC_KGBF,  string);

	string.Format(_T("%05d"),theApp.yxtask.up_time[theApp.yxnum_test]);
	SetDlgItemText(IDC_UPTIME,  string);

	string.Format(_T("%05d"),theApp.yxtask.dn_time[theApp.yxnum_test]);
	SetDlgItemText(IDC_DNTIME,  string);

	string.Format(_T("%05d"),theApp.yxtask.ms_count[theApp.yxnum_test]);
	SetDlgItemText(IDC_MSCOUNT,  string);

	string.Format(_T("%05d"),theApp.yxtask.bvtm[theApp.yxnum_test]);
	SetDlgItemText(IDC_BVTM,  string);

	string.Format(_T("%03x"),theApp.yxtask.chgkr[theApp.yxnum_test]);
	SetDlgItemText(IDC_CHGKR,  string);

	string.Format(_T("%03x"),theApp.yxtask.ysfg[theApp.yxnum_test]);
	SetDlgItemText(IDC_YSFG,  string);

	string.Format(_T("%03x"),theApp.yxtask.yscon[theApp.yxnum_test]);
	SetDlgItemText(IDC_YSCON,  string);

	string.Format(_T("%06d"),theApp.yxtask.mulse[theApp.yxnum_test]);
	SetDlgItemText(IDC_YMBUF,  string);

	string.Format(_T("%06d"),theApp.plc_con_ret[0]);
	SetDlgItemText(IDC_TEST1,  string);

	string.Format(_T("%06d"),  theApp.pw_len_ret);
	SetDlgItemText(IDC_TEST2,  string);

	string.Format(_T("%06d"),  theApp.rh1_switch);
	SetDlgItemText(IDC_TEST3,  string);

	string.Format(_T("%06d"),theApp.plc_con_ret[1]);
	SetDlgItemText(IDC_TEST4,  string);

	string.Format(_T("%06x"),theApp.ykout[0]);
	SetDlgItemText(IDC_TEST5,  string);

	string.Format(_T("%06x"),theApp.ykout[1]);
	SetDlgItemText(IDC_TEST6,  string);

	string.Format(_T("%06x"),theApp.ykout[2]);
	SetDlgItemText(IDC_TEST7,  string);

	string.Format(_T("%06x"),theApp.ykout[3]);
	SetDlgItemText(IDC_TEST8,  string);


	string.Format(_T("%06d"),theApp.test_ws[0]);
	SetDlgItemText(IDC_TEST9,  string);

	string.Format(_T("%06d"),theApp.test_ws[1]);
	SetDlgItemText(IDC_TEST10,  string);

	string.Format(_T("%06d"),theApp.test_ws[2]);
	SetDlgItemText(IDC_TEST11,  string);

	string.Format(_T("%06d"),theApp.test_ws[3]);
	SetDlgItemText(IDC_TEST12,  string);

	string.Format(_T("%06d"),theApp.test_ws[4]);
	SetDlgItemText(IDC_TEST13,  string);

	CDialog::OnTimer(nIDEvent);
}

void CPlcWndDlg::OnChangeYxnum() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function to send the EM_SETEVENTMASK message to the control
	// with the ENM_CHANGE flag ORed into the lParam mask.
	
	// TODO: Add your control notification handler code here
    unsigned short wBuf[32];
	GetDlgItemText(IDC_YXNUM,wBuf,20);
    theApp.yxnum_test=_wtoi(wBuf);
}

⌨️ 快捷键说明

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