The subject for this month is program that creates crossword puzzles. It is an SDI MFC program written in Visual C++ version 6.0 Foundation Classes.
If you look closely at the sample program display, you may notice that this is not really a crossword diagram. Words are displayed horizontally but not vertically. This is because the program is only half finished. The meeting for this month will discuss the graphical part of the program: How to put the information on the screen and how to interact with the document, view, and frame paradigm. The actual crossword algorithm and coding details will be discussed in May.
void CXwordDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here CFile* pFile = ar.GetFile (); m_nDocLength = pFile->GetLength (); // Allocate a buffer for the file data try { m_pFileData = new char[m_nDocLength]; } catch (CMemoryException* e) { m_nDocLength = 0; throw e; } // Read the file data into the buffer try { pFile->Read (m_pFileData, m_nDocLength); if (m_parray) free(m_parray); m_NX = m_NY = 16; m_parray = (char *) calloc(m_NX * m_NY, sizeof(char) ); CString buff; char *p=m_pFileData; int i=m_nDocLength; for (int y=0; y<m_NY; y++) { p = getFixedLine(&buff, p, m_NX, m_pFileData+m_nDocLength); strncpy(&m_parray[y*m_NX], buff.GetBuffer(20), m_NX); } } catch (CFileException* e) { delete[] m_pFileData; m_pFileData = NULL; m_nDocLength = 0; throw e; } } }