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. MFC Exntension-DLL Resource-Access question

MFC Exntension-DLL Resource-Access question

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelpc++learning
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.
  • O Offline
    O Offline
    ohadp
    wrote on last edited by
    #1

    Hi, I'll try to make this as straight forwards as possible :-) I'll describe the situation I want to create and the problem I'm facing as a consequence. I have a simple MFC-App (MfcApp.exe). It has a resource-DLL (MfcApp-Res.dll) which it maps using AfxSetResourceHandle. I want to build an MFC-Extension-DLL (MfcExt.dll) with new controls in it. I want this Extension-DLL to use resources from an additional Dll (MfcExt-Res.dll). What I would like to have: * MfcExt.dll loads resources from MfcExt-Res.dll * MfcApp.exe loads resources from MfcApp-Res.dll and from MfcExt-Res.dll (without explicitly stating MfcExt-Res.dll anywhere, just by linking to MfcExt.dll) But, Once the MFC-App will use the MFC-Extension-DLL, I expect a mess, why ? MSDN docs state that the MFC-App and Extension-DLL will use the same resource-dll handle. How can this be handled cleanly ? What is the percise function of CDynLinkLibrary in this case ? Thanks for the help,

    B 1 Reply Last reply
    0
    • O ohadp

      Hi, I'll try to make this as straight forwards as possible :-) I'll describe the situation I want to create and the problem I'm facing as a consequence. I have a simple MFC-App (MfcApp.exe). It has a resource-DLL (MfcApp-Res.dll) which it maps using AfxSetResourceHandle. I want to build an MFC-Extension-DLL (MfcExt.dll) with new controls in it. I want this Extension-DLL to use resources from an additional Dll (MfcExt-Res.dll). What I would like to have: * MfcExt.dll loads resources from MfcExt-Res.dll * MfcApp.exe loads resources from MfcApp-Res.dll and from MfcExt-Res.dll (without explicitly stating MfcExt-Res.dll anywhere, just by linking to MfcExt.dll) But, Once the MFC-App will use the MFC-Extension-DLL, I expect a mess, why ? MSDN docs state that the MFC-App and Extension-DLL will use the same resource-dll handle. How can this be handled cleanly ? What is the percise function of CDynLinkLibrary in this case ? Thanks for the help,

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      The CDynLinkLibrary is a list of libraries loaded dynamically during the run of the MFC program. When the MFC program requires a resource, it will traverse the chain of the dll in the list and stop once it finds the resource that matches. If you want the MfcExt.dll to only use resources from the MfcExt-Res.dll, you have two easy choices as I see it: 1. Always adjust the AfxSetResourceHandle() prior to any calls within MfcExt.dll that might load resources to the MfcExt-Res.dll and then set it BACK once you are done loading resources, which will cause it to load resources from the desired resource dll 2. Only use resouce identifiers in the MfcExt-Res.dll that do not overlap any within the MfcApp-Res.dll module. When the MfcApp.exe tries to load a resource, it will check MfcApp-Res.dll and then search in MfcExt-Res.dll. The MfcExt.dll will do the same search, but it will only find the resources in the MfcApp-Res.dll. I prefer to PLAN my resource utilitization, assign numerical identifier ranges, and go with option 2 myself. It saves tracking down resource loading and a lot of busy work associaed with option 1.

      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