Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. memory problem

memory problem

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vasu_sri
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • V vasu_sri

      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

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups