memory problem
-
i have 5 icons .. iam loading these icons into one static control... then what the problem is after loading 4000 times into static control it exit automatically... what the problem i dont know sir....
CString strFilename,strPercent,strFileExt; strFileExt=(LPSTR)wparam; if(strFile=="BMP0") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP))); } else if(strFile=="BMP1") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP1))); } else if(strFile=="BMP2") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP2))); } else if(strFile=="BMP3") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP3))); // DestroyIcon(hIcon); } else if(strFile=="BMP4") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP4))); } hIcon=m_stIcons1[icons].GetIcon(); DestroyIcon(hIcon); m_stIcons1[icons].DestroyWindow(); m_stFileName1[icons].DestroyWindow(); m_stPercent1[icons].DestroyWindow(); icons++; IconRes++;
Regards, Srinivas
-
i have 5 icons .. iam loading these icons into one static control... then what the problem is after loading 4000 times into static control it exit automatically... what the problem i dont know sir....
CString strFilename,strPercent,strFileExt; strFileExt=(LPSTR)wparam; if(strFile=="BMP0") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP))); } else if(strFile=="BMP1") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP1))); } else if(strFile=="BMP2") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP2))); } else if(strFile=="BMP3") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP3))); // DestroyIcon(hIcon); } else if(strFile=="BMP4") { m_stIcons1[icons].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP4))); } hIcon=m_stIcons1[icons].GetIcon(); DestroyIcon(hIcon); m_stIcons1[icons].DestroyWindow(); m_stFileName1[icons].DestroyWindow(); m_stPercent1[icons].DestroyWindow(); icons++; IconRes++;
Regards, Srinivas
Maybe the following excerpt from MSDN will be helpful:
Remarks
It is only necessary to call DestroyIcon for icons and cursors created
with the CreateIconIndirect function.
Do not use this function to destroy a shared icon.
A shared icon is valid as long as the module from which it was loaded remains in memory.
The following functions obtain a shared icon:LoadIcon
LoadImage (if you use the LR_SHARED flag)
CopyImage (if you use the LR_COPYRETURNORG flag and the hImage parameter is a shared icon):)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.