vc 应用picture控件显示图片的问题?
在win32application编程中,想在一个图片控件上显示图片,属性选择的是框架,编译通过,运行时,提示错误BOOLCALLBACKdlgProc(HWNDhdlg...
在win32 application编程中,想在一个图片控件上显示图片,属性选择的是框架,编译通过,运行时,提示错误
BOOL CALLBACK dlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam)
{
CBitmap hbmp;
HBITMAP hbitmap;
BITMAP bm;
//将pStatic指向要显示的地方
CStatic *pStaic=0;
pStaic=(CStatic*)GetDlgItem(hdlg,IDC_PIC1);
hbitmap=(HBITMAP)::LoadImage (::AfxGetInstanceHandle(),"2.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
hbmp.Attach(hbitmap);
//获取图片格式
hbmp.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(pStaic->GetDC());
CBitmap *poldBitmap=(CBitmap*)dcMem.SelectObject(hbmp);
CRect lRect;
pStaic->GetClientRect(&lRect);
lRect.NormalizeRect();
//显示位图
pStaic->GetDC()->StretchBlt(lRect.left ,lRect.top ,lRect.Width(),lRect.Height(),
&dcMem,0 ,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
dcMem.SelectObject(&poldBitmap); 展开
BOOL CALLBACK dlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam)
{
CBitmap hbmp;
HBITMAP hbitmap;
BITMAP bm;
//将pStatic指向要显示的地方
CStatic *pStaic=0;
pStaic=(CStatic*)GetDlgItem(hdlg,IDC_PIC1);
hbitmap=(HBITMAP)::LoadImage (::AfxGetInstanceHandle(),"2.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
hbmp.Attach(hbitmap);
//获取图片格式
hbmp.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(pStaic->GetDC());
CBitmap *poldBitmap=(CBitmap*)dcMem.SelectObject(hbmp);
CRect lRect;
pStaic->GetClientRect(&lRect);
lRect.NormalizeRect();
//显示位图
pStaic->GetDC()->StretchBlt(lRect.left ,lRect.top ,lRect.Width(),lRect.Height(),
&dcMem,0 ,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
dcMem.SelectObject(&poldBitmap); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询