Click here to Skip to main content
16,008,010 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can I convert my simple dll to a COM module ? Pin
David Salter3-Oct-01 10:51
David Salter3-Oct-01 10:51 
GeneralTemplates Pin
vijayaramaraju2-Oct-01 20:45
vijayaramaraju2-Oct-01 20:45 
GeneralRe: Templates Pin
Christian Graus2-Oct-01 21:02
protectorChristian Graus2-Oct-01 21:02 
QuestionSimple question : What is COM dll ? And what is its different ? Pin
2-Oct-01 20:40
suss2-Oct-01 20:40 
AnswerRe: Simple question : What is COM dll ? And what is its different ? Pin
Michael Dunn2-Oct-01 21:56
sitebuilderMichael Dunn2-Oct-01 21:56 
GeneralTHANK YOU ! Pin
2-Oct-01 22:36
suss2-Oct-01 22:36 
GeneralSerialize Pin
2-Oct-01 20:34
suss2-Oct-01 20:34 
GeneralRe: Serialize Pin
Joel Holdsworth3-Oct-01 9:19
Joel Holdsworth3-Oct-01 9:19 
Hi Fred,
If the type of class you are going to load is fixed, then the solution is simple, add a Serialize(CArchive &ar) method to the class. You create a blank object, a call this function, passing the CArchive reference to it, and hey-presto, you have a loaded class. If you have a class whose type is not fixed, your job is a little harder .. you will still need a 'Serialize' function though. The only reason you need a CObject derivation is because with it, MFC is able to dynamically reproduce the class from file data. But, as you don't have a CObject derivation, you will need to do this manually. In saving you must do three steps,

1. Store an identifyer that defines the name of your class, a string, or a just a token.
2. Get the class to serialize all it's member variables using the Serialize function.

To load you must

1. Read the identifyer that defines the class type.
2. Now you know what type of class to create, create it - like this
3. Ask the class to load it's member variables from the the archive, also using the Serialize function.

The code for loading might look a little like this...

ar >> iClassType;
switch(iClassType)
{
case FISH: object = new CFish(); break;
case DUCK: object = new CDuck(); break;
default: ASSERT(NULL); break;
}
object->Serialize(ar);

You could even define a constructor for the object that took a reference to the CArchive as it's only parameter, so as you construct the object, it deserializes itself!

I hope this all helps

With time we live, with money we spend!
Joel Holdsworth
GeneralGeneral ATL/COM question Pin
Christian Graus2-Oct-01 19:26
protectorChristian Graus2-Oct-01 19:26 
GeneralRe: General ATL/COM question Pin
Michael Dunn2-Oct-01 19:51
sitebuilderMichael Dunn2-Oct-01 19:51 
Generalchanging screen resolution dynamically Pin
erhemas2-Oct-01 18:51
erhemas2-Oct-01 18:51 
GeneralRe: changing screen resolution dynamically Pin
Christian Graus2-Oct-01 19:11
protectorChristian Graus2-Oct-01 19:11 
GeneralRe: changing screen resolution dynamically Pin
4-Oct-01 7:27
suss4-Oct-01 7:27 
Questionhow to replicate a window? Pin
erhemas2-Oct-01 18:49
erhemas2-Oct-01 18:49 
AnswerRe: how to replicate a window? Pin
Tomasz Sowinski3-Oct-01 1:11
Tomasz Sowinski3-Oct-01 1:11 
GeneralMSComm Help Pin
2-Oct-01 17:09
suss2-Oct-01 17:09 
GeneralRe: MSComm Help Pin
| mProject |2-Oct-01 20:14
| mProject |2-Oct-01 20:14 
GeneralTab key not working to jump to next control Pin
Mr.Freeze2-Oct-01 15:48
Mr.Freeze2-Oct-01 15:48 
GeneralRe: Tab key not working to jump to next control Pin
Chaos Lawful2-Oct-01 18:32
Chaos Lawful2-Oct-01 18:32 
GeneralRe: Tab key not working to jump to next control Pin
Mr.Freeze2-Oct-01 18:57
Mr.Freeze2-Oct-01 18:57 
GeneralRe: Tab key not working to jump to next control Pin
Chaos Lawful2-Oct-01 19:19
Chaos Lawful2-Oct-01 19:19 
GeneralRe: Tab key not working to jump to next control Pin
Mr.Freeze2-Oct-01 19:39
Mr.Freeze2-Oct-01 19:39 
GeneralRe: Tab key not working to jump to next control Pin
Chaos Lawful2-Oct-01 20:24
Chaos Lawful2-Oct-01 20:24 
GeneralRe: Tab key not working to jump to next control Pin
Mr.Freeze2-Oct-01 20:31
Mr.Freeze2-Oct-01 20:31 
GeneralKeyboard events Pin
Ever12342-Oct-01 14:52
Ever12342-Oct-01 14:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.