【VC开源代码栏目提醒】:网学会员为需要VC开源代码的朋友们搜集整理了FillRCView.cpp相关资料,希望对各位网友有所帮助!
// FillRCView.cpp : implementation of the CFillRCView class
//
#include "stdafx.h"
#include "FillRC.h"
#include "FillRCDoc.h"
#include "FillRCView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFillRCView
IMPLEMENT_DYNCREATE(CFillRCView, CView)
BEGIN_MESSAGE_MAP(CFillRCView, CView)
//{{AFX_MSG_MAP(CFillRCView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CFillRCView construction/destruction
CFillRCView::CFillRCView()
{
// TODO: add construction code here
}
CFillRCView::~CFillRCView()
{
}
BOOL CFillRCView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CFillRCView drawing
void CFillRCView::OnDraw(CDC* pDC)
{
CFillRCDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect rc(30,40,100,120);
CBrush brush(RGB(128,128,128));
//使用颜色填充区域
pDC->FillRect(rc,&brush);
brush.DeleteObject();
CBitmap bmp;
bmp.LoadBitmap(IDB_BKBITMAP);
brush.CreatePatternBrush(&bmp);
CRect bmpRC(110,40,200,120);
//使用位图填充区域
pDC->FillRect(bmpRC,&brush);
bmp.DeleteObject();
brush.DeleteObject();
//填充选区
CRect rectrc(210,40,300,120);
CRect hrc(280,60,350,140);
pDC->Rectangle(rectrc);
pDC->Rectangle(hrc);
HRGN hRect = CreateRectRgn(210,40,300,120);
HRGN hrgn = CreateRectRgn(280,60,350,140);
HRGN hret = CreateRectRgn(0,0,0,0);
CombineRgn(hret,hRect,hrgn,RGN_AND);
brush.CreateSolidBrush(RGB(255,0,0));
CRgn rgn;
rgn.Attach(hret);
pDC->FillRgn(&rgn,&brush);
brush.DeleteObject();
rgn.Detach();
DeleteObject(hRect);
DeleteObject(hrc);
DeleteObject(hret);
}
/////////////////////////////////////////////////////////////////////////////
// CFillRCView printing
BOOL CFillRCView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CFillRCView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CFillRCView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CFillRCView diagnostics
#ifdef _DEBUG
void CFillRCView::AssertValid() const
{
CView::AssertValid();
}
void CFillRCView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CFillRCDoc* CFillRCView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFillRCDoc)));
return (CFillRCDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFillRCView message handlers