开发环境:vc2005 arm wince5.0
我用网上下的CCePngButtonST类做png按钮,想要实现同一个按钮上的png图片根据不同情况显示不同内容,比如播放器打开时显示一张图片,播放器关闭时显示另一张图片,结果点了n次后把内存都占光了,显然是加载另一张时前一张的内存没有释放完,请问
如何释放?
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
this->ShowWindow(SW_SHOWMAXIMIZED); //SW_MAXIMIZE是显示窗口为最大化
m_cbtntest.SetWindowPos(&wndTop,0,190,80,80,SWP_NOZORDER|SWP_SHOWWINDOW);
m_cbtntest.SetImage(IDB_MAINBKGND,IDB_04,CSize(70,70),IDR_MUSIC,CSize(80,80));
DWORD CCePngButtonST::SetImage(int nBkgndID, int nImageIn, CSize sizeIn, int nImageOut, CSize sizeOut, int nImageDis, CSize sizeDis)
{
IImage* pImageIn = NULL;
IImage* pImageOut = NULL;
IImage* pImageDis = NULL;
nBkgndImageID = nBkgndID;
CoInitializeEx(NULL,COINIT_MULTITHREADED);
//initialize com
if(!SUCCEEDED(CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,(void **)&pIImgFactory)))
{
return BTNST_FAILEDMASK;
}
// Set image when the mouse is IN the button
ImageFromIDResource(nImageIn, L"PNG", &pImageIn);
// Set image when the mouse is OUT the button
if (nImageOut)
ImageFromIDResource(nImageOut, L"PNG", &pImageOut);
// Set image when the mouse is DISABLED
if (nImageDis)
ImageFromIDResource(nImageDis, L"PNG", &pImageDis);
return SetImage(pImageIn, sizeIn, pImageOut, sizeOut, pImageDis, sizeDis);
} // End of SetImage
if (pIImageIn)
{
// Image when mouse over button?
m_csImages[0].pIImage = pIImageIn;
// Get image dimension
m_csImages[0].dwWidth = (DWORD)sizeIn.cx;
m_csImages[0].dwHeight = (DWORD)sizeIn.cy;
// Image when mouse outside button?
if (pIImageOut)
{
m_csImages[1].pIImage = pIImageOut;
// Get image dimension
m_csImages[1].dwWidth = (DWORD)sizeOut.cx;
m_csImages[1].dwHeight = (DWORD)sizeOut.cy;
} // if
// Image when button disabled?
if (pIImageDis)
{
m_csImages[2].pIImage = pIImageDis;
// Get icon dimension
m_csImages[2].dwWidth = (DWORD)sizeDis.cx;
m_csImages[2].dwHeight = (DWORD)sizeDis.cy;
} // if
} // if
Invalidate();
return BTNST_OK;
} // End of SetImage
void CCePngButtonST::FreeResources(BOOL bCheckForNULL)
{
if (bCheckForNULL)
{
// Destroy icons
// Note: the following lines MUST be here! even if
// BoundChecker says they are unnecessary!
if (m_csIcons[0].hIcon) ::DestroyIcon(m_csIcons[0].hIcon);
if (m_csIcons[1].hIcon) ::DestroyIcon(m_csIcons[1].hIcon);
if (m_csIcons[2].hIcon) ::DestroyIcon(m_csIcons[2].hIcon);
} // if
memset(&m_csIcons, 0, sizeof(m_csIcons));
memset(&m_csBitmaps, 0, sizeof(m_csBitmaps));
memset(&m_csImages, 0, sizeof(m_csImages));
} // End of FreeResources
我也顺便打个广告,本人也有支持ESRI ARCGIS的.shp文件的地图的Windows mobile 5.0/6.0手机GIS地图软件----GPS移动GIS(GPSMobileGIS),PC端的服务软件----移动GIS服务平台(GPSMobileGISServer),可成套出售,可以完成以下功能:
1,通过GPRS上网连接后台服务端程序来实时传输在户外工作采集的数据到后台数据库!
我也顺便打个广告,本人也有支持ESRI ARCGIS的.shp文件的地图的Windows mobile 5.0/6.0手机GIS地图软件----GPS移动GIS(GPSMobileGIS),PC端的服务软件----移动GIS服务平台(GPSMobileGISServer),可成套出售,可以完成以下功能:
1,通过GPRS上网连接后台服务端程序来实时传输在户外工作采集的数据到后台数据库!