麻烦高手看看 我在mfc中的view类中用了几个消息响应OnRotaryvane() ,OnWaterring()等,使用了 m_nIDType变量来接受BitMap的ID号 ,调试都没什么问题,但是怎么运行不出来呢??
#include "stdafx.h"
#include "初步设计.h"
#include "初步设计Doc.h"
#include "初步设计View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyView
IMPLEMENT_DYNCREATE(CMyView, CView)
BEGIN_MESSAGE_MAP(CMyView, CView)
//{{AFX_MSG_MAP(CMyView)
ON_COMMAND(IDM_WATERRING, OnWaterring)
ON_COMMAND(IDM_ROTATINGPISTON, OnRotatingpiston)
ON_COMMAND(IDM_ROOTS, OnRoots)
ON_COMMAND(IDM_ROTARYVANE, OnRotaryvane)
ON_COMMAND(IDM_IONSPUTTERING, OnIonsputtering)
ON_COMMAND(IDM_DIFFUSION, OnDiffusion)
ON_COMMAND(IDM_CRYO, OnCryo)
ON_COMMAND(IDM_TURBOMOLECULAR, OnTurbomolecular)
ON_WM_ERASEBKGND()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CMyView construction/destruction
CMyView::CMyView()
{
// TODO: add construction code here
m_nPumpType=0;
m_nDrawType=0;
m_nIDType=0;
}
CMyView::~CMyView()
{
}
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMyView drawing
void CMyView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
// return CView::OnEraseBkgnd(pDC);
}
/////////////////////////////////////////////////////////////////////////////
// CMyView printing
BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics
#ifdef _DEBUG
void CMyView::AssertValid() const
{
CView::AssertValid();
}
void CMyView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers
void CMyView::OnRotaryvane()
{
// TODO: Add your command handler code here
m_nIDType=IDB_BITMAP1;
}
void CMyView::OnWaterring()
{
// TODO: Add your command handler code here
m_nIDType=IDB_BITMAP2;
}
void CMyView::OnRotatingpiston()
{
// TODO: Add your command handler code here
m_nIDType=IDB_BITMAP3;
}
void CMyView::OnRoots()
{
// TODO: Add your command handler code here
m_nIDType=IDB_BITMAP4;
}
void CMyView::OnTurbomolecular()
{
// TODO: Add your command handler code here
m_nIDType=IDB_BITMAP5;
}
void CMyView::OnDiffusion()
{
// TODO: Add your command handler code here
m_nIDType=IDB_BITMAP6;
}
void CMyView::OnIonsputtering()
{
// TODO: Add your command handler code here
m_nIDType=IDB_BITMAP7;
}
void CMyView::OnCryo()
{
// TODO: Add your command handler code here
m_nIDType=IDB_BITMAP8;
}
BOOL CMyView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBitmap bitmap;
if(bitmap.m_hObject!=NULL)
bitmap.DeleteObject();
bitmap.LoadBitmap(m_nIDType);
BITMAP bmp;
bitmap.GetBitmap(&bmp);
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDC);
dcCompatible.SelectObject(&bitmap);
CRect rect;
GetClientRect(&rect);
// pDC->BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);
pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,
0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
return TRUE;
// return CView::OnEraseBkgnd(pDC);
}
[此贴子已经被作者于2006-10-30 12:17:19编辑过]