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

📄 touchview.cpp

📁 有关win32应用程序编程和wince应用程序编程的很全面
💻 CPP
字号:
// touchView.cpp : implementation of the CTouchView class//#include "stdafx.h"#include "touch.h"#include "touchDoc.h"#include "touchView.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CTouchViewIMPLEMENT_DYNCREATE(CTouchView, CView)BEGIN_MESSAGE_MAP(CTouchView, CView)	//{{AFX_MSG_MAP(CTouchView)	ON_WM_LBUTTONDOWN()	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CTouchView construction/destructionCTouchView::CTouchView(){	// TODO: add construction code here}CTouchView::~CTouchView(){}BOOL CTouchView::PreCreateWindow(CREATESTRUCT& cs){	// TODO: Modify the Window class or styles here by modifying	//  the CREATESTRUCT cs	return CView::PreCreateWindow(cs);}/////////////////////////////////////////////////////////////////////////////// CTouchView drawingvoid CTouchView::OnDraw(CDC* pDC){	CTouchDoc* pDoc = GetDocument();	ASSERT_VALID(pDoc);	// TODO: add draw code for native data here}/////////////////////////////////////////////////////////////////////////////// CTouchView diagnostics#ifdef _DEBUGvoid CTouchView::AssertValid() const{	CView::AssertValid();}void CTouchView::Dump(CDumpContext& dc) const{	CView::Dump(dc);}CTouchDoc* CTouchView::GetDocument() // non-debug version is inline{	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTouchDoc)));	return (CTouchDoc*)m_pDocument;}#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////// CTouchView message handlersvoid CTouchView::DrawCross(){	CClientDC dc(this);	dc.MoveTo(m_rect.left+15,m_rect.top);	dc.LineTo(m_rect.left+15,m_rect.bottom);	dc.MoveTo(m_rect.left,m_rect.top+15);	dc.LineTo(m_rect.right,m_rect.top+15);}void CTouchView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) {	// TODO: Add your specialized code here and/or call the base class	CRect r;	GetClientRect(&r);	CPoint point(r.Width()/2,r.Height()/2);	m_rect = CRect(point.x-15,point.y-15,point.x+15,point.y+15);	DrawCross();	CView::OnPrepareDC(pDC, pInfo);}void CTouchView::OnLButtonDown(UINT nFlags, CPoint point) {	// TODO: Add your message handler code here and/or call default	CClientDC dc(this);	int i=0;	CRect r;	GetClientRect(&r);	if(m_rect.PtInRect(point))	{		while(m_rect.top>0)		{			dc.FillSolidRect(&m_rect,RGB(255,255,255));			m_rect.top-=5;			m_rect.bottom-=5;			for(i=0;i<400000;i++);			DrawCross();		}		while(m_rect.left>0)		{			dc.FillSolidRect(&m_rect,RGB(255,255,255));			m_rect.left-=5;			m_rect.right-=5;						for(i=0;i<400000;i++);			DrawCross();		}		while(m_rect.bottom<r.Height())		{			dc.FillSolidRect(&m_rect,RGB(255,255,255));			m_rect.top+=5;			m_rect.bottom+=5;			for(i=0;i<400000;i++);			DrawCross();		}		while(m_rect.right<r.Width())		{			dc.FillSolidRect(&m_rect,RGB(255,255,255));			m_rect.left+=5;			m_rect.right+=5;			for(i=0;i<400000;i++);			DrawCross();		}		while(m_rect.top>0)		{			dc.FillSolidRect(&m_rect,RGB(255,255,255));			m_rect.top-=5;			m_rect.bottom-=5;			for(i=0;i<400000;i++);			DrawCross();		}		while(m_rect.left>r.Width()/2-15)		{			dc.FillSolidRect(&m_rect,RGB(255,255,255));			m_rect.left-=5;			m_rect.right-=5;			for(i=0;i<400000;i++);			DrawCross();		}		while(m_rect.bottom<r.Height()/2+15)		{			dc.FillSolidRect(&m_rect,RGB(255,255,255));			m_rect.top+=5;			m_rect.bottom+=5;			for(i=0;i<400000;i++);			DrawCross();		}		MessageBox(_T("Touch Screen Test OK"));	}	CView::OnLButtonDown(nFlags, point);}

⌨️ 快捷键说明

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