Click here to Skip to main content
15,912,756 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Serialize Pin
TUMB16-Sep-04 5:28
TUMB16-Sep-04 5:28 
GeneralRe: Serialize Pin
TUMB16-Sep-04 5:34
TUMB16-Sep-04 5:34 
GeneralRe: Serialize Pin
David Crow16-Sep-04 5:46
David Crow16-Sep-04 5:46 
GeneralRe: Serialize Pin
David Crow16-Sep-04 5:43
David Crow16-Sep-04 5:43 
GeneralRe: Serialize Pin
TUMB17-Sep-04 3:40
TUMB17-Sep-04 3:40 
GeneralRe: Serialize Pin
David Crow17-Sep-04 5:49
David Crow17-Sep-04 5:49 
GeneralRe: Serialize Pin
TUMB17-Sep-04 6:16
TUMB17-Sep-04 6:16 
GeneralRe: Serialize Pin
David Crow17-Sep-04 7:59
David Crow17-Sep-04 7:59 
TUMB wrote:
When I view the file in Notepad...

Notepad is a poor choice for viewing serialized (i.e., binary) files. Use Visual Studio instead.

TUMB wrote:
but if I enter a new FileName, It is giving me the following error.

filecore.cpp
Line 238


Have you looked at line 238 of FileCore.cpp?

I know why the assertion itself fires, but I don't know why the file has not been opened at that point. I dummied up an SDI application just now and it worked fine. The only additional thing I added that was not mentioned before is a call to SetModifiedFlag(TRUE) inside if the OnNewDocument() method (right before the return statement). Something like:

CMyDoc::CMyDoc()
{
    // comment out these lines the second time through
    m_nAge    = 26;
    m_strName = "Crow, David";
    m_dPay    = 12.34;
}
 
BOOL CMyDoc::OnNewDocument()
{
    if (!CDocument::OnNewDocument())
        return FALSE;

    SetModifiedFlag(TRUE);

    return TRUE;
}
 
void CMyDoc::Serialize(CArchive& ar)
{
    if (ar.IsStoring())
    {
        ar << m_nAge;
        ar << m_strName;
        ar << m_dPay;
    }
    else
    {
        ar >> m_nAge; // set a breakpoint here
        ar >> m_strName;
        ar >> m_dPay;
    }
}
Run this as is. Close the application. When prompted, enter a filename. Comment out the initialization in the document's constructor. Set a breakpoint in the Serialize() method. Run the code again. The three variables should hold assigned the contents of the file. Yes?


"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen


GeneralRe: Serialize Pin
Ryan Binns16-Sep-04 18:27
Ryan Binns16-Sep-04 18:27 
GeneralRe: Serialize Pin
TUMB17-Sep-04 1:53
TUMB17-Sep-04 1:53 
GeneralProgrammatically modifying an HTML document from visual C++ Pin
Freeman Taylor16-Sep-04 4:11
Freeman Taylor16-Sep-04 4:11 
GeneralRe: Programmatically modifying an HTML document from visual C++ Pin
David Crow16-Sep-04 5:07
David Crow16-Sep-04 5:07 
GeneralRe: Programmatically modifying an HTML document from visual C++ Pin
Freeman Taylor16-Sep-04 6:18
Freeman Taylor16-Sep-04 6:18 
GeneralRe: Programmatically modifying an HTML document from visual C++ Pin
Neville Franks16-Sep-04 10:33
Neville Franks16-Sep-04 10:33 
Generalfonts changing without me asking them to Pin
BlackDice16-Sep-04 3:57
BlackDice16-Sep-04 3:57 
GeneralRe: fonts changing without me asking them to Pin
Gary R. Wheeler19-Sep-04 15:48
Gary R. Wheeler19-Sep-04 15:48 
Generalserial port: client server communication Pin
thelearnervc16-Sep-04 3:02
thelearnervc16-Sep-04 3:02 
GeneralA tricky problem of converting to string Pin
Anonymous16-Sep-04 2:33
Anonymous16-Sep-04 2:33 
GeneralRe: A tricky problem of converting to string Pin
Paolo Ponzano16-Sep-04 2:48
Paolo Ponzano16-Sep-04 2:48 
GeneralRe: A tricky problem of converting to string Pin
PrashantJ16-Sep-04 3:43
PrashantJ16-Sep-04 3:43 
GeneralRe: A tricky problem of converting to string Pin
David Crow16-Sep-04 4:07
David Crow16-Sep-04 4:07 
GeneralRe: A tricky problem of converting to string Pin
PrashantJ16-Sep-04 4:36
PrashantJ16-Sep-04 4:36 
GeneralRe: A tricky problem of converting to string Pin
David Crow16-Sep-04 5:00
David Crow16-Sep-04 5:00 
General2 quick questions... Pin
0v3rloader16-Sep-04 2:24
0v3rloader16-Sep-04 2:24 
GeneralRe: 2 quick questions... Pin
Arsalan Malik16-Sep-04 2:48
Arsalan Malik16-Sep-04 2:48 

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.