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 Dialog in Static Library

MFC Dialog in Static Library

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionlearning
3 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.
  • C Offline
    C Offline
    clintsinger
    wrote on last edited by
    #1

    Hi, I have a MFC dialog that I want to be in a static library. When it is in the static library and I call DoModal on it, the FindResource comes back with 0. if (m_lpszTemplateName != NULL) { hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG); // Works HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG); // Fails hDialogTemplate = LoadResource(hInst, hResource); // Obviously fails... } Is it possible to have a dialog defined in static library with MFC support? I should point out that made sure that all the resource identifiers are out of the range of all other identifiers in the program (ie, 5000+) Sincerly, Clint Singer

    S 1 Reply Last reply
    0
    • C clintsinger

      Hi, I have a MFC dialog that I want to be in a static library. When it is in the static library and I call DoModal on it, the FindResource comes back with 0. if (m_lpszTemplateName != NULL) { hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG); // Works HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG); // Fails hDialogTemplate = LoadResource(hInst, hResource); // Obviously fails... } Is it possible to have a dialog defined in static library with MFC support? I should point out that made sure that all the resource identifiers are out of the range of all other identifiers in the program (ie, 5000+) Sincerly, Clint Singer

      S Offline
      S Offline
      Shog9 0
      wrote on last edited by
      #2

      clintsinger wrote:

      Is it possible to have a dialog defined in static library with MFC support?

      Yes. But since you can't link resource templates into static libraries, you'll need to remember to do so in the app that uses them. For instance:

      • Clint.exe links with ClintLib.lib, and has resources specified in Clint.rc
      • ClintLib.lib contains class for dialog, template for dialog is defined in ClintLib.rc
      • Clint.rc must #include ClintLib.rc in order for those resources to be available at runtime.

      Post faster, post more, post now

      C 1 Reply Last reply
      0
      • S Shog9 0

        clintsinger wrote:

        Is it possible to have a dialog defined in static library with MFC support?

        Yes. But since you can't link resource templates into static libraries, you'll need to remember to do so in the app that uses them. For instance:

        • Clint.exe links with ClintLib.lib, and has resources specified in Clint.rc
        • ClintLib.lib contains class for dialog, template for dialog is defined in ClintLib.rc
        • Clint.rc must #include ClintLib.rc in order for those resources to be available at runtime.

        Post faster, post more, post now

        C Offline
        C Offline
        clintsinger
        wrote on last edited by
        #3

        Thank you. It worked! Cheers, Clint

        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