Académique Documents
Professionnel Documents
Culture Documents
Document template
Frame
View
vSize = size();
ar << vSize;
for (iterator it = begin(); it != end(); ++it)
ar << *it;
}
else {
clear();
ar >> vSize;
reserve(vSize*2);
for (int i= 0; i < vSize; ++i) {
T val;
ar >> val;
push_back(val);
}
}
}
};
};
IMPLEMENT_SERIAL(CStroke, CObject, 1)
BOOL CScribbleDoc::OnNewDocument() {
if (!CDocument::OnNewDocument()) return FALSE;
InitDocument();
return TRUE; void CScribbleDoc::InitDocument() {
} m_nPenWidth = 6; // default 2 pixel pen width, solid, black pen
m_penCur.CreatePen(PS_SOLID, m_nPenWidth, RGB(0,0,0));
void CScribbleDoc::Serialize(CArchive& ar) { m_strokeList.Serialize(ar);
} }
};
#include "stdafx.h"
#include "Scribble.h"
#include "ChildFrm.h"
IMPLEMENT_DYNCREATE(CChildFrame,
CMDIChildWnd)
DECLARE_DYNCREATE(CScribbleView)
private:
CStroke* m_pStrokeCur; // the stroke in progress
CPoint m_ptPrev; // the last mouse pt in the stroke in progress
public:
CScribbleDoc* GetDocument();
protected:
DECLARE_MESSAGE_MAP()
};
#include "stdafx.h"
#include "Scribble.h"
#include "ScribDoc.h"
#include "ScribVw.h"
IMPLEMENT_DYNCREATE(CScribbleView, CView)
BEGIN_MESSAGE_MAP(CScribbleView, CView)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
CScribbleDoc* CScribbleView::GetDocument() {
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CScribbleDoc)));
return (CScribbleDoc*)m_pDocument;
}
dc.MoveTo(m_ptPrev); dc.LineTo(point);
dc.SelectObject(pOldPen); m_pStrokeCur->add(point);
ReleaseCapture();
return;
}
SetContainerInfo Determines the resources for OLE containers when editing an in-place OLE item.
SetServerInfo Determines the resources and classes when the server document is embedded or edited in-place.
GetFirstDocPosition Retrieves the position of the first document associated with this template.
GetNextDoc Retrieves a document and the position of the next one.
LoadTemplate Loads the resources for a given CDocTemplate or derived class.
AddDocument Adds a document to a template.
RemoveDocument Removes a document from a template.
GetDocString Retrieves a string associated with the document type.
Overridables
MatchDocType Determines the degree of confidence in the match between a document type and this template.
Overridables
OnActivateFrame Called when the frame window containing the view is activated or deactivated.
OnBeginPrinting Called when a print job begins; override to allocate graphics device interface (GDI) resources.
OnDraw Called to render an image of the document for screen display, printing, or print preview.
Implementation required.
OnUpdate Called to notify a view that its document has been modified.
Serialization
Miscellaneous
struct CRuntimeClass {
// Attributes
LPCSTR m_lpszClassName;
int m_nObjectSize;
UINT m_wSchema; // schema number of the loaded class
CObject* (PASCAL* m_pfnCreateObject)(); // NULL => abstract class
CRuntimeClass* m_pBaseClass;
// Operations
CObject* CreateObject();
BOOL IsDerivedFrom(const CRuntimeClass* pBaseClass) const;
// Implementation
void Store(CArchive& ar) const;
static CRuntimeClass* PASCAL Load(CArchive& ar, UINT* pwSchemaNum);
};
DECLARE_DYNAMIC( class_name )
IMPLEMENT_DYNAMIC( class_name, base_class_name )
DECLARE_DYNCREATE( class_name )
IMPLEMENT_DYNCREATE( class_name, base_class_name )
DECLARE_SERIAL( class_name )
IMPLEMENT_SERIAL( class_name, base_class_name, wSchema )
#define _DECLARE_DYNAMIC(class_name) \
public: \
static AFX_DATA CRuntimeClass class##class_name; \
virtual CRuntimeClass* GetRuntimeClass() const;
#define DECLARE_DYNCREATE(class_name) \
DECLARE_DYNAMIC(class_name) \
static CObject* CreateObject();
#define DECLARE_SERIAL(class_name) \
DECLARE_DYNCREATE(class_name) \
AFX_API friend CArchive& AFXAPI operator>>(CArchive& ar, class_name* &pOb);