先了解双缓冲理论防闪烁,可以参考此文:http://blog.youkuaiyun.com/skykingf/article/details/20632125
基于单文档的
修改CChildView.h和CChildView.cpp即可
CChildView.h
// ChildView.h : CChildView 类的接口
//
#pragma once
// CChildView 窗口
class CChildView : public CWnd
{
// 构造
public:
CChildView();
// 属性
public:
// 操作
public:
// 重写
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
// 实现
public:
virtual ~CChildView();
CDC m_memDC;
CBitmap m_memBmp;
CRect m_rtClient;
// 生成的消息映射函数
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};
CChildView.cpp
// ChildView.cpp : CChildView 类的实现
//
#include "stdafx.h"
#include "DoClock.h"
#include "ChildView.h"
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CChildView
CChildView::CChildView()
{
}
CChildView::~CChildView()
{
}
BEGIN_MESSAGE_MAP(CChildView, CWnd)
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_TIMER()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
END_MESSAGE