I find it stunning how often you declare something as "unusable" or "worthless" or "needlessly complex", when that very thing you
criticize is something I have been using successfully for years. I think you quite often judge quickly and give up too easily.
Joseph M. Newcomer wrote:
It wouldn't make sense to serialize a dialog. Nor does it make much sense to have a
dialog class created by a template. If you need some kind of templating, it most likely
applies to data *within* the dialog, and therefore you should create a templated class to
hold your data.
I do not believe you can derive a template class from CObject, because of how the macros
work. You did not say which version of VS you are using.
Generally, MFC serialization is among the worst possible ways to implement persistent
memory of information. It is needlessly complex (in spite of the claims otherwise)
because it is exceptionally fragile under what is known as "schema migration". Change
anything in the class, such as adding or deleting a member variable, or changing its type,
and all existing files are rendered unreadable. I would suggest avoiding it entirely. I
tend to use either simple text files or XML files if I have complex structured data. I
have studiously avoided using MFC serialization for 15 years (we had implemented the
equivalent of MFC serialization in 1977 and knew exactly what was wrong with it, and when
I saw MFC serialization, all I could do was shake my head and say "how could they DO
something this bad when we knew almost 20 years ago [I looked at this in 1996] that it
cannot work". Our sollution, by the way, was to have an XML file we wrote out, along with
the binary. If the binary file had a different version than the program could read, we
ignored the binary form of the file and read the XML form [yes, I helped invent XML in
1977; it looked much better than the current XML, was more powerful, and the second
generation, done ca. 1980, and known as IDL, was even better. But it was not yet time to
build steam engines, so our work was ignored and then badly reinvented by the XML
designers. We documented our work in a 1989 book].
joe
On Fri, 4 Sep 2009 02:06:01 -0700, Elizabeta <Elizabeta@discussions.microsoft.com> wrote:
Hello
How can I serialize Mfc template dialog class , I can't use DECLARE_SERIAL
and IMPLEMENT_SERIAL for this . I noticed that IMPLEMENT_SERIAL_T macro
exist, but it is not documented and there is no corresponding
DECLARE_SERAIL_T.
Thanks
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm