// MakeSetConfigDoc.cpp : implementation of the CMakeSetConfigDoc class // #include "stdafx.h" // SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail // and search filter handlers and allows sharing of document code with that project. #ifndef SHARED_HANDLERS #include "MakeSetConfig.h" #endif #include "MakeSetConfigDoc.h" #include #ifdef _DEBUG #define new DEBUG_NEW #endif // CMakeSetConfigDoc IMPLEMENT_DYNCREATE(CMakeSetConfigDoc, CDocument) BEGIN_MESSAGE_MAP(CMakeSetConfigDoc, CDocument) END_MESSAGE_MAP() // CMakeSetConfigDoc construction/destruction CMakeSetConfigDoc::CMakeSetConfigDoc() { // TODO: add one-time construction code here } CMakeSetConfigDoc::~CMakeSetConfigDoc() { } BOOL CMakeSetConfigDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; if (!m_viewList.IsEmpty()) { reinterpret_cast(m_viewList.GetHead())->SetWindowText(NULL); } // TODO: add reinitialization code here // (SDI documents will reuse this document) return TRUE; } // CMakeSetConfigDoc serialization void CMakeSetConfigDoc::Serialize(CArchive& ar) { // CEditView contains an edit control which handles all serialization if (!m_viewList.IsEmpty()) { reinterpret_cast(m_viewList.GetHead())->SerializeRaw(ar); } #ifdef SHARED_HANDLERS if (m_viewList.IsEmpty() && ar.IsLoading()) { CFile* pFile = ar.GetFile(); pFile->Seek(0, FILE_BEGIN); ULONGLONG nFileSizeBytes = pFile->GetLength(); ULONGLONG nFileSizeChars = nFileSizeBytes/sizeof(TCHAR); LPTSTR lpszText = (LPTSTR)malloc(((size_t)nFileSizeChars + 1) * sizeof(TCHAR)); if (lpszText != NULL) { ar.Read(lpszText, (UINT)nFileSizeBytes); lpszText[nFileSizeChars] = '\0'; m_strThumbnailContent = lpszText; m_strSearchContent = lpszText; } } #endif } #ifdef SHARED_HANDLERS // Support for thumbnails void CMakeSetConfigDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) { // Modify this code to draw the document's data dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); LOGFONT lf; CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); pDefaultGUIFont->GetLogFont(&lf); lf.lfHeight = 36; CFont fontDraw; fontDraw.CreateFontIndirect(&lf); CFont* pOldFont = dc.SelectObject(&fontDraw); dc.DrawText(m_strThumbnailContent, lprcBounds, DT_CENTER | DT_WORDBREAK); dc.SelectObject(pOldFont); } // Support for Search Handlers void CMakeSetConfigDoc::InitializeSearchContent() { // Set search contents from document's data. // The content parts should be separated by ";" // Use the entire text file content as the search content. SetSearchContent(m_strSearchContent); } void CMakeSetConfigDoc::SetSearchContent(const CString& value) { if (value.IsEmpty()) { RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); } else { CMFCFilterChunkValueImpl *pChunk = NULL; ATLTRY(pChunk = new CMFCFilterChunkValueImpl); if (pChunk != NULL) { pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); SetChunkValue(pChunk); } } } #endif // SHARED_HANDLERS // CMakeSetConfigDoc diagnostics #ifdef _DEBUG void CMakeSetConfigDoc::AssertValid() const { CDocument::AssertValid(); } void CMakeSetConfigDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG // CMakeSetConfigDoc commands