怎样使用SetROP2(R2_XORPEN)

confideman2000 2004-07-26 08:32:48
我需要在一个图像上实现局部抓图功能,鼠标按下后取一点为开始点,鼠标移动时
当前点为中止点,然后根据矩形框四点的坐标组成一个CPoint pts[5]de的数组
用PloyLine(pts,5)画一个多线,现在有一个问题怎样把上一次画的多线去掉,在
图象上只留最后鼠标移动时画的多线,听说需要用SetROP2(R2_XORPEN),怎样使用
...全文
735 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
laofang 2005-09-05
  • 打赏
  • 举报
回复
如果画的是矩形虚框,用CDC::DrawFocusRect 最方便,连SetROP2(R2_XOR)都不需要自己调用:

Since this is a Boolean XOR function, calling this function a second time with the same rectangle removes the rectangle from the display.
李马 2004-07-26
  • 打赏
  • 举报
回复
在鼠标移动的事件处理程序中用static的变量保存上次的矩形,在处理中首先在原来的地方画矩形,根据R2_XORPEN的特点,原来的矩形就会被擦除。然后在新的地方画矩形,并将新矩形保存到那个static变量中。
qqhuangshen 2004-07-26
  • 打赏
  • 举报
回复
我写过这样的程序,给你一段我以前写的实现擦除的代码,不过画出的是个坐标,通过鼠标的移动进行擦除,然后绘制新的。

void CEraseFlashView::OnInitialUpdate()
{


CView::OnInitialUpdate();
CClientDC dc(this);

View_wi=dc.GetDeviceCaps(HORZRES);

View_hi=dc.GetDeviceCaps(VERTRES);

MemDC.CreateCompatibleDC(&dc);

bitmap.CreateCompatibleBitmap(&MemDC,View_wi/4*3-View_wi/18,View_hi/16*13-View_hi/8);

MemDC.SelectObject(&bitmap);

SetTimer(0,1000,NULL);

DrawAxis();


}

void CEraseFlashView::DrawAxis()
{
MemDC.FillRect(CRect(0,0,View_wi/4*3,View_hi/16*13),&CBrush(RGB(255,255,255)));

MemDC.SetTextColor(RGB(255,0,255));

MemDC.TextOut(300,100,"在此绘出的历史趋势图");



MemDC.MoveTo(View_wi/16,View_hi/4*3);

MemDC.LineTo(View_wi/4*3,View_hi/4*3);

Invalidate();

}

void CEraseFlashView::OnMouseMove(UINT nFlags, CPoint point)
{
static CPoint Oldpoint;
CPen pen;
pen.CreatePen(PS_SOLID,2,RGB(25,255,255));
MemDC.SelectObject(&pen);
CClientDC dc(this);
int nDrawMode=dc.GetROP2();

MemDC.SetROP2(R2_NOT);

MemDC.MoveTo(View_wi/16,Oldpoint.y);

MemDC.LineTo(View_wi/4*3,Oldpoint.y);

MemDC.MoveTo(Oldpoint.x,View_hi/8);

MemDC.LineTo(Oldpoint.x,View_hi/4*3);

MemDC.SetROP2(nDrawMode);

MemDC.MoveTo(View_wi/16,point.y);

MemDC.LineTo(View_wi/4*3,point.y);

MemDC.MoveTo(point.x,View_hi/8);

MemDC.LineTo(point.x,View_hi/4*3);


Oldpoint.x=point.x;
Oldpoint.y=point.y;
Invalidate(FALSE);

CView::OnMouseMove(nFlags, point);
}

void CEraseFlashView::OnDraw(CDC* pDC)
{
CEraseFlashDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->BitBlt(0,0,View_wi/4*3,View_hi/16*13,&MemDC,0,0,SRCCOPY);
}
zhuzhufox 2004-07-26
  • 打赏
  • 举报
回复
画两遍,第一次是要显示的,第二次画要擦除的。
wrcluomo 2004-07-26
  • 打赏
  • 举报
回复
//画矩形
//擦去上次的画
pdc->Rectangle(CRect(m_Begin,m_OldEnd));
//重新绘画
pdc->Rectangle(CRect(m_Begin,m_End));
m_OldEnd=m_End;
就这样画,
// MyPaintView.cpp : implementation of the CMyPaintView class // #include "stdafx.h" #include "MyPaint.h" #include "Mainfrm.h" #include "MyPaintDoc.h" #include "MyPaintView.h" #include "MyImage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMyPaintView IMPLEMENT_DYNCREATE(CMyPaintView, CView) BEGIN_MESSAGE_MAP(CMyPaintView, CView) //{{AFX_MSG_MAP(CMyPaintView) ON_UPDATE_COMMAND_UI(ID_BUTTON_IRREG_SEL, OnUpdateButtonIrregSel) ON_UPDATE_COMMAND_UI(ID_BUTTON_RECT_SEL, OnUpdateButtonRectSel) ON_UPDATE_COMMAND_UI(ID_BUTTON_ERASER, OnUpdateButtonEraser) ON_UPDATE_COMMAND_UI(ID_BUTTON_FILL, OnUpdateButtonFill) ON_UPDATE_COMMAND_UI(ID_BUTTON_MAGNIFY, OnUpdateButtonMagnify) ON_UPDATE_COMMAND_UI(ID_BUTTON_PEN, OnUpdateButtonPen) ON_UPDATE_COMMAND_UI(ID_BUTTON_BRUSH, OnUpdateButtonBrush) ON_UPDATE_COMMAND_UI(ID_BUTTON_AIRBRUSH, OnUpdateButtonAirbrush) ON_UPDATE_COMMAND_UI(ID_BUTTON_SELCOLOR, OnUpdateButtonSelcolor) ON_UPDATE_COMMAND_UI(ID_BUTTON_TEXT, OnUpdateButtonText) ON_COMMAND(ID_BUTTON_IRREG_SEL, OnButtonIrregSel) ON_COMMAND(ID_BUTTON_RECT_SEL, OnButtonRectSel) ON_COMMAND(ID_BUTTON_ERASER, OnButtonEraser) ON_COMMAND(ID_BUTTON_MAGNIFY, OnButtonMagnify) ON_COMMAND(ID_BUTTON_FILL, OnButtonFill) ON_COMMAND(ID_BUTTON_BRUSH, OnButtonBrush) ON_COMMAND(ID_BUTTON_PEN, OnButtonPen) ON_COMMAND(ID_BUTTON_SELCOLOR, OnButtonSelcolor) ON_COMMAND(ID_BUTTON_TEXT, OnButtonText) ON_COMMAND(ID_BUTTON_AIRBRUSH, OnButtonAirbrush) ON_WM_CREATE() ON_WM_LBUTTONDOWN() ON_WM_MOUSEMOVE() ON_WM_LBUTTONUP() ON_COMMAND(ID_BUTTON_CURVE, OnButtonCurve) ON_UPDATE_COMMAND_UI(ID_BUTTON_CURVE, OnUpdateButtonCurve) ON_COMMAND(ID_BUTTON_LINE, OnButtonLine) ON_UPDATE_COMMAND_UI(ID_BUTTON_LINE, OnUpdateButtonLine) ON_WM_SETCURSOR() ON_UPDATE_COMMAND_UI(ID_BUTTON_RECT, OnUpdateButtonRect) ON_COMMAND(ID_BUTTON_RECT, OnButtonRect) ON_UPDATE_COMMAND_UI(ID_BUTTON_POLYGON, OnUpdateButtonPolygon) ON_COMMAND(ID_BUTTON_POLYGON, OnButtonPolygon) ON_UPDATE_COMMAND_UI(ID_BUTTON_ROUND_RECT, OnUpdateButtonRoundRect) ON_COMMAND(ID_BUTTON_ROUND_RECT, OnButtonRoundRect) ON_UPDATE_COMMAND_UI(ID_BUTTON_ELLIPSE, OnUpdateButtonEllipse) ON_COMMAND(ID_BUTTON_ELLIPSE, OnButtonEllipse) ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) ON_COMMAND(ID_EDIT_REDO, OnEditRedo) //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMyPaintView construction/destruction CMyPaintView::CMyPaintView() { // TODO: add construction code here m_emPaintType = IRREG_SEL; m_pdcMem = new CDC; m_pbmBackground = new CBitmap; m_bDrawing = FALSE; m_bFirstDraw = FALSE; m_nEraserSize = 10; m_pbyBitmapBuf = NULL; } CMyPaintView::~CMyPaintView() { delete m_pdcMem; delete m_pbmBackground; if ( m_pbyBitmapBuf ) delete[] m_pbyBitmapBuf; } BOOL CMyPaintView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CMyPaintView drawing void CMyPaintView::OnDraw(CDC* pDC) { CMyPaintDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here pDC->BitBlt(0,0,m_nScreenW,m_nScreenH, m_pdcMem, 0, 0, SRCCOPY); } ///////////////////////////////////////////////////////////////////////////// // CMyPaintView printing BOOL CMyPaintView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CMyPaintView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CMyPaintView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CMyPaintView diagnostics #ifdef _DEBUG void CMyPaintView::AssertValid() const { CView::AssertValid(); } void CMyPaintView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CMyPaintDoc* CMyPaintView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyPaintDoc))); return (CMyPaintDoc*)m_pDocument; } #endif //_DEBUG COLORREF CMyPaintView::GetCanvasColor() const { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); if ( pFrame ) return pFrame->m_clrCanvas; else return RGB(255,255,255); } COLORREF CMyPaintView::GetPaintColor() const { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); if ( pFrame ) return pFrame->m_clrPaint; else return RGB(0,0,0); } int CMyPaintView::GetPenWidth() const { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); if ( pFrame ) return pFrame->GetPenWidth(); else return 1; } void CMyPaintView::SetSelBox(int type) { ((CMainFrame*)AfxGetMainWnd())->m_wndToolBar.SetSelType((SELTYPE)type); } ///////////////////////////////////////////////////////////////////////////// // CMyPaintView message handlers void CMyPaintView::OnUpdateButtonIrregSel(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==IRREG_SEL); } void CMyPaintView::OnUpdateButtonRectSel(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==RECT_SEL); } void CMyPaintView::OnUpdateButtonEraser(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==ERASER); } void CMyPaintView::OnUpdateButtonFill(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==FILL); } void CMyPaintView::OnUpdateButtonMagnify(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==MAGNIFY); } void CMyPaintView::OnUpdateButtonPen(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==PEN); } void CMyPaintView::OnUpdateButtonBrush(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==BRUSH); } void CMyPaintView::OnUpdateButtonAirbrush(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==AIRBRUSH); } void CMyPaintView::OnUpdateButtonSelcolor(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==SEL_COLOR); } void CMyPaintView::OnUpdateButtonText(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==TEXT); } void CMyPaintView::OnUpdateButtonCurve(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==CURVE); } void CMyPaintView::OnUpdateButtonLine(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==LINE); } void CMyPaintView::OnButtonIrregSel() { // TODO: Add your command handler code here m_emPaintType = IRREG_SEL; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonRectSel() { // TODO: Add your command handler code here m_emPaintType = RECT_SEL; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonEraser() { // TODO: Add your command handler code here m_emPaintType = ERASER; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonMagnify() { // TODO: Add your command handler code here m_emPaintType = MAGNIFY; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonFill() { // TODO: Add your command handler code here m_emPaintType = FILL; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonBrush() { // TODO: Add your command handler code here m_emPaintType = BRUSH; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonPen() { // TODO: Add your command handler code here m_emPaintType = PEN; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonSelcolor() { // TODO: Add your command handler code here m_emPaintType = SEL_COLOR; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonText() { // TODO: Add your command handler code here m_emPaintType = TEXT; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonAirbrush() { // TODO: Add your command handler code here m_emPaintType = AIRBRUSH; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonCurve() { // TODO: Add your command handler code here m_emPaintType = CURVE; SetSelBox(SEL_PENWIDTH); } void CMyPaintView::OnButtonLine() { // TODO: Add your command handler code here m_emPaintType = LINE; SetSelBox(SEL_PENWIDTH); } int CMyPaintView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here m_nScreenW = ::GetSystemMetrics(SM_CXSCREEN); m_nScreenH = ::GetSystemMetrics(SM_CYSCREEN); CDC *pDC = GetDC(); m_pdcMem->CreateCompatibleDC(pDC); m_pbmBackground->CreateCompatibleBitmap(pDC,m_nScreenW,m_nScreenH); m_bmBackup.CreateCompatibleBitmap(pDC,m_nScreenW,m_nScreenH); m_pdcMem->SelectObject(m_pbmBackground); CBrush brush; brush.CreateSolidBrush(GetCanvasColor()); CRect rect(0,0,m_nScreenW,m_nScreenH); m_pdcMem->FillRect(rect,&brush); ReleaseDC(pDC); BITMAP bm; m_pbmBackground->GetBitmap(&bm); m_dwSizeBitmap = bm.bmWidthBytes * bm.bmHeight; m_pbyBitmapBuf = new BYTE[m_dwSizeBitmap]; return 0; } void CMyPaintView::UpdateImage() { m_pdcMem->SelectObject(m_pbmBackground); Invalidate(); } void CMyPaintView::XorLine(CPoint pt1,CPoint pt2) { CDC *pDC = GetDC(); CPen pen; pen.CreateStockObject(WHITE_PEN); CPen* pOldPen = (CPen*)pDC->SelectObject(&pen); pDC->SetROP2(R2_XORPEN); pDC->MoveTo(pt1); pDC->LineTo(pt2); pDC->SelectObject(pOldPen); ReleaseDC(pDC); } void CMyPaintView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default Backup(); CDC* pDC = GetDC(); switch(m_emPaintType) { case LINE: case RECT: m_ptStart = point; m_bFirstDraw = TRUE; break; case PEN: case BRUSH: m_ptStart = point; break; case ERASER: m_ptStart = point; EraserBox(pDC, point); EraserBox(m_pdcMem, point); break; case FILL: Fill(pDC,point); Fill(m_pdcMem,point); break; default: break; } m_bDrawing = TRUE; ReleaseDC(pDC); CView::OnLButtonDown(nFlags, point); } void CMyPaintView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CString strCoord; strCoord.Format(" %d, %d", point.x, point.y); pFrame->m_wndStatusBar.SetPaneText(1, strCoord, TRUE); if ( m_bDrawing ) { CDC* pDC = GetDC(); switch(m_emPaintType) { case LINE: if ( point != m_ptEnd ) { if ( !m_bFirstDraw ) XorLine(m_ptStart,m_ptEnd); else m_bFirstDraw = FALSE; XorLine(m_ptStart,point); m_ptEnd = point; } break; case PEN: SetPixel(pDC, point); SetPixel(m_pdcMem, point); m_ptStart = point; break; case BRUSH: SetPixel(pDC, point, GetPenWidth()); SetPixel(m_pdcMem, point, GetPenWidth()); m_ptStart = point; break; case ERASER: EraserBox(pDC, point); EraserBox(m_pdcMem, point); m_ptStart = point; break; case RECT: if ( !m_bFirstDraw ) Rectangle(pDC,m_ptStart,m_ptEnd); else m_bFirstDraw = FALSE; Rectangle(pDC,m_ptStart,point); m_ptEnd = point; break; default: break; } ReleaseDC(pDC); } CView::OnMouseMove(nFlags, point); } void CMyPaintView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CDC* pDC = GetDC(); switch(m_emPaintType) { case LINE: XorLine(m_ptStart,m_ptEnd); Line(m_ptStart,m_ptEnd); break; case PEN: break; case RECT: Rectangle(pDC,m_ptStart,m_ptEnd); Rectangle(m_pdcMem,m_ptStart,m_ptEnd,TRUE); break; default: break; } ReleaseDC(pDC); m_bDrawing = FALSE; Invalidate(); CView::OnLButtonUp(nFlags, point); } void CMyPaintView::Line(CPoint point1, CPoint point2) { CPen pen; pen.CreatePen(PS_SOLID, GetPenWidth(), GetPaintColor()); CPen* pOldPen = (CPen*)m_pdcMem->SelectObject(&pen); m_pdcMem->MoveTo(point1); m_pdcMem->LineTo(point2); m_pdcMem->SelectObject(pOldPen); } void CMyPaintView::SetPixel(CDC* pDC,CPoint point,int nPenWidth) { CPen pen; pen.CreatePen(PS_SOLID, nPenWidth, GetPaintColor()); CPen* pOldPen = (CPen*)pDC->SelectObject(&pen); pDC->MoveTo(m_ptStart); pDC->LineTo(point); pDC->SelectObject(pOldPen); } BOOL CMyPaintView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { // TODO: Add your message handler code here and/or call default HCURSOR hCursor = NULL; switch(m_emPaintType) { case LINE: hCursor = AfxGetApp()->LoadCursor(IDC_LINE); break; case PEN: hCursor = AfxGetApp()->LoadCursor(IDC_PEN); break; case BRUSH: hCursor = AfxGetApp()->LoadCursor(IDC_BRUSH); break; case ERASER: hCursor = AfxGetApp()->LoadCursor(IDC_ERASER); break; case FILL: hCursor = AfxGetApp()->LoadCursor(IDC_FILL); break; case RECT: hCursor = AfxGetApp()->LoadCursor(IDC_LINE); break; default: break; } if ( hCursor ) { ::SetCursor(hCursor); return TRUE; } else return CView::OnSetCursor(pWnd, nHitTest, message); } void CMyPaintView::Fill(CDC *pDC, CPoint point) { CBrush brush; brush.CreateSolidBrush(GetPaintColor()); CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush); pDC->ExtFloodFill(point.x,point.y,pDC->GetPixel(point),FLOODFILLSURFACE); pDC->SelectObject(pOldBrush); } void CMyPaintView::EraserBox(CDC* pDC, CPoint point) {//|PS_INSIDEFRAME | PS_ENDCAP_ROUND CPen pen( PS_SOLID , 9, GetCanvasColor()); CPen* pOldPen = (CPen*)pDC->SelectObject(&pen); /* CBrush brush; brush.CreateSolidBrush(GetCanvasColor()); CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush); */ // pDC->Rectangle(point.x-5,point.y-5,point.x+5,point.y+5); pDC->MoveTo(m_ptStart); pDC->LineTo(point); // pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); } void CMyPaintView::Rectangle(CDC *pDC, CPoint ptUpperLeft, CPoint ptLowerLeft, BOOL bXorROP) { CPen pen; if ( !bXorROP ) pen.CreateStockObject(WHITE_PEN); else pen.CreatePen(PS_SOLID, GetPenWidth(), GetPaintColor()); CPen* pOldPen = (CPen*)pDC->SelectObject(&pen); CBrush brush; if ( bXorROP ) brush.CreateSolidBrush(GetCanvasColor()); else { brush.CreateStockObject(NULL_BRUSH); pDC->SetROP2(R2_XORPEN); } CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush); pDC->Rectangle(ptUpperLeft.x,ptUpperLeft.y,ptLowerLeft.x,ptLowerLeft.y); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); } void CMyPaintView::OnUpdateButtonRect(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==RECT); } void CMyPaintView::OnButtonRect() { // TODO: Add your command handler code here m_emPaintType = RECT; SetSelBox(SEL_RECTTYPE); } void CMyPaintView::OnUpdateButtonPolygon(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==POLYGON); } void CMyPaintView::OnButtonPolygon() { // TODO: Add your command handler code here m_emPaintType = POLYGON; SetSelBox(SEL_RECTTYPE); } void CMyPaintView::OnUpdateButtonRoundRect(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==ROUND_RECT); } void CMyPaintView::OnButtonRoundRect() { // TODO: Add your command handler code here m_emPaintType = ROUND_RECT; SetSelBox(SEL_RECTTYPE); } void CMyPaintView::OnUpdateButtonEllipse(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==ELLIPSE); } void CMyPaintView::OnButtonEllipse() { // TODO: Add your command handler code here m_emPaintType = ELLIPSE; SetSelBox(SEL_RECTTYPE); } void CMyPaintView::OnEditUndo() { // TODO: Add your command handler code here Restore(); } void CMyPaintView::OnEditRedo() { // TODO: Add your command handler code here } void CMyPaintView::Backup() { ASSERT(m_pbyBitmapBuf); m_pbmBackground->GetBitmapBits(m_dwSizeBitmap,m_pbyBitmapBuf); m_bmBackup.DeleteObject(); m_bmBackup.CreateBitmap(m_nScreenW,m_nScreenH, 1, 32, m_pbyBitmapBuf); } void CMyPaintView::Restore() { m_bmBackup.GetBitmapBits(m_dwSizeBitmap,m_pbyBitmapBuf); m_pbmBackground->DeleteObject(); m_pbmBackground->CreateBitmap(m_nScreenW,m_nScreenH, 1, 32, m_pbyBitmapBuf); UpdateImage(); }

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧