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. Load a resource script

Load a resource script

Scheduled Pinned Locked Moved C / C++ / MFC
c++toolstutorialquestionlearning
5 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.
  • D Offline
    D Offline
    Demian Panello
    wrote on last edited by
    #1

    Hi. I need to load a dialog from a resource script, (.rc file), at runtime. I mean, the resource file is not in the project, it was created outside the project and then, at runtime, I have to bind a CDialog class with some DIALOG template present in this .rc file. Is it possible? Thank you.

    Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

    M 1 Reply Last reply
    0
    • D Demian Panello

      Hi. I need to load a dialog from a resource script, (.rc file), at runtime. I mean, the resource file is not in the project, it was created outside the project and then, at runtime, I have to bind a CDialog class with some DIALOG template present in this .rc file. Is it possible? Thank you.

      Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

      M Offline
      M Offline
      Mattias G
      wrote on last edited by
      #2

      Well, anything is possible :-) To load a script (text file) you need a compiler, basically a C-compiler. This will be messy. If you need to do heavy modifications of the resources at runtime I would instead recommend 1) loading compiled resources in a DLL and 2) using UpdateResource.

      D 1 Reply Last reply
      0
      • M Mattias G

        Well, anything is possible :-) To load a script (text file) you need a compiler, basically a C-compiler. This will be messy. If you need to do heavy modifications of the resources at runtime I would instead recommend 1) loading compiled resources in a DLL and 2) using UpdateResource.

        D Offline
        D Offline
        Demian Panello
        wrote on last edited by
        #3

        Thank you for answer. Ok, I understand. But 2 more questions, please. 1) I have a resource file, and I have to compile it using, in example, VC compiler, ok?. What are the compiler options, (or where could I find it), to compile that script file into a dll. I mean without need to create a DLL project and so on. Because the guys that will create the resource script file, they don't know nothing about programming, they just put controls here and there using the VC 6.0 resource editor and nothing more. Then I will run, in example, a bat file to compile some given .rc files into a DLL. 2) Then that dll file will be load it at runtime by a VC program, (an OCX in particular), and it will use that dialog from dll and bind it to an existing CDialog derivated class. Confusing?, ;P I thought in all this because we need to display many kind of dialogs, (and everyday a new one), and we want them outside the main project. Maybe there's an easier way to handle this, but I can't figure out. Thank you very much.

        Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

        M 1 Reply Last reply
        0
        • D Demian Panello

          Thank you for answer. Ok, I understand. But 2 more questions, please. 1) I have a resource file, and I have to compile it using, in example, VC compiler, ok?. What are the compiler options, (or where could I find it), to compile that script file into a dll. I mean without need to create a DLL project and so on. Because the guys that will create the resource script file, they don't know nothing about programming, they just put controls here and there using the VC 6.0 resource editor and nothing more. Then I will run, in example, a bat file to compile some given .rc files into a DLL. 2) Then that dll file will be load it at runtime by a VC program, (an OCX in particular), and it will use that dialog from dll and bind it to an existing CDialog derivated class. Confusing?, ;P I thought in all this because we need to display many kind of dialogs, (and everyday a new one), and we want them outside the main project. Maybe there's an easier way to handle this, but I can't figure out. Thank you very much.

          Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

          M Offline
          M Offline
          Mattias G
          wrote on last edited by
          #4

          Ok, sounds reasonable. Compile the script.rc using rc (which is, I believe, in reality a preprocessor that converts stuff like BEGIN to { and END to }, DIALOG to a c struct and after that calling a C-compiler). The resource compiler produces a .res file, that you can link into a .dll with /DLL. Another option is to create a DLL project in MSVC and use the Project/Export makefile command in MSVC - you'll have a real fun experience trying to dechiper the output :-) But it works And then to load the dialog is a breeze; LoadLibrary and then LoadResource on the HMODULE returned, and then CreateDialog with the template loaded. Translate to the framework you're using.

          D 1 Reply Last reply
          0
          • M Mattias G

            Ok, sounds reasonable. Compile the script.rc using rc (which is, I believe, in reality a preprocessor that converts stuff like BEGIN to { and END to }, DIALOG to a c struct and after that calling a C-compiler). The resource compiler produces a .res file, that you can link into a .dll with /DLL. Another option is to create a DLL project in MSVC and use the Project/Export makefile command in MSVC - you'll have a real fun experience trying to dechiper the output :-) But it works And then to load the dialog is a breeze; LoadLibrary and then LoadResource on the HMODULE returned, and then CreateDialog with the template loaded. Translate to the framework you're using.

            D Offline
            D Offline
            Demian Panello
            wrote on last edited by
            #5

            Ok, I got it! Thank you very much!

            Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

            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