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 and Serialize... How do I attach an icon/schema?

MFC and Serialize... How do I attach an icon/schema?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++databasexml
5 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.
  • M Offline
    M Offline
    maxmaven
    wrote on last edited by
    #1

    Hello, I am using the MFC archive mechanism (serialize) to write out my document data. So I have something like:

    void MyDoc::Serialize(CArchive& ar)
    {
    if (ar.IsStoring())
    {
    // TODO: add storing code here
    ar << somedata;
    }
    else
    {
    // TODO: add loading code here
    ar >> somedata;
    }
    }

    How do I attach an icon to the file I have written out? Thank you! Max

    RaviBeeR 1 Reply Last reply
    0
    • M maxmaven

      Hello, I am using the MFC archive mechanism (serialize) to write out my document data. So I have something like:

      void MyDoc::Serialize(CArchive& ar)
      {
      if (ar.IsStoring())
      {
      // TODO: add storing code here
      ar << somedata;
      }
      else
      {
      // TODO: add loading code here
      ar >> somedata;
      }
      }

      How do I attach an icon to the file I have written out? Thank you! Max

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      maxmaven wrote:

      How do I attach an icon to the file I have written out?

      By "attach" do you mean (a) save an icon to the file, (b) associate an icon with the file or (c) something else? /ravi

      This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      M 1 Reply Last reply
      0
      • RaviBeeR RaviBee

        maxmaven wrote:

        How do I attach an icon to the file I have written out?

        By "attach" do you mean (a) save an icon to the file, (b) associate an icon with the file or (c) something else? /ravi

        This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        M Offline
        M Offline
        maxmaven
        wrote on last edited by
        #3

        I believe what I am wanting is (b) associate an icon with the file. So, the file is created by the serialize machinery in MFC, perhaps it is called "binky". But there will be a file extension, so it will actually be "binky.dzq" or some other file extension. And the file will have an icon, so that when you view the file in the regular explorer file view (not internet explorer), you will see the file binky.dzq has a nice icon picture so users will know this is a file created by/for my application. How would I get an icon to appear like this on my serialized file? Thank you! Max

        S 1 Reply Last reply
        0
        • M maxmaven

          I believe what I am wanting is (b) associate an icon with the file. So, the file is created by the serialize machinery in MFC, perhaps it is called "binky". But there will be a file extension, so it will actually be "binky.dzq" or some other file extension. And the file will have an icon, so that when you view the file in the regular explorer file view (not internet explorer), you will see the file binky.dzq has a nice icon picture so users will know this is a file created by/for my application. How would I get an icon to appear like this on my serialized file? Thank you! Max

          S Offline
          S Offline
          Steve S
          wrote on last edited by
          #4

          This is nothing to do with serialization, then. In the registry under HKEY_CLASSES_ROOT there are a number of keys corresponding to an extension, such as ".acl". This has an unnamed (default) value of "Agent.Character.2", for example. This relates to another key which again, has a default value. This is the description of the file as it would appear in explorer. Also under there is a key called "DefaultIcon" which contains a string describing where to get the icon for the file, normally the name of an exe or dll with an icon index. If you want the user to be able to double-click on the file and have explorer launch your app, you need to look at the shell and shellex keys. Have a browse for stuff like .xls etc if you have office installed, and you'll see what I mean. Normally, MFC apps take care of this by calling CWinApp::RegisterShellFileTypes(), but if you are a non-admin user, then you cannot write to the relevant bits of the registry, so this should really be done by an installer. BTW, are you a Terry Pratchett fan? :)

          Steve S Developer for hire

          M 1 Reply Last reply
          0
          • S Steve S

            This is nothing to do with serialization, then. In the registry under HKEY_CLASSES_ROOT there are a number of keys corresponding to an extension, such as ".acl". This has an unnamed (default) value of "Agent.Character.2", for example. This relates to another key which again, has a default value. This is the description of the file as it would appear in explorer. Also under there is a key called "DefaultIcon" which contains a string describing where to get the icon for the file, normally the name of an exe or dll with an icon index. If you want the user to be able to double-click on the file and have explorer launch your app, you need to look at the shell and shellex keys. Have a browse for stuff like .xls etc if you have office installed, and you'll see what I mean. Normally, MFC apps take care of this by calling CWinApp::RegisterShellFileTypes(), but if you are a non-admin user, then you cannot write to the relevant bits of the registry, so this should really be done by an installer. BTW, are you a Terry Pratchett fan? :)

            Steve S Developer for hire

            M Offline
            M Offline
            maxmaven
            wrote on last edited by
            #5

            Hello Steve, Well, you have introduced me to a whole new area of programming that I am not familiar with. :) Do you happen to know of a tutorial or discussion that I can look at to learn more? Thank you, Max

            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