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

📄 wodezuoyeview.cpp

📁 VC++6.0自编程序
💻 CPP
字号:
// WoDeZuoYeView.cpp : implementation of the CWoDeZuoYeView class
//

#include "stdafx.h"
#include "WoDeZuoYe.h"

#include "WoDeZuoYeDoc.h"
#include "WoDeZuoYeView.h"
#include "cout.h"

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

/////////////////////////////////////////////////////////////////////////////
// CWoDeZuoYeView

IMPLEMENT_DYNCREATE(CWoDeZuoYeView, CView)

BEGIN_MESSAGE_MAP(CWoDeZuoYeView, CView)
	//{{AFX_MSG_MAP(CWoDeZuoYeView)
	ON_COMMAND(ID_Menu_Line, OnMenuLine)
	ON_COMMAND(ID_Menu_Rec, OnMenuRec)
	ON_COMMAND(ID_Menu_Ell, OnMenuEll)
	ON_WM_LBUTTONDOWN()
	ON_WM_CANCELMODE()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	ON_WM_CAPTURECHANGED()
	ON_WM_CHAR()
	ON_COMMAND(ID_Menu_Text, OnMenuText)
	ON_WM_CREATE()
	ON_WM_CONTEXTMENU()
	ON_COMMAND(ID_Menu_Count, OnMenuCount)
	ON_COMMAND(ID_Menu_JSQ2, OnMenuJSQ2)
	ON_COMMAND(ID_Menu_Word2, OnMenuWord2)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWoDeZuoYeView construction/destruction

CWoDeZuoYeView::CWoDeZuoYeView()
{
	// TODO: add construction code here
     Lmouse_down=false;
	 Lmouse_up=false;
     m_flag=-1 ;
     m_n=0 ;
	 draw_down_i=0;
	 draw_up_i=0;
     m_str="" ;
     m_arg_point=caretpos=0 ;
}

CWoDeZuoYeView::~CWoDeZuoYeView()
{
}

BOOL CWoDeZuoYeView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CWoDeZuoYeView drawing

void CWoDeZuoYeView::OnDraw(CDC* pDC)
{
	CWoDeZuoYeDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CClientDC dc(this);
	int j,k,l;	
	switch(m_flag){
	case 0 :     break;
    case 1 :	
	for( j=0;j<draw_down_i;j++)
	{	dc.MoveTo(pointer_arg[j]) ; dc.LineTo(pointer_ent[j]) ; 
	}
		break;
    case 2 :  
			for( k=0;k<	draw_down_i;k++)
			{	dc.Rectangle(pointer_arg[k].x,pointer_arg[k].y,pointer_ent[k].x,pointer_ent[k].y);
			}
			break;
	case 3 :
			for( l=0;l<	draw_down_i;l++)
			{   dc.Ellipse(pointer_arg[l].x,pointer_arg[l].y,pointer_ent[l].x,pointer_ent[l].y);
			}
			break;
	}

	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CWoDeZuoYeView printing

BOOL CWoDeZuoYeView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CWoDeZuoYeView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CWoDeZuoYeView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CWoDeZuoYeView diagnostics

#ifdef _DEBUG
void CWoDeZuoYeView::AssertValid() const
{
	CView::AssertValid();
}

void CWoDeZuoYeView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CWoDeZuoYeDoc* CWoDeZuoYeView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWoDeZuoYeDoc)));
	return (CWoDeZuoYeDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CWoDeZuoYeView message handlers

void CWoDeZuoYeView::OnMenuLine() 
{
	// TODO: Add your command handler code here
	m_flag=1 ;
   	draw_down_i=0;
 	draw_up_i=0 ; 
    m_arg_point=endpoint;
	this->Invalidate();
}

void CWoDeZuoYeView::OnMenuRec() 
{
	// TODO: Add your command handler code here
	m_flag=2 ;
   	draw_down_i=0;
 	draw_up_i=0 ; 
    m_arg_point=endpoint;
	this->Invalidate();
}

void CWoDeZuoYeView::OnMenuEll() 
{
	// TODO: Add your command handler code here
	m_flag=3 ;
   	draw_down_i=0;
 	draw_up_i=0 ; 
    m_arg_point=endpoint;
	this->Invalidate();
}

void CWoDeZuoYeView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	m_arg_point=point ;
   
    pointer_arg[draw_down_i]=m_arg_point;  
    draw_down_i++ ;
	Lmouse_down=true ;
	Lmouse_up=false  ;

	caretpos=m_point2=point ;
	m_n=0;
    SetCaretPos(point) ;
    m_str="" ;


	CView::OnLButtonDown(nFlags, point);
}

void CWoDeZuoYeView::OnCancelMode() 
{
	CView::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}

void CWoDeZuoYeView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	 Lmouse_up=true ;

	Lmouse_down=false;
	CClientDC dc(this);
    endpoint=point ;
    
   pointer_ent[draw_down_i-1]=endpoint;  

	CView::OnLButtonUp(nFlags, point);
}

void CWoDeZuoYeView::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
		endpoint=point ;
  
	if(Lmouse_down==true&& Lmouse_up==false) 
	{ 	
	    pointer_ent[draw_down_i-1]=endpoint;  
		this->Invalidate(); 

	}
	CView::OnMouseMove(nFlags, point);
}

void CWoDeZuoYeView::OnCaptureChanged(CWnd *pWnd) 
{
	// TODO: Add your message handler code here
	
	CView::OnCaptureChanged(pWnd);
}

void CWoDeZuoYeView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	CClientDC dc(this);
	CSize sc;
	TEXTMETRIC tn ;
    dc.GetTextMetrics(&tn) ;
if(nChar==13) 
	{m_point2.x=0 ;
	 m_point2.y=m_point2.y+ tn.tmHeight ;
	 SetCaretPos(m_point2) ;
	 m_str="" ;
   	m_flag2=true ;
	caretpos.x=0;  //
	}


else if(nChar==8) 
{ 
    //COLORREF bclr; 
    COLORREF fclr ;
  
	fclr=dc.SetTextColor(dc.GetBkColor()) ;
   
    dc.TextOut(caretpos.x,m_point2.y,m_str);
    m_str=m_str.Left(m_str.GetLength()-1) ;
    
    dc.SetTextColor(fclr);
    
	 sc=dc.GetTextExtent(m_str);
      m_point2.x=caretpos.x+sc.cx;
			 
       SetCaretPos(m_point2) ;

	 dc.TextOut(caretpos.x,m_point2.y,m_str);
}

else  {	m_str+=nChar ;
	       
            sc=dc.GetTextExtent(nChar);
           /* if(m_flag==true)  
			{	caretpos.x=0;
				m_flag=false ;
			}    
	         */
			 m_point2.x= m_point2.x+sc.cx;
			 SetCaretPos(m_point2) ;
			 dc.TextOut(caretpos.x,m_point2.y,m_str);
			   
          }

	CView::OnChar(nChar, nRepCnt, nFlags);
}

void CWoDeZuoYeView::OnMenuText() 
{
	// TODO: Add your command handler code here
		m_flag=0 ;
}

int CWoDeZuoYeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	CClientDC dc(this);
	TEXTMETRIC tn ;
    dc.GetTextMetrics(&tn) ;
	CreateSolidCaret(tn.tmAveCharWidth/4,tn.tmHeight) ;
   if(m_flag==0) ShowCaret() ;

	return 0;
}

void CWoDeZuoYeView::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	// TODO: Add your message handler code here
	
}

void CWoDeZuoYeView::OnMenuCount() 
{
	// TODO: Add your command handler code here
	CCout m_count;
    m_count.DoModal();
}

void CWoDeZuoYeView::OnMenuJSQ2() 
{
	// TODO: Add your command handler code here
	
	//调计算器    
	WinExec("calc.exe",SW_SHOW);
}

void CWoDeZuoYeView::OnMenuWord2() 
{
	// TODO: Add your command handler code here
	//调记事本
	WinExec("notepad.exe",SW_SHOW);
}

⌨️ 快捷键说明

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