www.pudn.com > GandyDraw_MFC.rar > GandyDrawView.cpp, change:2006-11-21,size:48835b


// GandyDrawView.cpp : CGandyDrawView 类的实现 
// 
 
#include "stdafx.h" 
#include "GandyDraw.h" 
 
#include "GandyDrawDoc.h" 
#include "GandyDrawView.h" 
 
#include "MainFrm.h" 
#include "InputStr.h" 
#include "SetWidthDlg.h" 
#include "DukeDlg.h" 
#include "ChangeBmp.h" 
#include "DrawSetDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#endif 
 
 
// CGandyDrawView 
 
IMPLEMENT_DYNCREATE(CGandyDrawView, CView) 
 
BEGIN_MESSAGE_MAP(CGandyDrawView, CView) 
	// 标准打印命令 
	ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview) 
	ON_COMMAND(ID_VIEW_DS_TBAR, &CGandyDrawView::OnViewDsTbar) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_DS_TBAR, &CGandyDrawView::OnUpdateViewDsTbar) 
	ON_COMMAND(ID_LINE, &CGandyDrawView::OnLine) 
	ON_COMMAND(ID_POLYLINE, &CGandyDrawView::OnPolyline) 
	ON_COMMAND(ID_RECT, &CGandyDrawView::OnRect) 
	ON_COMMAND(ID_ELLIRECT, &CGandyDrawView::OnEllirect) 
	ON_COMMAND(ID_ELLIPSE, &CGandyDrawView::OnEllipse) 
	ON_COMMAND(ID_POLYGON, &CGandyDrawView::OnPolygon) 
	ON_COMMAND(ID_TEXTDRAW, &CGandyDrawView::OnTextdraw) 
	ON_COMMAND(ID_SOLID, &CGandyDrawView::OnSolid) 
	ON_COMMAND(ID_DASH, &CGandyDrawView::OnDash) 
	ON_COMMAND(ID_DOT, &CGandyDrawView::OnDot) 
	ON_COMMAND(ID_DASHDOT, &CGandyDrawView::OnDashdot) 
	ON_COMMAND(ID_DASHDOTDOT, &CGandyDrawView::OnDashdotdot) 
	ON_COMMAND(ID_SETWIDTH1, &CGandyDrawView::OnSetwidth1) 
	ON_COMMAND(ID_SETWIDTH2, &CGandyDrawView::OnSetwidth2) 
	ON_COMMAND(ID_SETWIDTH3, &CGandyDrawView::OnSetwidth3) 
	ON_COMMAND(ID_SETWIDTH4, &CGandyDrawView::OnSetwidth4) 
	ON_COMMAND(ID_SETWIDTH8, &CGandyDrawView::OnSetwidth8) 
	ON_COMMAND(ID_SETWIDTH10, &CGandyDrawView::OnSetwidth10) 
	ON_COMMAND(ID_SETWIDTH20, &CGandyDrawView::OnSetwidth20) 
	ON_COMMAND(ID_SETWIDTH50, &CGandyDrawView::OnSetwidth50) 
	ON_COMMAND(ID_BRU_HOLLOW, &CGandyDrawView::OnBruHollow) 
	ON_COMMAND(ID_BRU_SOLID, &CGandyDrawView::OnBruSolid) 
	ON_COMMAND(ID_FILLWITHPICTURE, &CGandyDrawView::OnFillwithpicture) 
	ON_COMMAND(ID_STR_HOR, &CGandyDrawView::OnStrHor) 
	ON_COMMAND(ID_STR_VER, &CGandyDrawView::OnStrVer) 
	ON_COMMAND(ID_STR_BIA, &CGandyDrawView::OnStrBia) 
	ON_COMMAND(ID_STR_BLA, &CGandyDrawView::OnStrBla) 
	ON_COMMAND(ID_STR_CRO, &CGandyDrawView::OnStrCro) 
	ON_COMMAND(ID_STR_CCRO, &CGandyDrawView::OnStrCcro) 
	ON_COMMAND(ID_PENCOLOR, &CGandyDrawView::OnPencolor) 
	ON_COMMAND(ID_BRU_COLOR, &CGandyDrawView::OnBruColor) 
	ON_WM_SETCURSOR() 
	ON_WM_CREATE() 
	ON_WM_LBUTTONDOWN() 
	ON_WM_MOUSEMOVE() 
	ON_WM_LBUTTONUP() 
	ON_WM_RBUTTONUP() 
	ON_COMMAND(ID_SETFONT, &CGandyDrawView::OnSetfont) 
	ON_COMMAND(ID_TESTROTATION, &CGandyDrawView::OnTestrotation) 
	ON_COMMAND(ID_SETFONTCOLOR, &CGandyDrawView::OnSetfontcolor) 
	ON_COMMAND(ID_CLEARALL, &CGandyDrawView::OnClearall) 
	ON_COMMAND(ID_INPUTSTR, &CGandyDrawView::OnInputstr) 
	ON_COMMAND(ID_OUTPUTSTR, &CGandyDrawView::OnOutputstr) 
	ON_COMMAND(ID_SETFONTBKCOLOR, &CGandyDrawView::OnSetfontbkcolor) 
	ON_COMMAND(ID_OUTPUTFONTSIZE, &CGandyDrawView::OnOutputfontsize) 
	ON_COMMAND(ID_DRAWOEMBMP, &CGandyDrawView::OnDrawoembmp) 
	ON_COMMAND(ID_OPENBMP, &CGandyDrawView::OnOpenbmp) 
	ON_COMMAND(ID_BLACKONWHITE, &CGandyDrawView::OnBlackonwhite) 
	ON_COMMAND(ID_WHITEONBLACK, &CGandyDrawView::OnWhiteonblack) 
	ON_COMMAND(ID_COLORONCOLOR, &CGandyDrawView::OnColoroncolor) 
	ON_COMMAND(ID_HALFTONE, &CGandyDrawView::OnHalftone) 
	ON_COMMAND(ID_DISPSTRBMP, &CGandyDrawView::OnDispstrbmp) 
	ON_COMMAND(ID_DISPVIRBMP, &CGandyDrawView::OnDispvirbmp) 
	ON_COMMAND(ID_STRFILLCLIENT, &CGandyDrawView::OnStrfillclient) 
	ON_COMMAND(ID_STRKEEPRATE, &CGandyDrawView::OnStrkeeprate) 
	ON_UPDATE_COMMAND_UI(ID_STRKEEPRATE, &CGandyDrawView::OnUpdateStrkeeprate) 
	ON_UPDATE_COMMAND_UI(ID_DISPVIRBMP, &CGandyDrawView::OnUpdateDispvirbmp) 
	ON_UPDATE_COMMAND_UI(ID_DISPSTRBMP, &CGandyDrawView::OnUpdateDispstrbmp) 
	ON_UPDATE_COMMAND_UI(ID_STRFILLCLIENT, &CGandyDrawView::OnUpdateStrfillclient) 
	ON_UPDATE_COMMAND_UI(ID_BLACKONWHITE, &CGandyDrawView::OnUpdateBlackonwhite) 
	ON_UPDATE_COMMAND_UI(ID_WHITEONBLACK, &CGandyDrawView::OnUpdateWhiteonblack) 
	ON_UPDATE_COMMAND_UI(ID_COLORONCOLOR, &CGandyDrawView::OnUpdateColoroncolor) 
	ON_UPDATE_COMMAND_UI(ID_HALFTONE, &CGandyDrawView::OnUpdateHalftone) 
	ON_COMMAND(ID_SETWIDTH, &CGandyDrawView::OnSetwidth) 
	ON_COMMAND(ID_JAVADUKE, &CGandyDrawView::OnJavaduke) 
	ON_COMMAND(ID_CHANGEBMP, &CGandyDrawView::OnChangebmp) 
	ON_COMMAND(ID_DRAWSET, &CGandyDrawView::OnDrawset) 
	ON_UPDATE_COMMAND_UI(ID_LINE, &CGandyDrawView::OnUpdateLine) 
	ON_UPDATE_COMMAND_UI(ID_ELLIPSE, &CGandyDrawView::OnUpdateEllipse) 
	ON_UPDATE_COMMAND_UI(ID_ELLIRECT, &CGandyDrawView::OnUpdateEllirect) 
	ON_UPDATE_COMMAND_UI(ID_POLYGON, &CGandyDrawView::OnUpdatePolygon) 
	ON_UPDATE_COMMAND_UI(ID_RECT, &CGandyDrawView::OnUpdateRect) 
	ON_UPDATE_COMMAND_UI(ID_POLYLINE, &CGandyDrawView::OnUpdatePolyline) 
	ON_UPDATE_COMMAND_UI(ID_TEXTDRAW, &CGandyDrawView::OnUpdateTextdraw) 
	ON_UPDATE_COMMAND_UI(ID_DASH, &CGandyDrawView::OnUpdateDash) 
	ON_UPDATE_COMMAND_UI(ID_DOT, &CGandyDrawView::OnUpdateDot) 
	ON_UPDATE_COMMAND_UI(ID_DASHDOT, &CGandyDrawView::OnUpdateDashdot) 
	ON_UPDATE_COMMAND_UI(ID_DASHDOTDOT, &CGandyDrawView::OnUpdateDashdotdot) 
	ON_UPDATE_COMMAND_UI(ID_SOLID, &CGandyDrawView::OnUpdateSolid) 
	ON_UPDATE_COMMAND_UI(ID_BRU_HOLLOW, &CGandyDrawView::OnUpdateBruHollow) 
	ON_UPDATE_COMMAND_UI(ID_BRU_SOLID, &CGandyDrawView::OnUpdateBruSolid) 
	ON_UPDATE_COMMAND_UI(ID_FILLWITHPICTURE, &CGandyDrawView::OnUpdateFillwithpicture) 
	ON_UPDATE_COMMAND_UI(ID_STR_BIA, &CGandyDrawView::OnUpdateStrBia) 
	ON_UPDATE_COMMAND_UI(ID_STR_BLA, &CGandyDrawView::OnUpdateStrBla) 
	ON_UPDATE_COMMAND_UI(ID_STR_CCRO, &CGandyDrawView::OnUpdateStrCcro) 
	ON_UPDATE_COMMAND_UI(ID_STR_CRO, &CGandyDrawView::OnUpdateStrCro) 
	ON_UPDATE_COMMAND_UI(ID_STR_HOR, &CGandyDrawView::OnUpdateStrHor) 
	ON_UPDATE_COMMAND_UI(ID_STR_VER, &CGandyDrawView::OnUpdateStrVer) 
	ON_UPDATE_COMMAND_UI(ID_SETWIDTH1, &CGandyDrawView::OnUpdateSetwidth1) 
	ON_UPDATE_COMMAND_UI(ID_SETWIDTH10, &CGandyDrawView::OnUpdateSetwidth10) 
	ON_UPDATE_COMMAND_UI(ID_SETWIDTH2, &CGandyDrawView::OnUpdateSetwidth2) 
	ON_UPDATE_COMMAND_UI(ID_SETWIDTH20, &CGandyDrawView::OnUpdateSetwidth20) 
	ON_UPDATE_COMMAND_UI(ID_SETWIDTH3, &CGandyDrawView::OnUpdateSetwidth3) 
	ON_UPDATE_COMMAND_UI(ID_SETWIDTH4, &CGandyDrawView::OnUpdateSetwidth4) 
	ON_UPDATE_COMMAND_UI(ID_SETWIDTH50, &CGandyDrawView::OnUpdateSetwidth50) 
	ON_UPDATE_COMMAND_UI(ID_SETWIDTH8, &CGandyDrawView::OnUpdateSetwidth8) 
	END_MESSAGE_MAP() 
 
// CGandyDrawView 构造/析构 
 
CGandyDrawView::CGandyDrawView() 
: m_bTBar(true) 
, m_bDoing(false) 
, m_iMaxX(0) 
, m_iMaxY(0) 
, m_iWidth(0) 
, m_pBmp(NULL) 
, m_pMDC(NULL) 
, m_PointOld(0) 
, m_PointNew(0) 
, m_DrawType(0) 
, m_iPenStyle(0) 
, m_iHatchStyle(0) 
, m_iBrushStyle(0) 
, m_iPCount(0) 
, m_PointLast_PL(0) 
, m_PointFirst_PL(0) 
, m_bClick(false) 
, fontSize(0) 
, italic(false) 
, bold(false) 
, underline(false) 
, strikeOut(false) 
, m_PointLast_StatusBar(0) 
, m_strText(_T("默认测试文本")) 
, m_bBitmapLoaded(false) 
, m_iStretchBltMode(3) 
, m_bIsStretchBlt(false) 
, m_bIsKeepingRate(false) 
, m_bIsOpeningBmp(false) 
, m_BmpPathName(_T("")) 
	{ 
	// TODO: 在此处添加构造代码 
	m_bDoing = false; 
	m_DrawType = 0; 
	m_iWidth = 1; 
	m_PenColor = RGB(0,0,0); 
	textBkColor = RGB(255,255,255); 
	m_pMDC = new CDC; 
	m_pBmp = new CBitmap; 
	m_iStretchBltMode = 3; 
 
	//CFont font; 
	//font.CreatePointFont(120, L"宋体"); 
	//font.GetLogFont(&logFont); 
	fontName = "宋体"; 
	fontSize = 105; 
	textColor = RGB(0,0,255); 
	m_Bitmap.LoadBitmapW(IDB_BITMAP_MM); 
 
 
 
} 
 
CGandyDrawView::~CGandyDrawView() 
{ 
	delete m_pBmp; 
	delete m_pMDC; 
} 
 
BOOL CGandyDrawView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: 在此处通过修改 
	//  CREATESTRUCT cs 来修改窗口类或样式 
 
	return CView::PreCreateWindow(cs); 
} 
 
// CGandyDrawView 绘制 
 
void CGandyDrawView::OnDraw(CDC* pDC) 
{ 
	CGandyDrawDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	if (!pDoc) 
		return; 
 
 
 
//画直线 矩形 椭圆 时的OnDraw()函数	 
if(m_DrawType <= 6) 
{ 
	CBitmap *pOldBmp = m_pMDC->SelectObject(m_pBmp); 
	pDC->BitBlt(0,0,m_iMaxX,m_iMaxY,m_pMDC,0,0,SRCCOPY); 
	m_pMDC->SelectObject(pOldBmp); 
	 
 
} 
 
//(m_DrawType > 6) 即显示位图时的OnDraw()函数 
else  
{ 
	 
	CRect crect; 
	GetClientRect(&crect); 
	if(m_bIsStretchBlt == false)//******显示原始位图时的OnDraw()函数 功能:1.可以直线矩形等绘图 2.可以擦除客户区 
	{ 
	CBitmap * pOldBmp1 = m_pMDC->SelectObject(m_pBmp); 
	CBitmap *pOldBmp; 
	 
	pDC->BitBlt(0,0,m_iMaxX,m_iMaxY,m_pMDC,0,0,SRCCOPY); 
 
	dc.CreateCompatibleDC(m_pMDC); 
	m_FileBitmap.GetBitmap(&bs); 
	pOldBmp=dc.SelectObject(&m_FileBitmap); 
 
	m_pMDC->BitBlt(0,0,bs.bmWidth,bs.bmHeight,&dc,0,0,SRCCOPY); 
 
	dc.SelectObject(pOldBmp); 
	dc.DeleteDC(); 
	Invalidate(false); 
	m_pMDC->SelectObject(pOldBmp1); 
	ReleaseDC(m_pMDC); 
	} 
 
 
 
	if(m_bIsStretchBlt == true)//******显示缩放位图时的OnDraw()函数 
	{ 
 
	CBitmap * pOldBmp1 = m_pMDC->SelectObject(m_pBmp); 
	CBitmap *pOldBmp; 
 
	 
	 
	pDC->BitBlt(0,0,m_iMaxX,m_iMaxY,m_pMDC,0,0,SRCCOPY); 
	m_pMDC->FillSolidRect(&crect,RGB(255,255,255)); 
 
	m_DrawType = 20; 
 
 
 
	m_pMDC->SetStretchBltMode(m_iStretchBltMode); 
 
	dc.CreateCompatibleDC(m_pMDC); 
	dc.SetStretchBltMode(m_iStretchBltMode); //将dc设置缩放模式 
	m_FileBitmap.GetBitmap(&bs); 
	pOldBmp=dc.SelectObject(&m_FileBitmap); 
 
	//m_pMDC->StretchBlt(0, 0, crect.right,crect.bottom, &dc, 0, 0,  
	//						bs.bmWidth, bs.bmHeight, SRCCOPY); 
 
	//*********以下代码实现“保持宽高比”与“填充客户区”两种缩放,并能支持缩放的类型如白去黑,多彩等************** 
	if(m_bIsKeepingRate == true) //保持宽高比缩放 m_bIsKeepingRate == true; 
	{ 
		if(crect.bottom!=0 && crect.right!=0) 
		{ 
 
			if(crect.right*bs.bmHeight >= crect.bottom*bs.bmWidth) 
			{ 
				m_pMDC->StretchBlt((crect.right-bs.bmWidth*crect.bottom/bs.bmHeight)/2,0 
				,bs.bmWidth*crect.bottom/bs.bmHeight,crect.bottom, &dc, 0,0,bs.bmWidth, bs.bmHeight, SRCCOPY); 
			} 
 
			else 
			{ 
				m_pMDC->StretchBlt(0,(crect.bottom-bs.bmHeight*crect.right/bs.bmWidth)/2 
				,crect.right,bs.bmHeight*crect.right/bs.bmWidth, &dc, 0,0,bs.bmWidth, bs.bmHeight, SRCCOPY); 
			} 
 
		 } 
	} 
	 
	else //填满整个客户区缩放 m_bIsKeepingRate == false 
	{ 
		m_pMDC->StretchBlt(0, 0, crect.right,crect.bottom, &dc, 0, 0,  
							bs.bmWidth, bs.bmHeight, SRCCOPY); 
	} 
	//*********以下代码实现“保持宽高比”与“填充客户区”两种缩放,并能支持缩放的类型如白去黑,多彩等************** 
 
	 
	Invalidate(false); 
	dc.SelectObject(pOldBmp); 
	Invalidate(false); 
	m_pMDC->SelectObject(pOldBmp1); 
	ReleaseDC(m_pMDC); 
 
 
	}//属于缩放型位图时刷新函数 
} 
 
 
 
} 
 
 
// CGandyDrawView 打印 
 
BOOL CGandyDrawView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// 默认准备 
	return DoPreparePrinting(pInfo); 
} 
 
void CGandyDrawView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: 添加额外的打印前进行的初始化过程 
} 
 
void CGandyDrawView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: 添加打印后进行的清除过程 
} 
 
 
// CGandyDrawView 诊断 
 
#ifdef _DEBUG 
void CGandyDrawView::AssertValid() const 
{ 
	CView::AssertValid(); 
} 
 
void CGandyDrawView::Dump(CDumpContext& dc) const 
{ 
	CView::Dump(dc); 
} 
 
CGandyDrawDoc* CGandyDrawView::GetDocument() const // 非调试版本是内联的 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGandyDrawDoc))); 
	return (CGandyDrawDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
 
// CGandyDrawView 消息处理程序 
 
void CGandyDrawView::OnViewDsTbar() 
{ 
	// TODO: 在此添加命令处理程序代码 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	if(m_bTBar==true) 
	{ 
		m_bTBar = false; 
		pFrmWnd->ShowControlBar(&pFrmWnd->m_ToolBar_ds, FALSE, FALSE); 
	} 
	else 
	{ 
	    m_bTBar = true; 
		pFrmWnd->ShowControlBar(&pFrmWnd->m_ToolBar_ds, TRUE, FALSE); 
 
	} 
} 
 
void CGandyDrawView::OnUpdateViewDsTbar(CCmdUI *pCmdUI) 
{ 
	// TODO: 绘图风格选中与否 
	if(m_bTBar==true)    
	{ 
		pCmdUI->SetCheck(true);   
	} 
	else 
	{ 
		pCmdUI->SetCheck(false); 
	} 
} 
 
void CGandyDrawView::OnLine() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_DrawType  = 0; 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"画直线:单击拖动绘直线"); 
} 
 
void CGandyDrawView::OnPolyline() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_DrawType  = 1; 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"画折线:单击开始,右键结束折线绘制"); 
} 
 
void CGandyDrawView::OnRect() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_DrawType   = 2; 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"按住Shift时,拖动鼠标画正方形"); 
} 
 
void CGandyDrawView::OnEllirect() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_DrawType  = 3; 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"画圆角矩形"); 
} 
 
void CGandyDrawView::OnEllipse() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_DrawType  = 4; 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"按住Shift时,拖动鼠标画圆"); 
} 
 
void CGandyDrawView::OnPolygon() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_DrawType   = 5; 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"画多边形:单击开始,右键结束折线绘制"); 
} 
 
void CGandyDrawView::OnTextdraw() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_DrawType = 6; 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"在单击处显示输入的文本(默认为“默认测试文本”)"); 
} 
 
void CGandyDrawView::OnSolid() 
{ 
	 
	m_iPenStyle = PS_SOLID; 
 
} 
 
void CGandyDrawView::OnDash() 
{ 
	 
	m_iPenStyle = PS_DASH; 
} 
 
void CGandyDrawView::OnDot() 
{ 
	 
	m_iPenStyle = PS_DOT; 
 
} 
 
void CGandyDrawView::OnDashdot() 
{ 
	 
	m_iPenStyle = PS_DASHDOT; 
} 
 
void CGandyDrawView::OnDashdotdot() 
{ 
	 
	m_iPenStyle = PS_DASHDOTDOT; 
} 
 
void CGandyDrawView::OnSetwidth1() 
{ 
	 
	m_iWidth = 1; 
} 
 
void CGandyDrawView::OnSetwidth2() 
{ 
	 
	m_iWidth = 2; 
} 
 
void CGandyDrawView::OnSetwidth3() 
{ 
	 
	m_iWidth = 3; 
} 
 
void CGandyDrawView::OnSetwidth4() 
{ 
	 
	m_iWidth = 4; 
} 
 
void CGandyDrawView::OnSetwidth8() 
{ 
	 
	m_iWidth = 8; 
} 
 
void CGandyDrawView::OnSetwidth10() 
{ 
	 
	m_iWidth = 10; 
} 
 
void CGandyDrawView::OnSetwidth20() 
{ 
	 
	m_iWidth = 20; 
} 
 
void CGandyDrawView::OnSetwidth50() 
{ 
	 
	m_iWidth = 50; 
} 
 
void CGandyDrawView::OnBruHollow() 
{ 
	 
	m_iBrushStyle = 0; 
} 
 
void CGandyDrawView::OnBruSolid() 
{ 
	 
	m_iBrushStyle = 1; 
} 
 
void CGandyDrawView::OnFillwithpicture() 
{ 
	 
	m_iBrushStyle = 3; 
//	BITMAP bm; 
	 
	m_Bitmap.LoadBitmapW(IDB_BITMAP_MM); 
	//m_Bitmap.GetBitmap(&bm); 
	//m_Bitmap.SetBitmapDimension(bm.bmWidth/4,bm.bmHeight/4); 
} 
 
void CGandyDrawView::OnStrHor() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_iBrushStyle = 2; 
	m_iHatchStyle = HS_HORIZONTAL; 
} 
 
void CGandyDrawView::OnStrVer() 
{ 
 
	m_iBrushStyle = 2; 
	m_iHatchStyle = HS_VERTICAL; 
} 
 
void CGandyDrawView::OnStrBia() 
{ 
 
	m_iBrushStyle = 2; 
	m_iHatchStyle = HS_FDIAGONAL; 
} 
 
void CGandyDrawView::OnStrBla() 
{ 
 
	m_iBrushStyle = 2; 
	m_iHatchStyle = HS_BDIAGONAL; 
} 
 
void CGandyDrawView::OnStrCro() 
{ 
 
	m_iBrushStyle = 2; 
	m_iHatchStyle = HS_CROSS; 
} 
 
void CGandyDrawView::OnStrCcro() 
{ 
 
	m_iBrushStyle = 2; 
	m_iHatchStyle = HS_DIAGCROSS; 
} 
 
void CGandyDrawView::OnPencolor() 
{ 
	CColorDialog dlg; 
	dlg.m_cc.Flags |=CC_PREVENTFULLOPEN | CC_RGBINIT; 
	dlg.m_cc.rgbResult = m_PenColor; 
	if(dlg.DoModal()==IDOK) 
	{ 
		m_PenColor = dlg.GetColor(); 
	} 
} 
 
void CGandyDrawView::OnBruColor() 
{ 
 
	CColorDialog dlg; 
	dlg.m_cc.Flags |=CC_PREVENTFULLOPEN | CC_RGBINIT; 
	dlg.m_cc.rgbResult = m_BrushColor; 
	if(dlg.DoModal()==IDOK) 
	{ 
		m_BrushColor = dlg.GetColor(); 
	} 
} 
 
BOOL CGandyDrawView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{ 
 
	switch(m_DrawType) 
	{ 
	case 0: 
		::SetCursor(AfxGetApp()->LoadCursorW(IDC_CURSOR1)); 
		break; 
	case 1: 
		::SetCursor(AfxGetApp()->LoadCursorW(IDC_CURSOR5)); 
		break; 
	case 2: 
		::SetCursor(AfxGetApp()->LoadCursorW(IDC_CURSOR2)); 
		break; 
	case 3: 
		::SetCursor(AfxGetApp()->LoadCursorW(IDC_CURSOR4)); 
		break; 
	case 4: 
		::SetCursor(AfxGetApp()->LoadCursorW(IDC_CURSOR3)); 
		break; 
	case 5: 
		::SetCursor(AfxGetApp()->LoadCursorW(IDC_CURSOR6)); 
		break; 
	case 6: 
		::SetCursor(AfxGetApp()->LoadCursorW(IDC_CURSOR7)); 
		break; 
	default: 
		::SetCursor(AfxGetApp()->LoadCursorW(IDC_ARROW)); 
		break; 
	} 
	//::SetCursor(AfxGetApp()->LoadCursorW(IDC_CURSOR1)); 
 
//	return CView::OnSetCursor(pWnd, nHitTest, message); 
	return true; 
} 
 
int CGandyDrawView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
	if (CView::OnCreate(lpCreateStruct) == -1) 
		return -1; 
 
	// TODO:  创建OnCreate()函数。。。 
	//GetSystemMetrics()得到屏幕尺寸  
	m_iMaxX = GetSystemMetrics(SM_CXSCREEN); 
	m_iMaxY = GetSystemMetrics(SM_CYSCREEN); 
 
	CDC * pDC = GetDC(); 
	 
	m_pMDC->CreateCompatibleDC(pDC); 
	m_pBmp->CreateCompatibleBitmap(pDC,m_iMaxX,m_iMaxY); 
 
	CBitmap * pOldBitmap = m_pMDC->SelectObject(m_pBmp); 
 
	CBrush brush; 
	brush.CreateStockObject(WHITE_BRUSH); 
	CRect rect(-1,-1,m_iMaxX,m_iMaxY); 
	m_pMDC->FillRect(rect,&brush); 
	m_pMDC->SelectObject(pOldBitmap); 
	ReleaseDC(pDC); 
 
 
	return 0; 
} 
 
void CGandyDrawView::OnLButtonDown(UINT nFlags, CPoint point) 
{ 
 
 
	m_PointLast_StatusBar = point; 
 
	if(m_bDoing==true) 
	{ 
	    return; 
	} 
 
	SetCapture(); 
	m_bDoing = true; 
	m_PointNew = point; 
	m_PointOld = point; 
 
 
	if(m_DrawType == 1)  //画折线时,每单击一次,将点坐标记入arrayP数组 
	{ 
		//CDC * pDC = GetDC(); 
		//pDC->SetPixel(point,m_PenColor); 
		//arrayP[m_iPCount++] = point; 
		//m_PointLast_PL = point; 
	} 
 
 
	//***************************************************** 
	if(m_DrawType == 10) //实现区域填充功能 m_DrawType == 10 
	{ 
	   CBrush * pOldBrush; 
	   CBitmap * pOldBmp; 
	   CBrush bfill; 
	   bfill.CreateSolidBrush(m_BrushColor); 
	   pOldBrush = m_pMDC->SelectObject(&bfill); 
	   pOldBmp = m_pMDC->SelectObject(m_pBmp); 
 
	   m_pMDC->ExtFloodFill(point.x,point.y,m_pMDC->GetPixel(point),FLOODFILLSURFACE); 
 
	   Invalidate(false); 
	   m_pMDC->SelectObject(pOldBrush); 
	   m_pMDC->SelectObject(pOldBmp); 
	   m_bDoing = false; 
	} 
	//***************************************************** 
 
 
	CView::OnLButtonDown(nFlags, point); 
} 
 
void CGandyDrawView::OnMouseMove(UINT nFlags, CPoint point) 
{ 
	// TODO: 在此添加消息处理程序代码和/或调用默认值 
	 
	wchar_t buf[20]; 
	CMainFrame *pFrmWnd = (CMainFrame*)GetTopLevelFrame(); 
	 
	_itow_s(point.x, buf, 20, 10); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->xVal, buf); 
	_itow_s(point.y, buf, 20, 10); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->yVal, buf); 
	_itow_s(abs(point.x-m_PointLast_StatusBar.x), buf, 20, 10); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->dxVal, buf); 
	_itow_s(abs(point.y-m_PointLast_StatusBar.y), buf, 20, 10); 
	pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->dyVal, buf); 
 
 
	if(m_bDoing==true) 
	{ 
		CDC * pDC = GetDC(); 
		CBitmap * pOldBmp = m_pMDC->SelectObject(m_pBmp); 
		CPen pen; 
		pen.CreatePen(m_iPenStyle,m_iWidth,m_PenColor); 
		CPen * pOldPen  = pDC->SelectObject(&pen); 
        //确定刷子类型**************** 
		CBrush brush; 
		switch(m_iBrushStyle) 
		{ 
		case 0 : 
			{ 
				brush.CreateStockObject(HOLLOW_BRUSH); 
				break; 
			} 
		case 1 : 
			{ 
				brush.CreateSolidBrush(m_BrushColor); 
				break; 
			} 
		case 2 : 
			{ 
				brush.CreateHatchBrush(m_iHatchStyle,m_BrushColor); 
				break; 
			} 
		case 3 : 
			{ 
				brush.CreatePatternBrush(&m_Bitmap); 
				//brush.UnrealizeObject();  //////////////////////// 
				break; 
			} 
 
		} 
		//******************************* 
		CBrush * pOldBrush = (CBrush *) pDC->SelectObject(&brush); 
 
 
		CRect rectOld(m_PointOld,m_PointNew); 
 
		if(m_DrawType==1 || m_DrawType==5) 
		{ 
			rectOld.SetRect(m_PointLast_PL,m_PointNew); 
		} 
		/*else 
		{ 
			CRect rectOld(m_PointOld,m_PointNew); 
		}*/ 
		rectOld.NormalizeRect(); 
		rectOld.InflateRect(m_iWidth,m_iWidth); 
 
		pDC->BitBlt(rectOld.left,rectOld.top,rectOld.Width(),rectOld.Height(), 
			m_pMDC,rectOld.left,rectOld.top,SRCCOPY); 
 
 
		CRect rectNew(m_PointOld,point); 
		 
		switch(m_DrawType) 
		{ 
		case 0: //画直线 
			{ 
				pDC->MoveTo(m_PointOld); 
				pDC->LineTo(point); 
				break; 
			} 
		case 1://画折线 
			{ 
				 
				pDC->MoveTo(m_PointLast_PL); 
				pDC->LineTo(point); 
				break; 
			} 
		case 2://画矩形 
			{ 
				//pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"按住Shift时,拖动鼠标画正方形"); 
				SetBrushOrgEx(pDC->m_hDC, rectNew.left, rectNew.top, NULL); 
			if(GetKeyState(VK_SHIFT)&(1<<15)) 
				{ 
 
					if(abs(rectNew.right-rectNew.left)>abs(rectNew.bottom-rectNew.top)) 
					{ 
						if(rectNew.right>rectNew.left) 
						{ 
						rectNew.SetRect(m_PointOld.x,m_PointOld.y,m_PointOld.x+abs(point.y-m_PointOld.y),point.y); 
						pDC->Rectangle(rectNew); 
						rectNew.SetRect(m_PointOld,point); 
						} 
						else 
						{ 
							rectNew.SetRect(m_PointOld.x,m_PointOld.y,m_PointOld.x-abs(point.y-m_PointOld.y),point.y); 
							pDC->Rectangle(rectNew); 
							rectNew.SetRect(m_PointOld,point); 
						} 
					} 
					else 
					{ 
						if(rectNew.bottom>rectNew.top) 
						{ 
							rectNew.SetRect(m_PointOld.x,m_PointOld.y,point.x,m_PointOld.y+abs(point.x-m_PointOld.x)); 
							pDC->Rectangle(rectNew); 
							rectNew.SetRect(m_PointOld,point); 
						} 
						else 
						{ 
							rectNew.SetRect(m_PointOld.x,m_PointOld.y,point.x,m_PointOld.y-abs(point.x-m_PointOld.x)); 
							pDC->Rectangle(rectNew); 
							rectNew.SetRect(m_PointOld,point); 
						} 
					} 
				} 
				else 
				{ 
				pDC->Rectangle(rectNew); 
				} 
				break; 
			} 
		case 3: //画圆角矩形 
			{ 
				SetBrushOrgEx(pDC->m_hDC, rectNew.left, rectNew.top, NULL); 
				int d = min(rectNew.Width(),rectNew.Height())/4; 
				pDC-> RoundRect(rectNew, CPoint(d, d)); 
				break; 
			} 
		case 4://画椭圆 
			{ 
				SetBrushOrgEx(pDC->m_hDC, rectNew.left, rectNew.top, NULL); 
				//pFrmWnd->m_wndStatusBar.SetPaneText(pFrmWnd->prompt,L"按住Shift时,拖动鼠标画圆"); 
				if(GetKeyState(VK_SHIFT)&(1<<15)) 
				{ 
					if(abs(rectNew.right-rectNew.left)>abs(rectNew.bottom-rectNew.top)) 
					{ 
						if(rectNew.right>rectNew.left) 
						{ 
						rectNew.SetRect(m_PointOld.x,m_PointOld.y,m_PointOld.x+abs(point.y-m_PointOld.y),point.y); 
						pDC->Ellipse(rectNew); 
						rectNew.SetRect(m_PointOld,point); 
						} 
						else 
						{ 
							rectNew.SetRect(m_PointOld.x,m_PointOld.y,m_PointOld.x-abs(point.y-m_PointOld.y),point.y); 
							pDC->Ellipse(rectNew); 
							rectNew.SetRect(m_PointOld,point); 
						} 
					} 
					else 
					{ 
						if(rectNew.bottom>rectNew.top) 
						{ 
							rectNew.SetRect(m_PointOld.x,m_PointOld.y,point.x,m_PointOld.y+abs(point.x-m_PointOld.x)); 
							pDC->Ellipse(rectNew); 
							rectNew.SetRect(m_PointOld,point); 
						} 
						else 
						{ 
							rectNew.SetRect(m_PointOld.x,m_PointOld.y,point.x,m_PointOld.y-abs(point.x-m_PointOld.x)); 
							pDC->Ellipse(rectNew); 
							rectNew.SetRect(m_PointOld,point); 
						} 
					} 
				} 
				else 
				{ 
					rectNew.SetRect(m_PointOld,point); 
				    pDC->Ellipse(rectNew); 
				} 
				break; 
			} 
		case 5: //画多边形 
			{ 
				pDC->MoveTo(m_PointLast_PL); 
				pDC->LineTo(point); 
				break; 
			} 
		case 6: //文本输出 
			{ 
				//pDC->TextOutW(point.x,point.y,m_strText); 
				break; 
			} 
		} 
 
		m_pMDC->SelectObject(pOldBmp); 
		pDC->SelectObject(pOldPen); 
		pDC->SelectObject(pOldBrush); 
		ReleaseDC(pDC); 
		m_PointNew = point; 
	} 
 
	CView::OnMouseMove(nFlags, point); 
} 
 
void CGandyDrawView::OnLButtonUp(UINT nFlags, CPoint point) 
{ 
	// TODO: 在此添加ONLButtonUP()函数 
	if(m_bDoing==true) 
	{ 
		m_bDoing = false; 
 
		CBitmap * pOldBmp = m_pMDC->SelectObject(m_pBmp); 
		CPen pen; 
		pen.CreatePen(m_iPenStyle,m_iWidth,m_PenColor); 
		CPen * pOldPen  = m_pMDC->SelectObject(&pen); 
 
		//确定刷子类型**************** 
		CBrush brush; 
		switch(m_iBrushStyle) 
		{ 
		case 0 : 
			{ 
				brush.CreateStockObject(HOLLOW_BRUSH); 
				break; 
			} 
		case 1 : 
			{ 
				brush.CreateSolidBrush(m_BrushColor); 
				break; 
			} 
		case 2 : 
			{ 
				brush.CreateHatchBrush(m_iHatchStyle,m_BrushColor); 
				break; 
			} 
		case 3 : 
			{ 
				 
				brush.CreatePatternBrush(&m_Bitmap); 
				//brush.UnrealizeObject(); 
				break; 
				 
			} 
 
		} 
		//******************************* 
		CBrush * pOldBrush = (CBrush *) m_pMDC->SelectObject(&brush); 
		//CBrush * pOldBrush = (CBrush *) m_pMDC->SelectStockObject(NULL_BRUSH); 
		 
		CRect rect(m_PointNew,m_PointOld); 
 
		CRect rectNew(m_PointOld,point); 
 
		//CRect rect33(55,55,200,200); 
 
		/*if(m_DrawType == 1) 
		{ 
			rect.SetRect(m_PointNew,m_PointLast_PL); 
			rectNew.SetRect(m_PointLast_PL,point); 
 
		}*/ 
 
		 
		switch(m_DrawType) 
		{ 
		case 0: 
			{ 
				m_pMDC->MoveTo(m_PointOld); 
				m_pMDC->LineTo(point); 
				break; 
			} 
		case 1: 
			{ 
				m_bClick = true; 
				//CDC * pDC = GetDC(); 
				m_bDoing = true; 
				m_pMDC->SetPixel(point,m_PenColor); 
				arrayP[m_iPCount++] = point; 
				m_PointLast_PL = point; 
 
				rect.SetRect(m_PointNew,m_PointLast_PL); 
				rectNew.SetRect(m_PointLast_PL,point); 
 
				if(m_iPCount >= 2) //画折线 有两点以上时 
				{ 
					m_pMDC->Polyline(arrayP,m_iPCount); 
				} 
			} 
		case 2: 
			{ 
 
				SetBrushOrgEx(m_pMDC->m_hDC, rectNew.left, rectNew.top, NULL); 
				if(GetKeyState(VK_SHIFT)&(1<<15)) 
				{ 
					if(abs(rectNew.right-rectNew.left)>abs(rectNew.bottom-rectNew.top)) 
					{ 
 
						if(rectNew.right>rectNew.left) 
							{ 
							rectNew.SetRect(m_PointOld.x,m_PointOld.y,m_PointOld.x+abs(point.y-m_PointOld.y),point.y); 
							m_pMDC->Rectangle(rectNew); 
							rectNew.SetRect(m_PointOld,point); 
							} 
							else 
							{ 
								rectNew.SetRect(m_PointOld.x,m_PointOld.y,m_PointOld.x-abs(point.y-m_PointOld.y),point.y); 
								m_pMDC->Rectangle(rectNew); 
								rectNew.SetRect(m_PointOld,point); 
							} 
					} 
				 
					else 
					{ 
							if(rectNew.bottom>rectNew.top) 
							{ 
								rectNew.SetRect(m_PointOld.x,m_PointOld.y,point.x,m_PointOld.y+abs(point.x-m_PointOld.x)); 
								m_pMDC->Rectangle(rectNew); 
								rectNew.SetRect(m_PointOld,point); 
							} 
							else 
							{ 
								rectNew.SetRect(m_PointOld.x,m_PointOld.y,point.x,m_PointOld.y-abs(point.x-m_PointOld.x)); 
								m_pMDC->Rectangle(rectNew); 
								rectNew.SetRect(m_PointOld,point); 
							} 
					} 
 
				 
				} 
				 
				else 
				{ 
					m_pMDC->Rectangle(rectNew); 
				} 
				break; 
			} 
		case 3: 
			{ 
				SetBrushOrgEx(m_pMDC->m_hDC, rectNew.left, rectNew.top, NULL); 
				int d = min(rectNew.Width(), rectNew.Height())/4; 
				m_pMDC-> RoundRect(rectNew, CPoint(d, d)); 
				break; 
			} 
		case 4: 
			{ 
				SetBrushOrgEx(m_pMDC->m_hDC, rectNew.left, rectNew.top, NULL); 
				if(GetKeyState(VK_SHIFT)&(1<<15)) 
				{ 
					if(abs(rectNew.right-rectNew.left)>abs(rectNew.bottom-rectNew.top)) 
					{ 
 
						if(rectNew.right>rectNew.left) 
							{ 
							rectNew.SetRect(m_PointOld.x,m_PointOld.y,m_PointOld.x+abs(point.y-m_PointOld.y),point.y); 
							m_pMDC->Ellipse(rectNew); 
							rectNew.SetRect(m_PointOld,point); 
							} 
							else 
							{ 
								rectNew.SetRect(m_PointOld.x,m_PointOld.y,m_PointOld.x-abs(point.y-m_PointOld.y),point.y); 
								m_pMDC->Ellipse(rectNew); 
								rectNew.SetRect(m_PointOld,point); 
							} 
					} 
				 
					else 
					{ 
							if(rectNew.bottom>rectNew.top) 
							{ 
								rectNew.SetRect(m_PointOld.x,m_PointOld.y,point.x,m_PointOld.y+abs(point.x-m_PointOld.x)); 
								m_pMDC->Ellipse(rectNew); 
								rectNew.SetRect(m_PointOld,point); 
							} 
							else 
							{ 
								rectNew.SetRect(m_PointOld.x,m_PointOld.y,point.x,m_PointOld.y-abs(point.x-m_PointOld.x)); 
								m_pMDC->Ellipse(rectNew); 
								rectNew.SetRect(m_PointOld,point); 
							} 
					} 
				} 
				else 
				{ 
					rectNew.SetRect(m_PointOld,point); 
					m_pMDC->Ellipse(rectNew); 
				} 
				break; 
			} 
		case 5: 
			{ 
				m_bClick = true; 
				if(m_iPCount==0) 
				{ 
					m_PointFirst_PL = point; 
				} 
				m_bDoing = true; 
				m_pMDC->SetPixel(point,m_PenColor); 
				arrayP[m_iPCount++] = point; 
				m_PointLast_PL = point; 
 
				rect.SetRect(m_PointNew,m_PointLast_PL); 
				rectNew.SetRect(m_PointLast_PL,point); 
 
				if(m_iPCount >= 2) //画折线 有两点以上时 
				{ 
					m_pMDC->Polyline(arrayP,m_iPCount); 
				} 
				break; 
 
			} 
		case 6: 
			{ 
				//m_pMDC->TextOutW(point.x,point.y,m_strText); 
				//break; 
 
				CFont *pOldFont = (CFont *) m_pMDC->SelectObject(&font); 
				CBitmap *pOldBmp = m_pMDC->SelectObject(m_pBmp); 
				SetFont(m_pMDC, fontName, fontSize, textColor, 0, italic,  
bold, underline, strikeOut); 
				m_pMDC->TextOutW(point.x, point.y, m_strText); 
				Invalidate(false); 
				m_pMDC->SelectObject(pOldFont); 
				m_pMDC->SelectObject(pOldBmp); 
				ReleaseDC(m_pMDC); 
			} 
		} 
		 
		Invalidate(false); 
		m_pMDC->SelectObject(pOldBmp); 
		m_pMDC->SelectObject(pOldPen); 
		m_pMDC->SelectObject(pOldBrush); 
	} 
 
	if((m_DrawType!=1)&&(m_DrawType!=5)) 
	{ 
		ReleaseCapture(); 
	} 
 
 
//	CView::OnLButtonUp(nFlags, point); 
} 
 
void CGandyDrawView::OnRButtonUp(UINT nFlags, CPoint point) 
{ 
	// TODO: 在此添加消息处理程序代码和/或调用默认值 
	if(m_bClick == true) 
	{ 
		CBitmap * pOldBmp = m_pMDC->SelectObject(m_pBmp); 
		CPen pen; 
		pen.CreatePen(m_iPenStyle,m_iWidth,m_PenColor); 
		CPen * pOldPen  = m_pMDC->SelectObject(&pen); 
		//CBrush * pOldBrush = (CBrush *) m_pMDC->SelectStockObject(NULL_BRUSH); 
 
		//确定刷子类型**************** 
		CBrush brush; 
		switch(m_iBrushStyle) 
		{ 
		case 0 : 
			{ 
				brush.CreateStockObject(HOLLOW_BRUSH); 
				break; 
			} 
		case 1 : 
			{ 
				brush.CreateSolidBrush(m_BrushColor); 
				break; 
			} 
		case 2 : 
			{ 
				brush.CreateHatchBrush(m_iHatchStyle,m_BrushColor); 
				break; 
			} 
		case 3 : 
			{ 
				brush.UnrealizeObject(); 
				brush.CreatePatternBrush(&m_Bitmap); 
				break; 
			} 
 
		} 
		//******************************* 
		CBrush * pOldBrush = (CBrush *) m_pMDC->SelectObject(&brush); 
 
 
		CRect rect(m_PointNew,m_PointOld); 
 
		CRect rectNew(m_PointOld,point); 
 
	//CDC * pDC=GetDC(); 
	if(m_DrawType == 1) 
	{ 
		m_pMDC->SetPixel(point,m_PenColor); 
		arrayP[m_iPCount++] = point; 
		 
		if(m_iPCount >= 2) //画折线 有两点以上时 
				{ 
					m_pMDC->Polyline(arrayP,m_iPCount); 
				} 
 
		m_bDoing = false; 
	    ReleaseCapture(); 
		m_iPCount = 0; 
	} 
	if(m_DrawType == 5) 
	{ 
		m_pMDC->MoveTo(m_PointLast_PL); 
		m_pMDC->LineTo(point); 
		m_pMDC->MoveTo(point); 
		m_pMDC->LineTo(m_PointFirst_PL); 
		m_bDoing = false; 
	    ReleaseCapture(); 
		m_iPCount = 0; 
	} 
	//ReleaseDC(pDC); 
	Invalidate(false); 
	m_pMDC->SelectObject(pOldBmp); 
	m_pMDC->SelectObject(pOldPen); 
	m_pMDC->SelectObject(pOldBrush); 
	} 
 
	m_bClick = false; 
 
	CView::OnRButtonUp(nFlags, point); 
} 
 
//字体选择对话框 
void CGandyDrawView::OnSetfont() 
{ 
	// TODO: 在此添加命令处理程序代码 
	CDC *pDC = GetDC(); 
	CFontDialog fontDlg(&logFont); 
	fontDlg.m_cf.rgbColors = textColor; 
	//fontDlg.m_cf.iPointSize = 105; 
	//fontDlg.m_cf.lpLogFont->lfFaceName = L"宋体"; 
 
	if (fontDlg.DoModal() == IDOK) { 
		//fontName = fontDlg.GetFaceName(); // Error! As wchar_t fontName[LF_FACESIZE]; 
		//wcscpy_s(fontName, LF_FACESIZE, fontDlg.GetFaceName()); 
		// wcscpy_s(fontName, LF_FACESIZE, fontDlg.GetFaceName().AllocSysString()); 
		fontName = fontDlg.GetFaceName(); 
		fontSize = fontDlg.GetSize(); 
		textColor = fontDlg.GetColor(); 
		italic = fontDlg.IsItalic(); 
		bold = fontDlg.IsBold(); 
		strikeOut = fontDlg.IsStrikeOut(); 
		underline = fontDlg.IsUnderline(); 
		if (!SetFont(pDC, fontName, fontSize, textColor, 0, italic, bold, underline,  
				strikeOut)) { 
			MessageBox(L"Create font wrong!", L"Error"); 
			return; 
		} 
		font.GetLogFont(&logFont); 
	} 
	ReleaseDC(pDC); 
 
 
} 
 
void CGandyDrawView::OnTestrotation() 
{ 
	// TODO: 在此添加命令处理程序代码 
	//CDC *pDC = GetDC(); 
	CFont *pOldFont = (CFont *) m_pMDC->SelectObject(&font); 
	CBitmap *pOldBmp = m_pMDC->SelectObject(m_pBmp); 
	RECT rect; 
	GetClientRect(&rect); 
	wchar_t buf[100]; 
	CString sFontNum; 
	 
	m_pMDC->FillSolidRect(&rect, RGB(255, 255, 255)); 
	for (int angle = 0; angle <= 360; angle += 10) { 
		SetFont(m_pMDC, fontName, fontSize, textColor, angle * 10, italic,  
bold, underline, strikeOut); 
		sFontNum = GetFontNumber(fontSize); 
		swprintf_s(buf,100, L"字体:名称=%s,字号=%s,大小=%g磅", fontName,  
					sFontNum, fontSize / 10.0); 
		m_pMDC->TextOutW(rect.right / 2, rect.bottom / 2, buf); 
	} 
	Invalidate(false); 
	m_pMDC->SelectObject(pOldFont); 
	m_pMDC->SelectObject(pOldBmp); 
 
	ReleaseDC(m_pMDC); 
 
} 
 
void CGandyDrawView::OnSetfontcolor() 
{ 
	// TODO  字体颜色 前景 
	CColorDialog dlg; 
	dlg.m_cc.Flags |=CC_PREVENTFULLOPEN | CC_RGBINIT; 
	dlg.m_cc.rgbResult = textColor; 
	if(dlg.DoModal()==IDOK) 
	{ 
		textColor= dlg.GetColor(); 
	} 
} 
 
// 将字体大小fontSize转换为中文字号sFontNum的自定义函数 
CString CGandyDrawView::GetFontNumber(int size) 
{ 
		switch(size) { 
	case 420: return L"初号"; 
	case 360: return L"小初"; 
	case 260: return L"一号"; 
	case 240: return L"小一"; 
	case 220: return L"二号"; 
	case 180: return L"小二"; 
	case 160: return L"三号"; 
	case 150: return L"小三"; 
	case 140: return L"四号"; 
	case 120: return L"小四"; 
	case 105: return L"五号"; 
	case  90: return L"小五"; 
	case  75: return L"六号"; 
	case  65: return L"小六"; 
	case  55: return L"七号"; 
	case  50: return L"八号"; 
	} 
	return L"未知"; 
 
} 
 
BOOL CGandyDrawView::SetFont(CDC * pDC, LPCTSTR name, int size, COLORREF col, int angle, bool italic, bool bold, bool underline, bool strikeOut) 
{ 
	int height = -MulDiv(size, pDC->GetDeviceCaps(LOGPIXELSY), 720); 
	CFont font; 
	BOOL bOk = font.CreateFont(height, 0, angle, angle, bold?700:400, italic,  
					underline, strikeOut, DEFAULT_CHARSET,  
					OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, 
				    CLIP_DEFAULT_PRECIS, DEFAULT_PITCH |  
					FF_DONTCARE, name); 
	if (bOk) { 
			font.GetLogFont(&logFont); 
			pDC->SelectObject(font); 
			pDC->SetTextColor(col); 
			pDC->SetBkColor(textBkColor); 
	} 
		return bOk; 
 
} 
 
void CGandyDrawView::OnClearall() 
{ 
	// TODO: 在此添加命令处理程序代码 
	CBitmap * pOldBmp = m_pMDC->SelectObject(m_pBmp); 
	RECT rect; 
	GetClientRect(&rect); 
	m_pMDC->FillSolidRect(&rect,RGB(255,255,255)); 
	Invalidate(false); 
	m_pMDC->SelectObject(pOldBmp); 
 
	ReleaseDC(m_pMDC); 
	 
} 
 
void CGandyDrawView::OnInputstr() 
{ 
	// TODO: 在此添加命令处理程序代码 
	CInputStr StrInputDlg; 
	if(StrInputDlg.DoModal()==IDOK) 
	{ 
		m_strText = StrInputDlg.m_strInput; 
	} 
} 
 
void CGandyDrawView::OnOutputstr() 
{ 
	// TODO: 在此添加命令处理程序代码 
	m_DrawType = 6; 
} 
 
void CGandyDrawView::OnSetfontbkcolor() 
{ 
	CColorDialog dlg; 
	dlg.m_cc.Flags |=CC_PREVENTFULLOPEN | CC_RGBINIT; 
	dlg.m_cc.rgbResult = textBkColor; 
	if(dlg.DoModal()==IDOK) 
	{ 
		textBkColor= dlg.GetColor(); 
	} 
} 
 
void CGandyDrawView::OnOutputfontsize() 
{ 
	int fs[16] = {420, 360, 260, 240, 220, 180, 160, 150, 140, 120, 105, 90, 75, 65, 55, 50}; 
	//CDC *pDC = GetDC(); 
	CBitmap *pOldBmp = m_pMDC->SelectObject(m_pBmp); 
	CFont *pOldFont = (CFont *)m_pMDC->SelectObject(&font); 
 
	wchar_t buf[40]; 
	CString no; 
	int y = 0, size; 
	for (int i = 0; i < 16; i++) { 
		size = fs[i]; 
		SetFont(m_pMDC, fontName, size, textColor, 0, italic, bold, underline, strikeOut); 
		no = GetFontNumber(size); 
		swprintf_s(buf, 40, L"这是%s%s字(%g磅)", fontName, no, size / 10.0); 
		m_pMDC->TextOut(0, y, buf); 
		y += fs[i] / 6; 
	} 
	Invalidate(false); 
	m_pMDC->SelectObject(pOldBmp); 
	m_pMDC->SelectObject(pOldFont); 
	ReleaseDC(m_pMDC); 
 
} 
 
void CGandyDrawView::OnDrawoembmp() 
{ 
	CBitmap * pOldBmp1 = m_pMDC->SelectObject(m_pBmp); 
	//CDC dc;// , *pDC = GetDC(); 
	CBitmap bmp, *pOldBmp; 
	//BITMAP bs; 
	int i, j, id = 32734; 
	wchar_t buf[8]; 
 
	dc.CreateCompatibleDC(m_pMDC); 
	for (i = 0; i < 4; i++)  
		for (j = 0; j < 10; j++) { 
			if(bmp.LoadOEMBitmap(id)) { 
				bmp.GetBitmap(&bs); 
				pOldBmp = (CBitmap*)dc.SelectObject(&bmp); 
				m_pMDC->BitBlt(j * 50, i * 80, bs.bmWidth, bs.bmHeight, &dc, 0, 0, SRCCOPY); 
				dc.SelectObject(pOldBmp); 
				bmp.DeleteObject(); 
			} 
			_itow_s(id, buf, 8, 10); 
			m_pMDC->TextOut(j * 50, 40 + i * 80, buf); 
			id++; 
			if(id>32767) break; 
		} 
 
		Invalidate(false); 
		m_pMDC->SelectObject(pOldBmp1); 
		ReleaseDC(m_pMDC); 
 
} 
 
void CGandyDrawView::OnOpenbmp() 
{ 
	 
	wchar_t filters[] = L"位图文件(*.bmp)|*.bmp|所有文件(*.*)|*.*||"; 
	CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, filters); 
	if (fileDlg.DoModal() == IDOK) { 
		HBITMAP hBmp = (HBITMAP)LoadImage(NULL, fileDlg.GetPathName(),  
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE |  
			LR_DEFAULTCOLOR | LR_DEFAULTSIZE); 
		if (hBmp != NULL) { 
			BITMAP bm; 
			GetObject(hBmp, sizeof(bm), &bm); 
			long cb = bm.bmBitsPixel * bm.bmHeight * bm.bmWidthBytes; 
			bm.bmBits = new char[cb]; 
			GetBitmapBits(hBmp, cb, bm.bmBits); 
			m_FileBitmap.CreateBitmapIndirect(&bm); 
			m_bBitmapLoaded = true; 
		} 
	} 
 
	CBitmap * pOldBmp1 = m_pMDC->SelectObject(m_pBmp); 
	//CDC dc;// , *pDC = GetDC(); 
	CBitmap *pOldBmp; 
	//BITMAP bs; 
	dc.CreateCompatibleDC(m_pMDC); 
	m_FileBitmap.GetBitmap(&bs); 
	pOldBmp=dc.SelectObject(&m_FileBitmap); 
	m_pMDC->BitBlt(0,0,bs.bmWidth,bs.bmHeight,&dc,0,0,SRCCOPY); 
	dc.SelectObject(pOldBmp); 
	Invalidate(false); 
	m_pMDC->SelectObject(pOldBmp1); 
	ReleaseDC(m_pMDC); 
 
 
	m_bIsOpeningBmp = true; 
	m_DrawType = 20; 
 
 
} 
 
void CGandyDrawView::OnBlackonwhite() 
{ 
		m_iStretchBltMode = 1; 
		Invalidate(false); 
		OnDispstrbmp(); 
} 
 
void CGandyDrawView::OnWhiteonblack() 
{ 
	m_iStretchBltMode = 2; 
	Invalidate(false); 
	OnDispstrbmp(); 
	 
} 
 
void CGandyDrawView::OnColoroncolor() 
{ 
	m_iStretchBltMode = 3; 
	Invalidate(false); 
	OnDispstrbmp(); 
} 
 
void CGandyDrawView::OnHalftone() 
{ 
	m_iStretchBltMode = 4; 
	Invalidate(false); 
	OnDispstrbmp(); 
} 
 
void CGandyDrawView::OnDispstrbmp()  //显示缩放位图 
{ 
	m_DrawType = 20; 
	m_bIsStretchBlt = true; 
	m_bIsKeepingRate = false; 
 
	OnClearall(); 
	CRect crect; 
	GetClientRect(&crect); 
	m_pMDC->FillSolidRect(&crect,RGB(255,255,255)); 
 
	CBitmap * pOldBmp1 = m_pMDC->SelectObject(m_pBmp); 
	CBitmap *pOldBmp; 
 
	 
	m_pMDC->SetStretchBltMode(m_iStretchBltMode); 
	 
	dc.CreateCompatibleDC(m_pMDC); 
	dc.SetStretchBltMode(m_iStretchBltMode); 
	m_FileBitmap.GetBitmap(&bs); 
	pOldBmp=dc.SelectObject(&m_FileBitmap); 
 
	m_pMDC->StretchBlt(0, 0, crect.right,crect.bottom, &dc, 0, 0,  
						bs.bmWidth, bs.bmHeight, SRCCOPY); 
 
	Invalidate(false); 
	dc.SelectObject(pOldBmp); 
	m_pMDC->SelectObject(pOldBmp1); 
 
	ReleaseDC(m_pMDC);	 
} 
 
void CGandyDrawView::OnDispvirbmp()  //显示原始位图 
{ 
	 
	m_bIsStretchBlt = false; 
	m_DrawType = 20; 
 
	CBitmap * pOldBmp1 = m_pMDC->SelectObject(m_pBmp); 
	CBitmap *pOldBmp; 
 
	 
	OnClearall(); 
	CRect crect; 
	GetClientRect(&crect); 
	m_pMDC->FillSolidRect(&crect,RGB(255,255,255)); 
 
	dc.CreateCompatibleDC(m_pMDC); 
	m_FileBitmap.GetBitmap(&bs); 
	pOldBmp=dc.SelectObject(&m_FileBitmap); 
 
	m_pMDC->BitBlt(0,0,bs.bmWidth,bs.bmHeight,&dc,0,0,SRCCOPY); 
 
	dc.SelectObject(pOldBmp); 
	Invalidate(false); 
	m_pMDC->SelectObject(pOldBmp1); 
	ReleaseDC(m_pMDC); 
} 
 
void CGandyDrawView::OnStrfillclient() 
{ 
	 
	OnDispstrbmp(); 
	m_bIsKeepingRate = false; 
} 
 
 
void CGandyDrawView::OnStrkeeprate() //保持宽高比缩放 
{ 
 
	m_DrawType = 20; 
	m_bIsStretchBlt = true; 
	m_bIsKeepingRate = true; 
 
	CBitmap * pOldBmp1 = m_pMDC->SelectObject(m_pBmp); 
	CBitmap *pOldBmp; 
 
	OnClearall(); 
	CRect crect; 
	GetClientRect(&crect); 
	m_pMDC->FillSolidRect(&crect,RGB(255,255,255)); 
 
 
	m_pMDC->SetStretchBltMode(m_iStretchBltMode); 
	 
 
	dc.CreateCompatibleDC(m_pMDC); 
	dc.SetStretchBltMode(m_iStretchBltMode); //将dc设置缩放模式 
	m_FileBitmap.GetBitmap(&bs); 
	pOldBmp=dc.SelectObject(&m_FileBitmap); 
	 
	if((float)(crect.right/crect.bottom) >= (float)(bs.bmWidth/bs.bmHeight) ) 
	{ 
		m_pMDC->StretchBlt((crect.right-bs.bmWidth*crect.bottom/bs.bmHeight)/2,0 
			,bs.bmWidth*crect.bottom/bs.bmHeight,crect.bottom, &dc, 0,0,bs.bmWidth, bs.bmHeight, SRCCOPY); 
	} 
	if((float)(crect.bottom/crect.right) >= (float)(bs.bmHeight/bs.bmWidth)) 
	{ 
		OnClearall(); 
		m_pMDC->StretchBlt(0,(crect.bottom-bs.bmHeight*crect.right/bs.bmWidth)/2 
			,crect.right,bs.bmHeight*crect.right/bs.bmWidth, &dc, 0,0,bs.bmWidth, bs.bmHeight, SRCCOPY); 
	} 
 
	//m_pMDC->StretchBlt(0, 0, crect.right,crect.bottom, &dc, 0, 0,  
	//bs.bmWidth, bs.bmHeight, SRCCOPY); 
	Invalidate(false); 
 
	dc.SelectObject(pOldBmp); 
	m_pMDC->SelectObject(pOldBmp1); 
	ReleaseDC(m_pMDC); 
	 
} 
 
void CGandyDrawView::OnUpdateStrkeeprate(CCmdUI *pCmdUI) 
{ 
	if(m_bIsStretchBlt == true) 
	{ 
		pCmdUI->Enable(true); 
	} 
	else 
	{ 
		pCmdUI->Enable(false); 
	} 
} 
 
void CGandyDrawView::OnUpdateDispvirbmp(CCmdUI *pCmdUI) 
{ 
	if(m_bIsOpeningBmp == true) 
	{ 
		pCmdUI->Enable(true); 
	} 
	else 
	{ 
		pCmdUI->Enable(false); 
	} 
	 
} 
 
void CGandyDrawView::OnUpdateDispstrbmp(CCmdUI *pCmdUI) 
{ 
	if(m_bIsOpeningBmp == true) 
	{ 
		pCmdUI->Enable(true); 
	} 
	else 
	{ 
		pCmdUI->Enable(false); 
	} 
} 
 
void CGandyDrawView::OnUpdateStrfillclient(CCmdUI *pCmdUI) 
{ 
	if(m_bIsStretchBlt == true) 
	{ 
		pCmdUI->Enable(true); 
	} 
	else 
	{ 
		pCmdUI->Enable(false); 
	} 
} 
 
 
void CGandyDrawView::OnUpdateBlackonwhite(CCmdUI *pCmdUI) 
{ 
	if(m_bIsStretchBlt == true) 
	{ 
		pCmdUI->Enable(true); 
	} 
	else 
	{ 
		pCmdUI->Enable(false); 
	} 
} 
 
void CGandyDrawView::OnUpdateWhiteonblack(CCmdUI *pCmdUI) 
{ 
	if(m_bIsStretchBlt == true) 
	{ 
		pCmdUI->Enable(true); 
	} 
	else 
	{ 
		pCmdUI->Enable(false); 
	} 
} 
 
void CGandyDrawView::OnUpdateColoroncolor(CCmdUI *pCmdUI) 
{ 
	if(m_bIsStretchBlt == true) 
	{ 
		pCmdUI->Enable(true); 
	} 
	else 
	{ 
		pCmdUI->Enable(false); 
	} 
} 
 
void CGandyDrawView::OnUpdateHalftone(CCmdUI *pCmdUI) 
{ 
	if(m_bIsStretchBlt == true) 
	{ 
		pCmdUI->Enable(true); 
	} 
	else 
	{ 
		pCmdUI->Enable(false); 
	} 
 
} 
 
void CGandyDrawView::OnSetwidth() 
{ 
	CSetWidthDlg setwidthdlg; 
	if(setwidthdlg.DoModal()==IDOK) 
	{ 
	UpdateData(false); 
	m_iWidth = setwidthdlg.GetWidth(); 
	} 
	 
} 
 
void CGandyDrawView::OnJavaduke() 
{ 
	CDukeDlg dlg; 
	dlg.DoModal(); 
} 
 
void CGandyDrawView::OnChangebmp() 
{ 
	CChangeBmp dlg; 
	if(dlg.DoModal()==IDOK) 
	{ 
		//m_Bitmap.CreateBitmapIndirect(dlg.m_FileBitmap); 
		HBITMAP hBmp = (HBITMAP)LoadImage(NULL, dlg.m_BmpPathName,  
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE |  
			LR_DEFAULTCOLOR | LR_DEFAULTSIZE); 
		if (hBmp != NULL) { 
			BITMAP bm; 
			GetObject(hBmp, sizeof(bm), &bm); 
			long cb = bm.bmBitsPixel * bm.bmHeight * bm.bmWidthBytes; 
			bm.bmBits = new char[cb]; 
			GetBitmapBits(hBmp, cb, bm.bmBits); 
			m_Bitmap.CreateBitmapIndirect(&bm); 
			m_BmpPathName = dlg.m_BmpPathName; 
			//m_bBitmapLoaded = true; 
		} 
		 
	} 
} 
 
void CGandyDrawView::OnDrawset() 
{ 
	CDrawSetDlg dlg; 
//	dlg.m_Bmp = m_Bitmap; 
	dlg.m_BmpPathName = m_BmpPathName; 
	dlg.m_BrushColor = m_BrushColor; 
	dlg.m_PenColor = m_PenColor; 
	dlg.m_ComboIndex = m_iPenStyle; 
	dlg.m_DrawRadio = m_DrawType; 
	dlg.m_iBruHatchStyle = m_iHatchStyle; 
	dlg.m_iBruStyle = m_iBrushStyle; 
	dlg.m_iPenWidth = m_iWidth; 
	if(dlg.DoModal()==IDOK) 
	{ 
//		m_Bitmap =dlg.m_Bmp; 
		m_BmpPathName = dlg.m_BmpPathName; 
		m_BrushColor = dlg.m_BrushColor; 
		m_PenColor = dlg.m_PenColor; 
	   m_DrawType = dlg.m_DrawRadio; 
	   m_iHatchStyle = dlg.m_iBruHatchStyle; 
		m_iBrushStyle = dlg.m_iBruStyle; 
		m_iWidth = dlg.m_iPenWidth; 
		m_iPenStyle = dlg.m_ComboIndex; 
	} 
 
} 
 
void CGandyDrawView::OnUpdateLine(CCmdUI *pCmdUI) 
{ 
	if(m_DrawType == 0) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else  
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateEllipse(CCmdUI *pCmdUI) 
{ 
	if(m_DrawType == 4) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else  
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateEllirect(CCmdUI *pCmdUI) 
{ 
	if(m_DrawType == 3) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else  
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdatePolygon(CCmdUI *pCmdUI) 
{ 
	if(m_DrawType == 5) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else  
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateRect(CCmdUI *pCmdUI) 
{ 
	if(m_DrawType == 2) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else  
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdatePolyline(CCmdUI *pCmdUI) 
{ 
	if(m_DrawType == 1) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else  
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateTextdraw(CCmdUI *pCmdUI) 
{ 
	if(m_DrawType == 6) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else  
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateDash(CCmdUI *pCmdUI) 
{ 
	if(m_iPenStyle == 1) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateDot(CCmdUI *pCmdUI) 
{ 
	if(m_iPenStyle == 2) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateDashdot(CCmdUI *pCmdUI) 
{ 
	if(m_iPenStyle == 3) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateDashdotdot(CCmdUI *pCmdUI) 
{ 
	if(m_iPenStyle == 4) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSolid(CCmdUI *pCmdUI) 
{ 
	if(m_iPenStyle == 0) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateBruHollow(CCmdUI *pCmdUI) 
{ 
	if(m_iBrushStyle == 0) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateBruSolid(CCmdUI *pCmdUI) 
{ 
	if(m_iBrushStyle == 1) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateFillwithpicture(CCmdUI *pCmdUI) 
{ 
	if(m_iBrushStyle == 3) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateStrBia(CCmdUI *pCmdUI) 
{ 
	if((m_iHatchStyle == 2)&&(m_iBrushStyle == 2)) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateStrBla(CCmdUI *pCmdUI) 
{ 
	if((m_iHatchStyle == 3)&&(m_iBrushStyle == 2)) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateStrCcro(CCmdUI *pCmdUI) 
{ 
	if((m_iHatchStyle == 5)&&(m_iBrushStyle == 2)) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateStrCro(CCmdUI *pCmdUI) 
{ 
	if((m_iHatchStyle == 4)&&(m_iBrushStyle == 2)) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateStrHor(CCmdUI *pCmdUI) 
{ 
	if((m_iHatchStyle == 0)&&(m_iBrushStyle == 2)) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateStrVer(CCmdUI *pCmdUI) 
{ 
	if((m_iHatchStyle == 1)&&(m_iBrushStyle == 2)) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSetwidth1(CCmdUI *pCmdUI) 
{ 
	if(m_iWidth == 1) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSetwidth10(CCmdUI *pCmdUI) 
{ 
	if(m_iWidth == 10) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSetwidth2(CCmdUI *pCmdUI) 
{ 
	if(m_iWidth == 2) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSetwidth20(CCmdUI *pCmdUI) 
{ 
	if(m_iWidth == 20) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSetwidth3(CCmdUI *pCmdUI) 
{ 
	if(m_iWidth == 3) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSetwidth4(CCmdUI *pCmdUI) 
{ 
	if(m_iWidth == 4) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSetwidth50(CCmdUI *pCmdUI) 
{ 
	if(m_iWidth == 50) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
} 
 
void CGandyDrawView::OnUpdateSetwidth8(CCmdUI *pCmdUI) 
{ 
	if(m_iWidth == 8) 
	{ 
		pCmdUI->SetCheck(1); 
	} 
	else 
	{ 
		pCmdUI->SetCheck(0); 
	} 
}