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

📄 cbubblelvhongview.cpp

📁 此程序完成的是随即画出泡泡的程序
💻 CPP
字号:
// CBubbleLvhongView.cpp : implementation of the CCBubbleLvhongView class
//

#include "stdafx.h"
#include "CBubbleLvhong.h"

#include "CBubbleLvhongDoc.h"
#include "CBubbleLvhongView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCBubbleLvhongView

IMPLEMENT_DYNCREATE(CCBubbleLvhongView, CView)

BEGIN_MESSAGE_MAP(CCBubbleLvhongView, CView)
	//{{AFX_MSG_MAP(CCBubbleLvhongView)
	ON_WM_LBUTTONDOWN()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CCBubbleLvhongView construction/destruction

CCBubbleLvhongView::CCBubbleLvhongView()
{
	// TODO: add construction code here

}

CCBubbleLvhongView::~CCBubbleLvhongView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CCBubbleLvhongView drawing

void CCBubbleLvhongView::OnDraw(CDC* pDC)
{
	CCBubbleLvhongDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	//pDC->SelectStockObject(LTGRAY_BRUSH);
     //CPen NewPen ,*OldPen;
	 //NewPen.CreatePen(PS_DASHDOTDOT,3,RGB(0,255,255));
	 //OldPen=pDC->SelectObject(&NewPen);
     CBrush br(HS_DIAGCROSS  ,RGB(255,255,0));
	 CBrush *pbrOld=pDC->SelectObject(&br);
	for(int i=0;i<pDoc->GetListSize();i++)
	{
		pDC->Ellipse(pDoc->GetBubble(i));
	}
	pDC->SelectObject(pbrOld);
}

/////////////////////////////////////////////////////////////////////////////
// CCBubbleLvhongView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CCBubbleLvhongView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CCBubbleLvhongView message handlers

void CCBubbleLvhongView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CCBubbleLvhongDoc* pDoc=GetDocument();//得到文档的一个指针
	ASSERT_VALID(pDoc);
	int r=rand()%50+5;//生成泡泡
	CRect rectBubble(point.x-r,point.y-r,point.x+r,point.y+r);
	pDoc->AddBubble(rectBubble);
	pDoc->SetModifiedFlag();
	InvalidateRect(rectBubble,FALSE);
	CView::OnLButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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