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