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. Resource problem in an MFC extention DLL

Resource problem in an MFC extention DLL

Scheduled Pinned Locked Moved C / C++ / MFC
learningc++databasevisual-studiocom
3 Posts 3 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.
  • D Offline
    D Offline
    D D de Kerf
    wrote on last edited by
    #1

    Hi, I'm having a rather weird problem here and I thought that maybe, if I described it, it would ring some bells with the experts. I haven't a clue! Anyway, here's the situation: We have an in-house developed database-access layer with all kinds of specific goodies in it and for reasons of deployment and ease of upgrade, we isolated it in an MFC extention DLL. This all worked fine for a couple of months. I can integrate it easily in existing programs and everything works fine... that is, as long as I integrate it in an exe! The database-access layer in the DLL has a feature which displays a tray-icon. You can see what the layer is doing by looking at the tray-icon's color or by calling a dialog, hidden in the tray-icon's context menu. Of course the dialog and tray-icons are all located in the resource of the extention dll... As long as I integrate the extention dll in a stand-alone application (.exe), everything works fine, tray-icon included. But when I integrate the dll in an activeX-component (complete with clsid and interface) the tray-icon's icon cannot be loaded from the resource! In release build this results in a tray-icon without an icon (just an empty space) which isn't THAT bad, but when I try to bring up the dialog it fails completely (which you might expect). In debug build I get all sorts of assert-failures saying that the icon HANDLE is invalid... So how come everything works fine in a stand-alone application and it fails in an ActiveX component? :confused: Structured programming vs. chaotic mind boggling

    L T 2 Replies Last reply
    0
    • D D D de Kerf

      Hi, I'm having a rather weird problem here and I thought that maybe, if I described it, it would ring some bells with the experts. I haven't a clue! Anyway, here's the situation: We have an in-house developed database-access layer with all kinds of specific goodies in it and for reasons of deployment and ease of upgrade, we isolated it in an MFC extention DLL. This all worked fine for a couple of months. I can integrate it easily in existing programs and everything works fine... that is, as long as I integrate it in an exe! The database-access layer in the DLL has a feature which displays a tray-icon. You can see what the layer is doing by looking at the tray-icon's color or by calling a dialog, hidden in the tray-icon's context menu. Of course the dialog and tray-icons are all located in the resource of the extention dll... As long as I integrate the extention dll in a stand-alone application (.exe), everything works fine, tray-icon included. But when I integrate the dll in an activeX-component (complete with clsid and interface) the tray-icon's icon cannot be loaded from the resource! In release build this results in a tray-icon without an icon (just an empty space) which isn't THAT bad, but when I try to bring up the dialog it fails completely (which you might expect). In debug build I get all sorts of assert-failures saying that the icon HANDLE is invalid... So how come everything works fine in a stand-alone application and it fails in an ActiveX component? :confused: Structured programming vs. chaotic mind boggling

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      use AFX_MANAGE_STATE(AfxGetStaticModuleState()) in your DLL. see MFC technical note 058 for more info if it doesn't help, you can set the resource handle manually in the DLL

      HINSTANCE hResPrev=AfxGetResourceHandle ();
      AfxSetResourceHandle (GetModuleHandle (_T("CT.DLL"))); // MFC ext. DLL

      ...

      AfxSetResourceHandle (hResPrev);

      1 Reply Last reply
      0
      • D D D de Kerf

        Hi, I'm having a rather weird problem here and I thought that maybe, if I described it, it would ring some bells with the experts. I haven't a clue! Anyway, here's the situation: We have an in-house developed database-access layer with all kinds of specific goodies in it and for reasons of deployment and ease of upgrade, we isolated it in an MFC extention DLL. This all worked fine for a couple of months. I can integrate it easily in existing programs and everything works fine... that is, as long as I integrate it in an exe! The database-access layer in the DLL has a feature which displays a tray-icon. You can see what the layer is doing by looking at the tray-icon's color or by calling a dialog, hidden in the tray-icon's context menu. Of course the dialog and tray-icons are all located in the resource of the extention dll... As long as I integrate the extention dll in a stand-alone application (.exe), everything works fine, tray-icon included. But when I integrate the dll in an activeX-component (complete with clsid and interface) the tray-icon's icon cannot be loaded from the resource! In release build this results in a tray-icon without an icon (just an empty space) which isn't THAT bad, but when I try to bring up the dialog it fails completely (which you might expect). In debug build I get all sorts of assert-failures saying that the icon HANDLE is invalid... So how come everything works fine in a stand-alone application and it fails in an ActiveX component? :confused: Structured programming vs. chaotic mind boggling

        T Offline
        T Offline
        Tomasz Sowinski
        wrote on last edited by
        #3

        MFC Extension DLL will work correctly only if your exe is also MFC app linking dynamically to MFC. With ActiveX, your .exe is a container - you can't expect all apps hosting your ActiveX to be MFC apps. Tomasz Sowinski -- http://www.shooltz.com

        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