【VC开源代码栏目提醒】:网学会员鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“CShow_2View.cpp”一文,供大家参考学习
// CShow_2View.cpp : implementation of the CCShow_2View class
//
#include "stdafx.h"
#include "CShow_2.h"
#include "CShow_2Doc.h"
#include "CShow_2View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCShow_2View
IMPLEMENT_DYNCREATE(CCShow_2View, CView)
BEGIN_MESSAGE_MAP(CCShow_2View, CView)
//{{AFX_MSG_MAP(CCShow_2View)
ON_COMMAND(IDB_FIFTY, OnFifty)
ON_COMMAND(TDM_SEVENTY, OnSeventy)
ON_COMMAND(IDB_HUNDRED, OnHundred)
ON_COMMAND(IDB_ADD_HUNDRED, OnAddHundred)
ON_WM_PAINT()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCShow_2View construction/destruction
CCShow_2View::CCShow_2View()
{
// TODO: add construction code here
canshu=1;
}
CCShow_2View::~CCShow_2View()
{
}
BOOL CCShow_2View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCShow_2View drawing
void CCShow_2View::OnDraw(CDC* pDC)
{
CCShow_2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCShow_2View printing
BOOL CCShow_2View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCShow_2View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCShow_2View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCShow_2View diagnostics
#ifdef _DEBUG
void CCShow_2View::AssertValid() const
{
CView::AssertValid();
}
void CCShow_2View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCShow_2Doc* CCShow_2View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCShow_2Doc)));
return (CCShow_2Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCShow_2View message handlers
void CCShow_2View::OnFifty()
{
// TODO: Add your command handler code here
canshu=0.5;
Invalidate();
}
void CCShow_2View::OnSeventy()
{
// TODO: Add your command handler code here
canshu=0.75;
Invalidate();
}
void CCShow_2View::OnHundred()
{
// TODO: Add your command handler code here
canshu=1;
Invalidate();
}
void CCShow_2View::OnAddHundred()
{
// TODO: Add your command handler code here
canshu=1.5;
Invalidate();
}
void CCShow_2View::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CBitmap bitmap; //创建位图
bitmap.LoadBitmap(IDB_BITMAP1);
BITMAP bm;
bitmap.GetBitmap(&bm);
CRect rect;
GetClientRect(&rect);
CDC ImageDc;
ImageDc.CreateCompatibleDC(&dc); //创建兼容DC
CBitmap *pOldImageDc=ImageDc.SelectObject(&bitmap); //将位图选进兼容DC
dc.StretchBlt(0,0,(int)(canshu*rect.Width()),(int)(canshu*rect.Height()),&ImageDc,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
// Do not call CView::OnPaint() for painting messages
}
上一篇:
B学生查询.frm
下一篇:
硕士毕业论文写作基本要求