Click here to Skip to main content
15,917,320 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to link the prolog to C++ Pin
ismail marmoush12-Apr-07 23:40
ismail marmoush12-Apr-07 23:40 
QuestionHow to import CIE and CLS files? Pin
Joan M12-Apr-07 23:33
professionalJoan M12-Apr-07 23:33 
QuestionHow to set document file extension? Pin
maxmaven12-Apr-07 23:03
maxmaven12-Apr-07 23:03 
AnswerRe: How to set document file extension? Pin
Paresh Chitte13-Apr-07 2:41
Paresh Chitte13-Apr-07 2:41 
QuestionMFC Serialization Pin
Keshav V. Kamat12-Apr-07 22:52
Keshav V. Kamat12-Apr-07 22:52 
AnswerRe: MFC Serialization Pin
Cedric Moonen12-Apr-07 23:12
Cedric Moonen12-Apr-07 23:12 
GeneralRe: MFC Serialization Pin
Keshav V. Kamat12-Apr-07 23:46
Keshav V. Kamat12-Apr-07 23:46 
AnswerRe: MFC Serialization Pin
maxmaven12-Apr-07 23:16
maxmaven12-Apr-07 23:16 
If you are using the Doc/View architecture, you can do some simple document writing:

void CYourDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring()) {
           // here we are writing
           ar << an_int
           << a_double
           << a_CString
           << a_short;
        } else {
           // here we are reading
           ar >> an_int
           >> a_double
           >> a_CString
           >> a_short;
}


Make sure the order and size of the data you write is identical to the order and size of the data you read, otherwise kaboom. If you want to serialize your own classes, you need to inherit them from CObject. It is also a bit more complicated. Websearch for DECLARE_SERIAL, IMPLEMENT_SERIAL. These are macros that you will need to add to your class. Finally, when you actually write the code to do the serialization of your class objects, you will need to over-ride Serialize(...), which your class will inherit from CObject. In your Serialize(...) over-ride, you will implement the necessary code to write your class object to a file. It will be pretty much the same as the sample code above. So, e.g., your class has an int size; member variable, you will do ar << size; in your Serialize(...) over-ride.

Max

Max
GeneralRe: MFC Serialization Pin
Keshav V. Kamat12-Apr-07 23:48
Keshav V. Kamat12-Apr-07 23:48 
QuestionHow to merge only two cells using MSHFlexGrid? Pin
megha_gharote12-Apr-07 22:26
megha_gharote12-Apr-07 22:26 
QuestionMultiple fonts CEdit Pin
hatemtaleb12-Apr-07 22:20
hatemtaleb12-Apr-07 22:20 
AnswerRe: Multiple fonts CEdit Pin
Mark Salsbery13-Apr-07 7:51
Mark Salsbery13-Apr-07 7:51 
Questionalready defined in .obj Pin
Programm3r12-Apr-07 22:16
Programm3r12-Apr-07 22:16 
AnswerRe: already defined in .obj (modified: some addendum) Pin
CPallini12-Apr-07 22:24
mveCPallini12-Apr-07 22:24 
QuestionRe: already defined in .obj [MOD] Pin
Programm3r12-Apr-07 22:30
Programm3r12-Apr-07 22:30 
AnswerRe: already defined in .obj [MOD] Pin
Michael Dunn12-Apr-07 23:02
sitebuilderMichael Dunn12-Apr-07 23:02 
GeneralRe: already defined in .obj [MOD] Pin
Programm3r13-Apr-07 1:15
Programm3r13-Apr-07 1:15 
GeneralRe: already defined in .obj (modified: some addendum) Pin
Programm3r12-Apr-07 22:35
Programm3r12-Apr-07 22:35 
AnswerRe: already defined in .obj Pin
Don Box12-Apr-07 22:34
Don Box12-Apr-07 22:34 
QuestionRe: already defined in .obj Pin
Programm3r12-Apr-07 22:36
Programm3r12-Apr-07 22:36 
GeneralRe: already defined in .obj Pin
cp987612-Apr-07 22:39
cp987612-Apr-07 22:39 
GeneralRe: already defined in .obj Pin
Programm3r12-Apr-07 22:41
Programm3r12-Apr-07 22:41 
QuestionHow to add data to a grid [modified] Pin
engilela12-Apr-07 21:20
engilela12-Apr-07 21:20 
QuestionLinker Error Pin
Programm3r12-Apr-07 19:59
Programm3r12-Apr-07 19:59 
AnswerRe: Linker Error Pin
Programm3r12-Apr-07 20:02
Programm3r12-Apr-07 20:02 

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.