渐 变

private:
 int ColorR;
 int ColorG;

 

// vcB1View.cpp : implementation of the CVcB1View class
//

#include "stdafx.h"
#include "vcB1.h"

#include "vcB1Doc.h"
#include "vcB1View.h"

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

/
// CVcB1View

IMPLEMENT_DYNCREATE(CVcB1View, CView)

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

/
// CVcB1View construction/destruction

CVcB1View::CVcB1View()
{
 // TODO: add construction code here
 // TODO: add construction code here
 ColorR = 255;
 ColorG = 255;
 
}

CVcB1View::~CVcB1View()
{
}

BOOL CVcB1View::PreCreateWindow(CREATESTRUCT& cs)
{
 // TODO: Modify the Window class or styles here by modifying
 //  the CREATESTRUCT cs
 
 return CView::PreCreateWindow(cs);
}

/
// CVcB1View drawing

void CVcB1View::OnDraw(CDC* pDC)
{
 CVcB1Doc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);
 // TODO: add draw code for native data here
 
 
 // TODO: add draw code for native data here
 CRect m_rcClient;
 
 // file://得到客户区域的填充矩形
 GetClientRect(&m_rcClient);
 int nWidth = m_rcClient.Width();
 int nHeight = m_rcClient.Height();
 CRect rectangle;
 //file://分割客户区域成小矩形,逐个填充
 for(int i = 0;i < nWidth;i++ )
 {
  rectangle.SetRect(i, 0, i+1, nHeight);
  pDC->FillSolidRect(&rectangle, RGB(ColorR, ColorG, 255-MulDiv(i, 255, nWidth)));
 }
 
}

/
// CVcB1View printing

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

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

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

/
// CVcB1View diagnostics

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

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

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

/
// CVcB1View message handlers

void CVcB1View::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 //生成小于255的随机数,给ColorR和ColorG赋值
 int nRand = rand();

 float fMap = (float)255/RAND_MAX;
 ColorR = (UINT)(float)nRand*fMap + 0.5f;
 nRand = rand();

 fMap = (float)255/RAND_MAX;

 ColorG = (UINT)(float)nRand*fMap + 0.5f;
 //更新界面
 Invalidate();
 
 CView::OnLButtonDown(nFlags, point);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值