资源描述:
《vc动态加载位图.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、动态加载位图就是在运行中随意显示某图片吧原型:intWINAPIicePub_dispImg(HWNDhWnd,char*strImgFilename,intx,inty)输入:hWnd窗体或控件句柄strImgFilename待显示的图片文件名xx坐标yy坐标输出:{typedefint(WINAPIICEPUB_DISPIMG)(HWNDhWnd,char*strImgFilename,intx,inty);ICEPUB_DISPIMG*icePub_dispImg=0;HINSTANCEhDLLDrv=LoadLibra
2、ry("icePubDll.dll");if(hDLLDrv){icePub_dispImg=(ICEPUB_DISPIMG*)GetProcAddress(hDLLDrv,"icePub_dispImg");}if(icePub_dispImg!=NULL)icePub_dispImg(m_hWnd,"b.png",10,10);//icePub_dispImg(m_ctrlText.m_hWnd,"b.jpg",0,0);if(hDLLDrv)FreeLibrary(hDLLDrv);}追问谢谢!我是刚学不久,我要在按钮上
3、贴图片,用程序的参数而改变按钮图片,也就是显示不同的图片,我要怎么做,谢谢!回答冒汗,那用按钮直接装载图片资源比较方便,但能不能装载图片文件就不知了...追问谢谢!回答不用客气VC动态加载位图第一步://位图加载if(m_BitMap.m_hObject!=NULL)m_BitMap.DeleteObject();HBITMAPhbmp=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),"位图文件的绝对路径",IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION
4、LR_
5、LOADFROMFILE);if(hbmp==NULL){AfxMessageBox("加载位图失败!!!");returnFALSE;}m_BitMap.Attach(hbmp);BITMAPINFOHEADERbminfo;m_BitMap.GetObject(sizeof(bminfo),&bminfo);m_nBmpWidth=bminfo.biWidth;//获取图像宽度m_nBmpHeight=bminfo.biHeight;//获取图像高度第二步:把图片画出来,在OnPaint()函数中添加:CPaintDCdc
6、(this);//devicecontextforpaintingCDCDcPicture;DcPicture.CreateCompatibleDC(&dc);//创建兼容DCCBitmap*pOldBitMap=DcPicture.SelectObject(&m_BitMap);CRectrectPicture;GetDlgItem(IDC_PICTUREWND)->GetWindowRect(&rectPicture);//ScreenToClient(&rectPicture);dc.StretchBlt(rectPic
7、ture.left,rectPicture.top,rectPicture.Width(),rectPicture.Height(),&DcPicture,0,0,m_nBmpWidth,m_nBmpHeight,SRCCOPY);DcPicture.SelectObject(pOldBitMap);经过这两步,就可以实现位图的动态加载了。稍微扩展就成图片浏览功能模块了呵呵