VC++定时器
voidCDfView::OnInitialUpdate(){CView::OnInitialUpdate();SetTimer(1,2000,NULL);}voidCD...
void CDfView::OnInitialUpdate()
{
CView::OnInitialUpdate();
SetTimer(1,2000,NULL);
}
void CDfView::OnTimer(UINT nIDEvent)
{
CDC MemDC;
CDC *pDC;
HBITMAP hBmp;
BITMAP bm;
CBitmap Bitmap;
CPoint point( 10, 10);
CString cStr;
hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),"c:\wy.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
Bitmap.DeleteObject();
Bitmap.Attach( hBmp );
Bitmap.GetObject(sizeof(BITMAP),&bm);
MemDC.CreateCompatibleDC(pDC);
MemDC.SelectObject(&Bitmap);
pDC->BitBlt(point.x, point.y, bm.bmWidth, bm.bmHeight, &MemDC, 0, 0, SRCCOPY);
MemDC.DeleteDC();
KillTimer(1);
CView::OnTimer(nIDEvent);
}
这个程序 我想实现的功能是隔两秒钟再显示那个位图,编译都没错
怎么会老是出现内存不能读的情况 展开
{
CView::OnInitialUpdate();
SetTimer(1,2000,NULL);
}
void CDfView::OnTimer(UINT nIDEvent)
{
CDC MemDC;
CDC *pDC;
HBITMAP hBmp;
BITMAP bm;
CBitmap Bitmap;
CPoint point( 10, 10);
CString cStr;
hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),"c:\wy.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
Bitmap.DeleteObject();
Bitmap.Attach( hBmp );
Bitmap.GetObject(sizeof(BITMAP),&bm);
MemDC.CreateCompatibleDC(pDC);
MemDC.SelectObject(&Bitmap);
pDC->BitBlt(point.x, point.y, bm.bmWidth, bm.bmHeight, &MemDC, 0, 0, SRCCOPY);
MemDC.DeleteDC();
KillTimer(1);
CView::OnTimer(nIDEvent);
}
这个程序 我想实现的功能是隔两秒钟再显示那个位图,编译都没错
怎么会老是出现内存不能读的情况 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询