求助!!!网上找的方法,封到一个函数中后,就出了问题,高手来看看吧!!! - C++ Builder / Windows SDK/API
void SHOWGIF(HWND Mwnd,int TIME){ int Frame=0; int WIDE,HIGH; HDC hdc; RECT rt; hdc=GetDC(Mwnd); Graphics gh(hdc);// GetWindowRect(Mwnd,&rt);// WIDE=rt.right-rt.left;// HIGH=rt.bottom-rt.top; Image image(L".//PIC//2.gif");// gh.DrawImage(&image,0,0,image.GetWidth(),image.GetHeight()); //以下干什么,我也不知道。。。。。,不过每运行一次会导致内存增加,问题应该在这里 UINT count = 0; count = image.GetFrameDimensionsCount(); GUID *pDimensionIDs=(GUID*)new GUID[count]; image.GetFrameDimensionsList(pDimensionIDs, count); WCHAR strGuid[39]; StringFromGUID2(pDimensionIDs[0], strGuid, 39); UINT frameCount=image.GetFrameCount(&pDimensionIDs[0]); delete []pDimensionIDs; int size =image.GetPropertyItemSize(PropertyTagFrameDelay); PropertyItem* pItem = NULL; pItem = (PropertyItem*)malloc(size); image.GetPropertyItem(PropertyTagFrameDelay,size,pItem); UINT fcount=0; GUID Guid = FrameDimensionTime;//到此貌似干完了,那就show吧!//play: do { gh.DrawImage(&image,0,0,image.GetWidth(),image.GetHeight()); //重新设置当前的活动数据帧 image.SelectActiveFrame(&Guid,fcount++); // if(fcount == frameCount) //frameCount是上面GetFrameCount返回值 // fcount= 0; //如果到了最后一帧数据又重新开始 //计算此帧要延迟的时间 long lPause = ((long*)pItem->value)[fcount]*10; Sleep(lPause);//这里简单使用了sleep }while(fcount!=frameCount);// delete image;// delete gh; DeleteObject(&image); DeleteObject(pItem); DeleteObject(&Guid);//删除对象 ReleaseDC(Mwnd,hdc);}