mfc贴图有关问题~
mfc贴图问题~~~
图片导入了,可是运行时贴不出来,不知道为什么,新手求教
代码如下:
// 贴图View.cpp : implementation of the CMyView class
//
#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)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}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
}
CMyView::~CMyView()
{
}
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
int cardNo;
int i;
cardNo=IDB_BITMAP1; //获取第一幅图片的ID号
for (i=0; i<6; i++){
m_card[i].LoadBitmap(cardNo); //加载图片
cardNo++; //指向下一幅图片
}
//创建内存设备环境
CDC pDC;
for (i=0; i<6; i++) //循环创建13张图片的内存设备环境
card[i].CreateCompatibleDC (&pDC);
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
int i=0,j=0,k=0;//随机化数组
for(i=0;i<6;i++)
{
j=rand()%(6-i)+i;
k=sort[i];
sort[i]=sort[j];
sort[j]=k;
}
//粘贴图片s
for (i=0; i<6; i++){
card[sort[i]].SelectObject(m_card[sort[i]]);
if(i<=2){
pDC->BitBlt (20+i*160, 60, 300, 300, &card[sort[i]], 0, 0, SRCCOPY);
图片导入了,可是运行时贴不出来,不知道为什么,新手求教
代码如下:
// 贴图View.cpp : implementation of the CMyView class
//
#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)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}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
}
CMyView::~CMyView()
{
}
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
int cardNo;
int i;
cardNo=IDB_BITMAP1; //获取第一幅图片的ID号
for (i=0; i<6; i++){
m_card[i].LoadBitmap(cardNo); //加载图片
cardNo++; //指向下一幅图片
}
//创建内存设备环境
CDC pDC;
for (i=0; i<6; i++) //循环创建13张图片的内存设备环境
card[i].CreateCompatibleDC (&pDC);
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
int i=0,j=0,k=0;//随机化数组
for(i=0;i<6;i++)
{
j=rand()%(6-i)+i;
k=sort[i];
sort[i]=sort[j];
sort[j]=k;
}
//粘贴图片s
for (i=0; i<6; i++){
card[sort[i]].SelectObject(m_card[sort[i]]);
if(i<=2){
pDC->BitBlt (20+i*160, 60, 300, 300, &card[sort[i]], 0, 0, SRCCOPY);