📄 testwnddlg.cpp
字号:
// TestWndDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "TestWndDlg.h"
#include "FLADS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTestWndDlg dialog
extern CFLADSApp theApp;
CTestWndDlg::CTestWndDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestWndDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestWndDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CTestWndDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestWndDlg)
// DDX_Control(pDX, IDC_TESTIMAGE, m_testimage);
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestWndDlg, CDialog)
//{{AFX_MSG_MAP(CTestWndDlg)
ON_WM_TIMER()
ON_WM_DESTROY()
ON_WM_CTLCOLOR()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestWndDlg message handlers
BOOL CTestWndDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
theApp.ControlMode= Test_Window;
SetTimer(Test_TIMER,500,NULL);
hbrush=CreateSolidBrush(RGB(0, 167, 192));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTestWndDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
Invalidate(false);
CDialog::OnTimer(nIDEvent);
}
void CTestWndDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
KillTimer(Test_Window);
DeleteObject(hbrush);
}
HBRUSH CTestWndDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return hbrush;
return hbr;
}
void CTestWndDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
int i,dx,dy,j;
unsigned char ch;
CString string;
CRect mm_rect;
mm_rect.left=0;
mm_rect.right=0;
mm_rect.top=0;
mm_rect.bottom=0;
GetClientRect(&m_rectClient);
dc.SetBkColor(RGB(0, 167, 192));
dc.SetBkMode(OPAQUE);
if(theApp.TestFlash!=0)
{
theApp.TestFlash=0;
flash=0;
}
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap* pOld;
// 0--------入板光感
// 1--------急停
// 2--------编码信号
// 3--------噴头左限 原点
// 4--------噴头右限 顶点
// 5--------运输马达过载
// 6--------
// 7--------排风马达过载
// 8--------波峰马达1
// 9--------波峰马达2
//10--------调机测试
// theApp.yxbuf00=RxdBuffer[6];
// theApp.yxbuf01=RxdBuffer[7];
// Warninformatiom[16]=_T("波峰马达1启动");
// Warninformatiom[17]=_T("编码信号");
// Warninformatiom[18]=_T("喷头原点");
// Warninformatiom[19]=_T("喷头终点");
// Warninformatiom[20]=_T("入板检知");
LOGFONT lf;
CFont Font, *PtrOldFont;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 24;
lstrcpy(lf.lfFaceName, _T("宋体"));
Font.CreateFontIndirect(&lf);
PtrOldFont = dc.SelectObject(&Font);//--
dc.SetTextColor(RGB(0, 0, 0));
dx=0; dy=40; string=_T("入板光感");
if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,20))
{//红色
pOld = memDC.SelectObject(theApp.fillbitmap[165]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}else
{//绿色
pOld = memDC.SelectObject(theApp.fillbitmap[164]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(pOld);
ExtTextOut(dc,m_rectClient.left+15+dx,m_rectClient.top+dy+40,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
dx=150*1; dy=40;
string=_T("紧急停止");
if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,1))
{//红色
pOld = memDC.SelectObject(theApp.fillbitmap[165]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}else
{//绿色
pOld = memDC.SelectObject(theApp.fillbitmap[164]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(pOld);
ExtTextOut(dc,m_rectClient.left+15+dx,m_rectClient.top+dy+40,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
dx=150*2; dy=40;
string=_T("编码信号");
if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,17))
{//红色
pOld = memDC.SelectObject(theApp.fillbitmap[165]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}else
{//绿色
pOld = memDC.SelectObject(theApp.fillbitmap[164]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(pOld);
ExtTextOut(dc,m_rectClient.left+15+dx,m_rectClient.top+dy+40,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
dx=150*3; dy=40;
string=_T("噴头原点");
if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,18))
{//红色
pOld = memDC.SelectObject(theApp.fillbitmap[165]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}else
{//绿色
pOld = memDC.SelectObject(theApp.fillbitmap[164]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(pOld);
ExtTextOut(dc,m_rectClient.left+15+dx,m_rectClient.top+dy+40,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
dx=150*4; dy=40; string=_T("噴头终点");
if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,19))
{//红色
pOld = memDC.SelectObject(theApp.fillbitmap[165]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}else
{//绿色
pOld = memDC.SelectObject(theApp.fillbitmap[164]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(pOld);
ExtTextOut(dc,m_rectClient.left+15+dx,m_rectClient.top+dy+40,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
dx=0; dy=120; string=_T("运输马达过载");
if(theApp.yxtask.BitTestChar(theApp.yxtask.yxbuf,5))
{//红色
pOld = memDC.SelectObject(theApp.fillbitmap[165]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}else
{//绿色
pOld = memDC.SelectObject(theApp.fillbitmap[164]);
if (pOld == NULL)return; // destructors will clean up
dc.BitBlt(m_rectClient.left+40+dx, m_rectClient.top+dy, m_rectClient.Width(), m_rectClient.Height(),
&memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(pOld);
ExtTextOut(dc,m_rectClient.left+15+dx,m_rectClient.top+dy+40,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -