資源簡介
一款供學(xué)習(xí)GDI的繪圖軟件,軟件構(gòu)架很有學(xué)習(xí)價(jià)值,實(shí)現(xiàn)圖行對象化,序列化。可對圖元進(jìn)行編輯修改等操作
代碼片段和文件信息
//?cntritem.h?:?interface?of?the?CDrawItem?class
//
//?This?is?a?part?of?the?Microsoft?Foundation?Classes?C++?library.
//?Copyright?(c)?Microsoft?Corporation.??All?rights?reserved.
//
//?This?source?code?is?only?intended?as?a?supplement?to?the
//?Microsoft?Foundation?Classes?Reference?and?related
//?electronic?documentation?provided?with?the?library.
//?See?these?sources?for?detailed?information?regarding?the
//?Microsoft?Foundation?Classes?product.
#include?“stdafx.h“
#include?“drawcli.h“
#include?“drawdoc.h“
#include?“drawobj.h“
#include?“drawvw.h“
#include?“cntritem.h“
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?baseD_CODE?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CDrawItem?implementation
IMPLEMENT_SERIAL(CDrawItem?COleClientItem?0)
CDrawItem::CDrawItem(CDrawDoc*?pContainer?CDrawOleObj*?pDrawObj)
:?COleClientItem(pContainer)
{
m_pDrawObj?=?pDrawObj;
}
CDrawItem::~CDrawItem()
{
if?(m_pDrawObj?!=?NULL)
m_pDrawObj->m_pClientItem?=?NULL;
}
void?CDrawItem::onchange(OLE_NOTIFICATION?nCode?DWORD?dwParam)
{
ASSERT_VALID(this);
COleClientItem::onchange(nCode?dwParam);
switch(nCode)
{
case?OLE_CHANGED_STATE:
case?OLE_CHANGED_ASPECT:
m_pDrawObj->Invalidate();
break;
case?OLE_CHANGED:
UpdateExtent();?//?extent?may?have?changed
m_pDrawObj->Invalidate();
break;
}
}
BOOL?CDrawItem::onchangeItemPosition(const?CRect&?rectPos)
{
ASSERT_VALID(this);
CDrawView*?pView?=?GetActiveView();
ASSERT_VALID(pView);
CRect?rect?=?rectPos;
pView->ClientToDoc(rect);
if?(rect?!=?m_pDrawObj->m_position)
{
//?invalidate?old?rectangle
m_pDrawObj->Invalidate();
//?update?to?new?rectangle
m_pDrawObj->m_position?=?rect;
GetExtent(&m_pDrawObj->m_extent);
//?and?invalidate?new?rectangle
m_pDrawObj->Invalidate();
//?mark?document?as?dirty
GetDocument()->SetModifiedFlag();
}
return?COleClientItem::onchangeItemPosition(rectPos);
}
void?CDrawItem::OnGetItemPosition(CRect&?rPosition)
{
ASSERT_VALID(this);
//?update?to?extent?of?item?if?m_position?is?not?initialized
if?(m_pDrawObj->m_position.IsRectEmpty())
UpdateExtent();
//?copy?m_position?which?is?in?document?coordinates
CDrawView*?pView?=?GetActiveView();
ASSERT_VALID(pView);
rPosition?=?m_pDrawObj->m_position;
pView->DocToClient(rPosition);
}
void?CDrawItem::Serialize(CArchive&?ar)
{
ASSERT_VALID(this);
//?Call?base?class?first?to?read?in?COleClientItem?data.
//?Note:?this?sets?up?the?m_pDocument?pointer?returned?from
//??CDrawItem::GetDocument?therefore?it?is?a?good?idea
//??to?call?the?base?class?Serialize?first.
COleClientItem::Serialize(ar);
//?now?store/retrieve?data?specific?to?CDrawItem
if?(ar.IsStoring())
{
//?TODO:?add?storing?code?here
}
else
{
//?TODO:?add?loading?code?here
}
}
BOOL?CDrawItem::UpdateExtent()
{
CSize?size;
if?(
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????4880??2002-09-26?03:50??drawcli\cntritem.cpp
?????文件???????1772??2002-09-26?03:50??drawcli\cntritem.h
?????文件???????2244??2014-06-19?10:07??drawcli\Debug\BscMake.command.1.tlog
?????文件???????1886??2014-06-19?10:07??drawcli\Debug\bscmake.read.1.tlog
?????文件???????1726??2014-06-19?10:07??drawcli\Debug\bscmake.write.1.tlog
?????文件??????11498??2014-06-19?10:07??drawcli\Debug\cl.command.1.tlog
?????文件??????44396??2014-06-19?10:07??drawcli\Debug\CL.read.1.tlog
?????文件??????11164??2014-06-19?10:07??drawcli\Debug\CL.write.1.tlog
?????文件??????31622??2014-06-18?14:04??drawcli\Debug\cntritem.obj
?????文件??????????0??2014-06-18?14:04??drawcli\Debug\cntritem.sbr
?????文件???12741632??2014-06-19?10:07??drawcli\Debug\drawcli.bsc
?????文件?????311296??2014-06-19?10:07??drawcli\Debug\drawcli.exe
?????文件????????667??2014-05-16?09:24??drawcli\Debug\drawcli.exe.em
?????文件????????732??2014-05-16?09:24??drawcli\Debug\drawcli.exe.em
?????文件????????381??2014-06-19?10:07??drawcli\Debug\drawcli.exe.intermediate.manifest
?????文件????2818532??2014-06-19?10:07??drawcli\Debug\drawcli.ilk
?????文件?????????66??2014-06-19?10:07??drawcli\Debug\drawcli.lastbuildstate
?????文件???????3043??2014-06-19?10:07??drawcli\Debug\drawcli.log
?????文件??????41616??2014-06-18?14:04??drawcli\Debug\drawcli.obj
?????文件???25296896??2014-05-16?09:23??drawcli\Debug\drawcli.pch
?????文件????5041152??2014-06-19?10:07??drawcli\Debug\drawcli.pdb
?????文件??????17996??2014-06-18?14:04??drawcli\Debug\drawcli.res
?????文件??????????0??2014-06-18?14:04??drawcli\Debug\drawcli.sbr
?????文件????????210??2014-05-16?09:23??drawcli\Debug\drawcli_manifest.rc
?????文件?????110644??2014-06-18?14:04??drawcli\Debug\drawdoc.obj
?????文件??????????0??2014-06-18?14:04??drawcli\Debug\drawdoc.sbr
?????文件?????129413??2014-06-18?14:04??drawcli\Debug\drawobj.obj
?????文件??????????0??2014-06-18?14:04??drawcli\Debug\drawobj.sbr
?????文件??????53922??2014-06-18?14:04??drawcli\Debug\drawtool.obj
?????文件??????????0??2014-06-18?14:04??drawcli\Debug\drawtool.sbr
............此處省略85個(gè)文件信息
評(píng)論
共有 條評(píng)論