Click here to Skip to main content
15,922,894 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: output Pin
sardinka26-Sep-03 9:25
sardinka26-Sep-03 9:25 
GeneralRe: output Pin
Ravi Bhavnani26-Sep-03 9:17
professionalRavi Bhavnani26-Sep-03 9:17 
GeneralOleLoadPicture() and Non-standard JPEG Files Pin
Steve Thresher26-Sep-03 5:45
Steve Thresher26-Sep-03 5:45 
GeneralSerializing question Pin
doctorpi26-Sep-03 4:46
doctorpi26-Sep-03 4:46 
GeneralRe: Serializing question Pin
David Crow26-Sep-03 5:44
David Crow26-Sep-03 5:44 
GeneralRe: Serializing question Pin
doctorpi26-Sep-03 6:20
doctorpi26-Sep-03 6:20 
GeneralRe: Serializing question Pin
David Crow26-Sep-03 6:50
David Crow26-Sep-03 6:50 
GeneralRe: Serializing question Pin
Nathan Smith26-Sep-03 5:57
Nathan Smith26-Sep-03 5:57 
I am not sure the application, but let me try to give an example from what I've done.

First you must open the file where you serialized the data, here is a sample serialize code...

I would advice that if these are settings for the view and in no way have anything to do with the document data, then do not store the values in your document. Rather create a new file called ViewSettings.dat and save the values in that. Lets say ViewSettings.dat is in your c:\\Program Files\\Program folder. Where Program is your program In the sample below we will assume that bEnableWindow is the variable you wish to serialize.

in CView's OnInitialUpdate call the serialize function passing an archive of the file.. Here's how to do it.

void CView::OnInitialUpdate()
{
CView::OnInitialUpdate();

try
{
CFile fileViewSettings( _T("C:\\Program Files\\Program\\ViewSettings.dat"),
CFile::modeRead );

CArchive arViewSettings( &fileViewSettings, CArchive::load );
Serialize( arViewSettings );
}
catch (CFileException* e)
{
// if the file has not yet been created then initialize default values //
// and also create the file to where the values will be serialized.
e->Delete();

bShowVisible = TRUE;

CFile file( _T("C:\\Program Files\\EGames\\Settings\\FrameSettings.dat"), CFile::modeCreate);

// At this point we should either have set a default value for bShowVisible if the file
// had not yet been created, or if it had then we have successfully loaded it in.

myButton.EnableWindow( bEnableWindow );
}

void CView::Serialize( CArchive& ar )
{
if( ar.IsStoring() )
{
/* Save your variables
example:

ar << bEnableWindow ; Where bEnableWindow is the boolean
for enabling your control.
*/
}
else
{
/* Else load in your variable
example:
ar >> bEnableWindow ;
*/
}
}

I hope this gives you an idea! Questions?? my email is nateinstein@hotmail.com I've been doing doc view for the past year religiously and have 3 serialize functions for just one class lol.

Nathan Smith - The Essence of Art in any design is not the medium in which it is made, but the creativity of the finished product.
GeneralRe: Serializing question Pin
Nathan Smith26-Sep-03 6:03
Nathan Smith26-Sep-03 6:03 
GeneralRe: Serializing question Pin
Navin26-Sep-03 6:51
Navin26-Sep-03 6:51 
GeneralRe: Serializing question Pin
Ravi Bhavnani26-Sep-03 8:40
professionalRavi Bhavnani26-Sep-03 8:40 
Generalusing a constant in several classes Pin
Jerome Conus26-Sep-03 4:39
Jerome Conus26-Sep-03 4:39 
GeneralRe: using a constant in several classes Pin
Dominik Reichl26-Sep-03 4:50
Dominik Reichl26-Sep-03 4:50 
GeneralRe: using a constant in several classes Pin
Alvaro Mendez26-Sep-03 5:06
Alvaro Mendez26-Sep-03 5:06 
GeneralRe: using a constant in several classes Pin
Joe Woodbury26-Sep-03 12:15
professionalJoe Woodbury26-Sep-03 12:15 
QuestionAccellerators in modeless dialog ? Pin
Brian van der Beek26-Sep-03 4:19
Brian van der Beek26-Sep-03 4:19 
AnswerRe: Accellerators in modeless dialog ? Pin
valikac26-Sep-03 4:32
valikac26-Sep-03 4:32 
GeneralRe: Accellerators in modeless dialog ? Pin
Brian van der Beek26-Sep-03 5:00
Brian van der Beek26-Sep-03 5:00 
AnswerRe: Accellerators in modeless dialog ? Pin
Alvaro Mendez26-Sep-03 5:11
Alvaro Mendez26-Sep-03 5:11 
GeneralRe: Accellerators in modeless dialog ? Pin
Brian van der Beek28-Sep-03 21:34
Brian van der Beek28-Sep-03 21:34 
Questionhow to set initial size of dialog? Pin
ns26-Sep-03 4:18
ns26-Sep-03 4:18 
AnswerRe: how to set initial size of dialog? Pin
valikac26-Sep-03 4:33
valikac26-Sep-03 4:33 
GeneralRe: how to set initial size of dialog? Pin
ns26-Sep-03 4:52
ns26-Sep-03 4:52 
GeneralRe: how to set initial size of dialog? Pin
Alvaro Mendez26-Sep-03 5:14
Alvaro Mendez26-Sep-03 5:14 
GeneralRe: how to set initial size of dialog? Pin
PJ Arends26-Sep-03 8:32
professionalPJ Arends26-Sep-03 8:32 

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.