📄 noflashview.cpp
字号:
// NoFlashView.cpp : implementation of the CNoFlashView class
//
#include "stdafx.h"
#include "NoFlash.h"
#include "NoFlashDoc.h"
#include "NoFlashView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNoFlashView
IMPLEMENT_DYNCREATE(CNoFlashView, CView)
BEGIN_MESSAGE_MAP(CNoFlashView, CView)
//{{AFX_MSG_MAP(CNoFlashView)
ON_WM_ERASEBKGND()
ON_WM_TIMER()
ON_COMMAND(ID_FLASH, OnFlash)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CNoFlashView construction/destruction
CNoFlashView::CNoFlashView()
{
// TODO: add construction code here
left1=100;
left2=100;
}
CNoFlashView::~CNoFlashView()
{
}
BOOL CNoFlashView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CNoFlashView drawing
void CNoFlashView::OnDraw(CDC* pDC)
{
CNoFlashDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect rect;
GetWindowRect(&rect);
nWidth=rect.Width();
nHeight=rect.Height();
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC (NULL);
MemBitmap.CreateCompatibleBitmap(pDC,nWidth,nHeight);
CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
MemDC.FillSolidRect(0,0,nWidth,nHeight,RGB(255,255,255));
rect1.SetRect (100,left1,150,400);
MemDC.FillSolidRect(&rect1,RGB(255,0,0));
MemDC.MoveTo(50,420);
MemDC.LineTo(500,420);
for(int i=0;i<25;i++)
{
rect1.SetRect(125+i,left1,125+i+1,400);
MemDC.FillSolidRect(&rect1,RGB(240-i*9,240-i*9,0));
}
for ( i=25;i>0;i--)
{
rect1.SetRect(125-i,left1,125-i+1,400);
MemDC.FillSolidRect(&rect1,RGB(240-i*9,240-i*9,0));
}
for( i=0;i<25;i++)
{
rect1.SetRect(200+i,left2,200+i+1,400);
MemDC.FillSolidRect(&rect1,RGB(240-i*9,0,0));
}
for ( i=25;i>0;i--)
{
rect1.SetRect(200-i,left2,200-i+1,400);
MemDC.FillSolidRect(&rect1,RGB(240-i*9,0,0));
}
pDC->BitBlt(0,0,nWidth,nHeight,&MemDC,0,0,SRCCOPY);
MemBitmap.DeleteObject();
MemDC.DeleteDC();
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CNoFlashView printing
BOOL CNoFlashView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CNoFlashView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CNoFlashView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CNoFlashView diagnostics
#ifdef _DEBUG
void CNoFlashView::AssertValid() const
{
CView::AssertValid();
}
void CNoFlashView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CNoFlashDoc* CNoFlashView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNoFlashDoc)));
return (CNoFlashDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CNoFlashView message handlers
BOOL CNoFlashView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return true;
// return CView::OnEraseBkgnd(pDC);
}
void CNoFlashView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
Invalidate();
//InvalidateRect(&rect1);
//InvalidateRect(&rect2);
left1=rand()%100;
left2=rand()%100;
CView::OnTimer(nIDEvent);
}
void CNoFlashView::OnInitialUpdate()
{
CView::OnInitialUpdate();
SetTimer(1,1000,NULL);
// TODO: Add your specialized code here and/or call the base class
}
void CNoFlashView::OnFlash()
{
// TODO: Add your command handler code here
CClientDC dc(this);
dc.SetBkColor(RGB(255,255,255));
//Invalidate();
}
void CNoFlashView::OnPaint()
{
CPaintDC dc(this); // device context for painting
}
BOOL CNoFlashView::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
return CView::DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -