void CShowBitmapView::OnDraw(CDC* pDC)
{
CShowBitmapDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//在视图中显示一副图像
HBITMAP hBitmap = (HBITMAP) LoadImage(NULL, "d://test.bmp",IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE);
//定义一个位图对象
CBitmap m_bitmap;
//将位图句柄与位图对象相连接
m_bitmap.Attach(hBitmap);
//位图信息结构
BITMAP bm;
//将位图数据存入位图结构
m_bitmap.GetBitmap(&bm);
//源
CDC dcImage;
dcImage.CreateCompatibleDC(pDC);
dcImage.SelectObject(&m_bitmap);
//画图
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&dcImage,0,0,SRCCOPY);
}
{
CShowBitmapDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//在视图中显示一副图像
HBITMAP hBitmap = (HBITMAP) LoadImage(NULL, "d://test.bmp",IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE);
//定义一个位图对象
CBitmap m_bitmap;
//将位图句柄与位图对象相连接
m_bitmap.Attach(hBitmap);
//位图信息结构
BITMAP bm;
//将位图数据存入位图结构
m_bitmap.GetBitmap(&bm);
//源
CDC dcImage;
dcImage.CreateCompatibleDC(pDC);
dcImage.SelectObject(&m_bitmap);
//画图
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&dcImage,0,0,SRCCOPY);
}