|
If you can help me with any of these problems, I'd be very happy to hear from you...
- How to make an app start maximised in VisualC++, rather than starting minimised and then immediately maximising
- How to have a progress indicator in the status bar
- What the hell does CArchive::Read(...) do to file pointer position? Look at the following pieces of code from a Serialize(CArchive ar) function:
OnNewDocument();
ar.Flush();
fread(&m_Version, sizeof(int), 1, ((CStdioFile*)ar.GetFile())->m_pStream);
CSfFlow::Read(((CStdioFile*)ar.GetFile())->m_pStream);
and...
OnNewDocument();
ar.Read(&m_Version, sizeof(int));
ar.Flush();
CSfFlow::Read(((CStdioFile*)ar.GetFile())->m_pStream);
(CDocument::GetFile(...) has been overloaded so as to provide a CStdioFile rather than a CFile, so I can have access to a file pointer: for portability in the rest of my code). Well... The first bit of code works okay all the time. The second bit works for some files, but not for others. It seems that the file pointer position is a couple of bytes forward of where it should be... ar.Write(...) returns a value of 4 showing that an int has been written, but when I next read from the file using ar's file pointer, the position is wrong! Wierd.
- When writing binary string data to a stdio file... I have an escape sequence /r/r/n in a string, the length of this fragment is 3 bytes, right? Well, it is when it is written to a file, but I have found that when you have this stored in a CString, CString::GetLength() returns the length as 2 bytes. And when I have an array of chars in a binary file, and ask to read 3 bytes to get /r/r/n, it actually reads 4 bytes. So, is /r/n stored in memory as a single byte, and stored in file as two, or am I just missing something really obvoius?