bool GameUtil::saveToFileFromSprite(CCSprite* pOrg, char* szFile) { CCPoint ptOrg(pOrg->getPosition()); CCRenderTexture * rt = CCRenderTexture::create((int)pOrg->getContentSize().width, (int)pOrg->getContentSize().height); pOrg->setPosition(ccp(pOrg->getContentSize().width/2, pOrg->getContentSize().height/2)); rt->begin(); pOrg->visit(); rt->end(); pOrg->setPosition(ptOrg); bool bSave = rt->saveToFile(szFile); return bSave; }
void CDBFrame::DrawSysButtons(CDC *pDC) { //更新系统按钮位置 OnSetSysButtonPos(); DWORD dwStyle = GetStyle(); if (!(dwStyle & WS_SYSMENU)) return; //绘制系统按钮 CRect rcWindow; GetWindowRect(&rcWindow); //关闭按钮 CSize szBtnBmp = m_sysCloseBtn.GetImageSize(); CPoint ptOrg(rcWindow.Width() - szBtnBmp.cx - m_rcSysCloseBtn.left, m_rcSysBorder.top); ptOrg.Offset(rcWindow.TopLeft()); ScreenToClient(&ptOrg); m_sysCloseBtn.DrawButton(ptOrg, pDC); //注意:CDBButton类中的调用总是相对于客户区 if (!(dwStyle & WS_MINIMIZEBOX) && !(dwStyle & WS_MAXIMIZEBOX)) return; //最大化按钮 szBtnBmp = m_sysMaxBtn.GetImageSize(); ptOrg.Offset(-szBtnBmp.cx, 0); m_sysMaxBtn.DrawButton(ptOrg, pDC); //注意:CDBButton类中的调用总是相对于客户区 //最小化按钮 szBtnBmp = m_sysMinBtn.GetImageSize(); ptOrg.Offset(-szBtnBmp.cx, 0); m_sysMinBtn.DrawButton(ptOrg, pDC); //注意:CDBButton类中的调用总是相对于客户区 }
//----------------------------------------------------------------------------- // Purpose: Handles left mouse button down events in the 2D view. // Input : Per CWnd::OnLButtonDown. // Output : Returns true if the message was handled, false if not. //----------------------------------------------------------------------------- bool Clipper3D::OnLMouseDown2D(CMapView2D *pView, UINT nFlags, CPoint point) { CMapDoc *pDoc = pView->GetDocument(); CMapWorld *pWorld = pDoc->GetMapWorld(); m_ptLDownClient = point; m_bLButtonDown = true; pView->SetCapture(); // // Convert to some odd coordinate space that the base tools code uses. // CPoint ptScreen = point; ptScreen.x += pView->GetScrollPos(SB_HORZ); ptScreen.y += pView->GetScrollPos(SB_VERT); // // Convert point to world coords. // pView->ClientToWorld(point); Vector ptOrg( COORD_NOTINIT, COORD_NOTINIT, COORD_NOTINIT ); ptOrg[axHorz] = point.x; ptOrg[axVert] = point.y; // getvisiblepoint fills in any coord that's still set to COORD_NOTINIT: pDoc->GetBestVisiblePoint(ptOrg); // snap starting position to grid if (!(GetAsyncKeyState(VK_MENU) & 0x8000)) { pDoc->Snap(ptOrg); } BOOL bStarting = FALSE; // if the tool is not empty, and shift is not held down (to // start a new camera), don't do anything. if(!IsEmpty()) { if(!StartTranslation(ptScreen)) { if (nFlags & MK_SHIFT) { SetEmpty(); bStarting = TRUE; } else { goto _DoNothing; } } } else { bStarting = TRUE; } SetClipObjects(pDoc->Selection_GetList()); if (bStarting) { StartNew(ptOrg); pView->SetUpdateFlag(CMapView2D::updTool); } _DoNothing: return true; }