資源簡介
畫圖軟件源代碼,MFC實(shí)現(xiàn),有圖形移動(dòng)、旋轉(zhuǎn)、選取、刪除等功能。

代碼片段和文件信息
//?Context.cpp:?implementation?of?the?CContext?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“Context.h“
//?根據(jù)繪圖模式設(shè)置繪圖環(huán)境:設(shè)置設(shè)備環(huán)境的模式并創(chuàng)建畫筆
void SetDrawEnvir(CDC* pDC?int?drawMode?CPen*?pPen)
{
int linestyle?lineWidth;
COLORREF color;
switch(drawMode)?
{
case?dmSelect:?//?選中狀態(tài)
{
pDC->SetROP2(R2_COPYPEN);
linestyle?=?PS_SOLID;
lineWidth?=?1;
color?=?RGB(25500);
break;
}
case?dmPrompt:?//?提示狀態(tài)
{
pDC->SetROP2(R2_COPYPEN);
linestyle?=?PS_DASH;
lineWidth?=?1;
color?=?RGB(0255255);
break;
}
case?dmDrag:?//?拖動(dòng)狀態(tài)
{
pDC->SetROP2(R2_XORPEN);
linestyle?=?PS_SOLID;
lineWidth?=?1;
color?=?RGB(1921920);
break;
}
case?dmInvalid:?//?擦除狀態(tài)
{
pDC->SetROP2(R2_COPYPEN);
linestyle?=?PS_SOLID;
lineWidth?=?1;
color?=?::GetBkColor(*pDC);?//?用背景色畫
break;
}
case?dmNormal:???
default:
{
pDC->SetROP2(R2_COPYPEN);
linestyle?=?PS_SOLID;
lineWidth?=?1;
color?=?RGB(000);
break;
}
}
pPen->CreatePen(linestylelineWidthcolor)?;
}
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
/*
CContext::CContext()
{
}
*/
CContext::~CContext()
{
g_pView->ReleaseDC(pDC);
}
void?CContext::MoveTo(const?Position?&pt)
{
g_pView->WorldtoScreen(pt?ptCurrent);?//?將世界坐標(biāo)轉(zhuǎn)化為屏幕坐標(biāo)
pDC->SetMapMode(MM_LOENGLISH);?
pDC->MoveTo(ptCurrent);?//?移動(dòng)到ptCurrent
}
void?CContext::LineTo(const?Position?&pt)
{
g_pView->WorldtoScreen(pt?ptCurrent);?//?將世界坐標(biāo)轉(zhuǎn)化為屏幕坐標(biāo)
pDC->SetMapMode(MM_LOENGLISH);?
int n?=?GetROP2(pDC->GetSafeHdc());?//?得到原來的繪圖模式
CPen pen;?
if(?drawMode?==?dmNormal?)??//?如果為正常狀態(tài)的繪制,根據(jù)成員變量創(chuàng)建畫筆
pen.CreatePen(m_linestylem_lineWidthm_color)?;
else?//?非正常狀態(tài)調(diào)用SetDrawEnvir函數(shù)設(shè)置繪圖環(huán)境
::SetDrawEnvir(pDC?drawMode?&pen);
CPen*?pOldPen?=?pDC->Selectobject(&pen);?//?得到原來的畫筆
pDC->LineTo(ptCurrent);
pDC->Selectobject(pOldPen);?//?恢復(fù)原來的畫筆?
pDC->SetROP2(n);?//?恢復(fù)原來的繪圖模式
}
void?CContext::Circle(const?Position?¢er?double?radius)
{
Position?ltpos(center.x?-?radius?center.y?+?radius?)?;
Position?rbpos(center.x?+?radius?center.y?-?radius?)?;
CPoint?ssp?sep?scenp;
g_pView->WorldtoScreen(ltposssp)?;
g_pView->WorldtoScreen(rbpossep)?;
// g_pView->WorldtoScreen(center?scenp)?;
int n?=?GetROP2(pDC->GetSafeHdc());
//?create?a?pen?by?following?rules:
//?if?in?normal?draw?mode?create?a?pen?by?its?member?variables?
//?if?else?create?a?pen?using?global?funtion?“SetDrawEnvir“
CPen pen;?
if(?drawMode?==?dmNormal?)?
pen.CreatePen(m_linestylem_lineWidthm_color)?;
else
::SetDrawEnvir(pDC?drawMode?&pen);
CPen*?pOldPen?=?pDC->Selectobject(&pen)?;
pDC->SetMapMode(MM_LOENGLISH);?
pDC->SelectStockobject(NULL_BRUSH)?;
pDC->Ellipse(ssp.x?ssp.y?se
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2962??2000-10-16?23:40??VCADVIEW.H
?????文件????????326??2006-04-16?22:59??RES\cur00001.cur
?????文件????????326??2000-10-16?23:29??RES\CURSOR1.CUR
?????文件????????326??2000-10-16?20:03??RES\DRAW_ARC.CUR
?????文件????????326??2000-10-16?20:04??RES\DRAW_CIR.CUR
?????文件????????326??2000-10-16?20:02??RES\DRAW_LIN.CUR
?????文件????????326??2000-10-16?20:04??RES\DRAW_REC.CUR
?????文件????????838??2000-10-16?18:58??RES\MODIFY.BMP
?????文件????????326??2000-10-16?23:31??RES\PROMPT_C.CUR
?????文件????????326??2000-10-16?23:31??RES\PROMPT_L.CUR
?????文件????????326??2000-10-16?23:31??RES\PROMPT_R.CUR
?????文件????????326??2006-04-16?22:59??RES\prompt_t.cur
?????文件????????238??2000-10-17?18:44??RES\PROPERTY.BMP
?????文件???????1078??2000-08-20?05:03??RES\TOOLBAR.BMP
?????文件????????718??2010-05-02?15:32??RES\toolbar1.bmp
?????文件???????1078??2000-08-20?05:03??RES\VCAD.ICO
?????文件????????396??2000-08-20?05:03??RES\VCAD.RC2
?????文件???????1078??2000-08-20?05:03??RES\VCADDOC.ICO
?????文件????????718??2000-10-16?19:03??RES\VIEW.BMP
?????文件???????5775??2007-03-15?13:33??ARC.CPP
?????文件???????4735??2007-04-29?22:57??ba
?????文件????????269??2007-03-01?08:11??ba
?????文件???????4027??2007-03-01?16:24??CIRCLE.CPP
?????文件????????896??2007-03-01?17:45??COMMAND.H
?????文件???????4281??2007-03-01?10:56??Context.cpp
?????文件???????2900??2007-03-01?10:54??Context.h
?????文件???????4660??2007-03-02?13:38??CREATEARC.CPP
?????文件???????3441??2007-03-02?13:40??CREATECIRCLE.CPP
?????文件???????2629??2010-05-02?22:39??CREATECMD.H
?????文件???????3993??2007-03-02?13:47??CREATELINE.CPP
............此處省略40個(gè)文件信息
評(píng)論
共有 條評(píng)論