//-------------------------------------------------------------- void CBMRegEditView::UpdateRow(int nInvalidRow) { int nRowCount = GetRowCount(); if (nRowCount != m_nPrevRowCount) { UpdateScrollSizes(); m_nPrevRowCount = nRowCount; } CClientDC dc(this); OnPrepareDC(&dc); int nFirstRow, nLastRow; CRect rectClient; GetClientRect(&rectClient); dc.DPtoLP(&rectClient); RectLPtoRowRange(rectClient, nFirstRow, nLastRow, FALSE); POINT pt; pt.x = 0; BOOL bNeedToScroll = TRUE; if (nInvalidRow < nFirstRow) pt.y = RowToYPos(nInvalidRow); else if (nInvalidRow > nLastRow) pt.y=max(0,RowToYPos(nInvalidRow+1) - rectClient.Height()); else bNeedToScroll = FALSE; if (bNeedToScroll) { ScrollToDevicePosition(pt); OnPrepareDC(&dc); } CRect rectInvalid = RowToWndRect(&dc, nInvalidRow); rectInvalid.left=23; rectInvalid.right=37; InvalidateRect(&rectInvalid); int nSelectedRow = GetActReg(); if (m_nPrevSelectedRow != nSelectedRow) { CRect rectOldSelection = RowToWndRect(&dc, m_nPrevSelectedRow); rectOldSelection.left=23; rectOldSelection.right=37; InvalidateRect(&rectOldSelection); m_nPrevSelectedRow = nSelectedRow; } }
void CDrawView::DocToClient(CRect& rect) { CClientDC dc(this); OnPrepareDC(&dc, NULL); dc.LPtoDP(rect); //rect.NormalizeRect(); }
void CQueView::DocToClient(CRect* rect) { CClientDC dc(this); OnPrepareDC(&dc, nullptr); dc.LPtoDP(rect); rect->NormalizeRect(); }
void ScheduleViewEx::OnPrintAll() { CPrintDialog dlg(FALSE); if (IDOK == dlg.DoModal()) { HDC dc = dlg.GetPrinterDC(); CDC DC; DC.Attach(dc); DEVMODE *myMode = dlg.GetDevMode();//fills myMode with printer defaults myMode->dmOrientation = DMORIENT_LANDSCAPE;//change default to landscape myMode->dmPrintQuality = DMRES_DRAFT; myMode->dmColor = DMCOLOR_MONOCHROME; DC.ResetDC(myMode); DC.m_bPrinting = TRUE; OnPrepareDC(&DC); DC.StartDoc(_T("myDoc")); int tmpOffset = m_offset; for (int i = 0; i< TotalPages(); i++) { m_offset = i; DC.StartPage(); OnDraw(&DC); DC.EndPage(); } DC.EndDoc(); m_offset = tmpOffset; } }
BOOL CEditView::PaginateTo(CDC* pDC, CPrintInfo* pInfo) // attempts pagination to pInfo->m_nCurPage, TRUE == success { ASSERT_VALID(this); ASSERT_VALID(pDC); CRect rectSave = pInfo->m_rectDraw; UINT nPageSave = pInfo->m_nCurPage; ASSERT(nPageSave > 1); ASSERT(nPageSave >= (UINT)m_aPageStart.GetSize()); VERIFY(pDC->SaveDC() != 0); pDC->IntersectClipRect(0, 0, 0, 0); pInfo->m_nCurPage = m_aPageStart.GetSize(); while (pInfo->m_nCurPage < nPageSave) { ASSERT(pInfo->m_nCurPage == (UINT)m_aPageStart.GetSize()); OnPrepareDC(pDC, pInfo); ASSERT(pInfo->m_bContinuePrinting); pInfo->m_rectDraw.SetRect(0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES)); pDC->DPtoLP(&pInfo->m_rectDraw); OnPrint(pDC, pInfo); if (pInfo->m_nCurPage == (UINT)m_aPageStart.GetSize()) break; ++pInfo->m_nCurPage; } BOOL bResult = pInfo->m_nCurPage == nPageSave; pDC->RestoreDC(-1); pInfo->m_nCurPage = nPageSave; pInfo->m_rectDraw = rectSave; ASSERT_VALID(this); return bResult; }
BOOL CVisualSynanView::PreTranslateMessage(MSG* pMsg) { if( pMsg->message== WM_LBUTTONDOWN || pMsg->message== WM_LBUTTONUP || pMsg->message== WM_MOUSEMOVE) { CClientDC dc(NULL); OnPrepareDC(&dc); BOOL bInSomeWord; CPoint ClientPoint = pMsg->pt; ScreenToClient(&ClientPoint); dc.DPtoLP(&ClientPoint); bInSomeWord = GetDocument()->GetHomonymsArray(ClientPoint,NULL,&m_iActiveSentenceTT,&m_iActiveWordTT); if(bInSomeWord) { dc.LPtoDP(&ClientPoint); CRect rect(ClientPoint.x - 1, ClientPoint.y - 1, ClientPoint.x + 1,ClientPoint.y + 1); m_ctrlToolTip.SetToolRect(this,ID_WORD_TOOL,rect); m_ctrlToolTip.RelayEvent(pMsg); } else { m_iActiveWordTT = -1; m_iActiveSentenceTT = -1; } } return CScrollView::PreTranslateMessage(pMsg); }
void CActivityView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { CBigBrotherDoc* pDoc = (CBigBrotherDoc*)GetDocument(); if(!pDoc) return; ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CBigBrotherDoc))); if(pHint){ CBrother *b = (CBrother*)pHint; if(m_Brothers->Find(b)){ CClientDC dc(this); OnPrepareDC(&dc); CRect rc = b->m_rc; dc.LPtoDP(&rc); InvalidateRect(rc,FALSE); } return; } m_Brothers->RemoveAll(); CBrother *b = pDoc->GetCurrentBrother(); if(b) pDoc->GetFamily(b,m_Brothers); SetScaleToFitSize(CSize(10+500+10,20+m_Brothers->GetCount()*105+20)); POSITION p = m_Brothers->GetHeadPosition(); int host = 0; while(p){ CBrother *b = m_Brothers->GetNext(p); b->m_rc.SetRect(10,20+host*105,10+500,20+host*105+100); host++; } CScrollView::OnUpdate(pSender,lHint,pHint); }
void CScribbleView::OnMouseMove(UINT, CPoint point) { // Mouse movement is interesting in the Scribble application // only if the user is currently drawing a new stroke by dragging // the captured mouse. if (GetCapture() != this) return; // If this window (view) didn't capture the mouse, // then the user isn't drawing in this window. CClientDC dc(this); // CScrollView changes the viewport origin and mapping mode. // It's necessary to convert the point from device coordinates // to logical coordinates, such as are stored in the document. OnPrepareDC(&dc); dc.DPtoLP(&point); m_pStrokeCur->m_pointArray.Add(point); // Draw a line from the previous detected point in the mouse // drag to the current point. CPen* pOldPen = dc.SelectObject(GetDocument()->GetCurrentPen()); dc.MoveTo(m_ptPrev); dc.LineTo(point); dc.SelectObject(pOldPen); m_ptPrev = point; return; }
// The following handle conversion between our view coords and device coords // The view coords are logical coords (with origin the top left corner of // the window) BUT the direction of the axes is always +ve down and right, // like MM_TEXT but unlike MM_LOENGLISH etc. // Routines are provided to convert CRect and CPoint between view coords and // device coords. To convert a CSize object just use DPToLP and LPToDP // (since they always return +ve results for CSize). CRect CScrView::ConvertToDP(CRectAp rr) { ASSERT(init_coord_); rr -= scrollpos_; CRect retval; if (negx_) { retval.left = -rr.left; retval.right = -rr.right; } else { retval.left = rr.left; retval.right = rr.right; } if (negy_) { retval.top = -int(rr.top); retval.bottom = -int(rr.bottom); } else { retval.top = int(rr.top); retval.bottom = int(rr.bottom); } CClientDC dc(this); OnPrepareDC(&dc); dc.LPtoDP(&retval); retval.left += bdr_left_; retval.right += bdr_left_; retval.top += bdr_top_; retval.bottom += bdr_top_; return retval; }
void CImageView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //SetCapture();viewfeatures==true CImageDoc*pDoc=GetDocument(); CString rid,rs,rnc; if(pDoc->m_HC.GetSetSize()) { CClientDC dc(this); OnPrepareDC(&dc); dc.DPtoLP(&point); int miss=pDoc->lookregion(point.x,point.y,1); // pDoc->curRegion=miss; rid.Format("ID:%d",miss); // rs.Format("%d",pDoc->m_HC.S[miss].size); // rnc.Format("%d",pDoc->m_HC.S[miss].perim); } CMainFrame* pMainFrame= (CMainFrame*)( AfxGetApp()->m_pMainWnd); ASSERT_KINDOF(CMainFrame, pMainFrame); pMainFrame->m_wndStatusBar.SetPaneText(PANE_REGION_ID, rid); // pMainFrame->m_wndStatusBar.SetPaneText(PANE_REGION_SIZE, rs); // pMainFrame->m_wndStatusBar.SetPaneText(PANE_RN_COUNT, rnc); CScrollView::OnLButtonDown(nFlags, point); Invalidate(); }
void CGame2View::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if (mMouseLbuttonDown) { CClientDC dc(this); if(mBoundingBoxIsUp) { // erase our current box... DrawBoundingBox(mCurSelectRect); } // figure new box... mMouseEndLoc = point; OnPrepareDC(&dc); dc.DPtoLP(&mMouseEndLoc); mCurSelectRect.top = min(mMouseStartLoc.y,mMouseEndLoc.y); mCurSelectRect.bottom = max(mMouseStartLoc.y,mMouseEndLoc.y); mCurSelectRect.left = min(mMouseStartLoc.x,mMouseEndLoc.x); mCurSelectRect.right = max(mMouseStartLoc.x,mMouseEndLoc.x); // draw the rectangle mBoundingBoxIsUp = TRUE; DrawBoundingBox(mCurSelectRect); } else { CScrollView::OnMouseMove(nFlags, point); } }
/******************************************************************************** * Begin store the mouse movements into our stroke objects * ********************************************************************************/ void CWhiteBoardView::OnLButtonDown(UINT nFlags, CPoint point) { CWhiteBoardDoc* pDoc = GetDocument(); // the Document // Note: Do NOT use GetDC when sending coordinates from one // scroll view to another, the stroke will not display correctly CClientDC theDC(this); // the Device Context OnPrepareDC(&theDC); // prepare the Device Context bIsDrawing = true; // We are now drawing SetCapture(); // Keep the mouse focus // Covert the point to logical units (prevent mangling due to scrolling) theDC.DPtoLP(&point); // Create a new stroke starting at the current mouse location if (pDoc->m_pCurStroke == NULL) { pDoc->m_pCurStroke = new CStroke(point); pDoc->m_pCurStroke->mStrokeColor = pDoc->m_CurStrokeColor; pDoc->m_pCurStroke->mStrokeSize = pDoc->m_nCurStrokeSize; pDoc->m_StrokeList.AddTail( pDoc->m_pCurStroke ); } // Move the graphics pt to the stroke's first point (mouse position) theDC.MoveTo(point); mCurPoint = point; // Call the base case implementation CScrollView::OnLButtonDown(nFlags, point); }
void campaign_tree_view::OnContextMenu(CWnd* pWnd, CPoint point) { int i; CMenu menu, *popup; CPoint p = point; CClientDC dc(this); OnPrepareDC(&dc); dc.DPtoLP(&p); ScreenToClient(&p); for (i=0; i<Campaign.num_missions; i++) if (Elements[i].box.PtInRect(p)) break; if (i < Campaign.num_missions) { // clicked on a mission Context_mission = i; if (menu.LoadMenu(IDR_CPGN_VIEW_ON)) { popup = menu.GetSubMenu(0); ASSERT(popup); popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); } } else { Context_mission = query_level(p); if ((Context_mission >= 0) && (Context_mission < total_levels)) if (menu.LoadMenu(IDR_CPGN_VIEW_OFF)) { popup = menu.GetSubMenu(0); ASSERT(popup); popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); } } }
void CPictureView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //CScrollView::OnLButtonDown(nFlags, point); if ( m_bDrawScript == TRUE ) { CClientDC dc(this); OnPrepareDC(&dc); dc.DPtoLP(&point); //, begin m_pDoc->m_bScriptChanged = TRUE; // 标识笔迹已修执行 //, ends m_pDoc->m_bHasScript = TRUE; // 标识有笔迹产生 m_pScriptLineCur = m_pDoc->NewScriptLine(); m_ptPrev = point; //笔迹点的坐标必须与job显示模式相关联 point.x /= (m_fDisplayModeX * m_fDisplayScale); point.y /= (m_fDisplayModeY * m_fDisplayScale); m_pScriptLineCur->m_pointArray.Add(point); SetCapture(); } return; }
void COXImageViewer::OnPaint() { CPaintDC dc(this); // device context for painting if(m_dib.IsEmpty()) return; // TODO: Add your message handler code here OnPrepareDC(&dc); // get the size of image CSize sizeDIB=GetDIBSize(); CRect rect(0,0,sizeDIB.cx,sizeDIB.cy); CRect rectPaint=rect; // transform coordinates of boundary rectangle // taking into account current zoom level NormalToScaled(&rectPaint); /// // we have to revert Y-coordinates // to get right print output UINT diff=rect.bottom-rect.top; rect.bottom=sizeDIB.cy-rect.top; rect.top=rect.bottom-diff; /// DrawDIB(&dc,rectPaint,rect); // Do not call COXScrollWnd::OnPaint() for painting messages }
void CJevView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if( bMouseDown == FALSE ) return; TRACE( "Entering OnMouseMove()\n" ); CJevDoc* pDoc = GetDocument(); CClientDC dc( this ); OnPrepareDC( &dc ); dc.DPtoLP( &point ); CRect rect( point, CSize( 1,1 )); int nyNewActiveDispLine, njeLastSelectedRecord, nSubAcct; nyNewActiveDispLine = rect.top / m_cyChar; TRACE( "top=%d, nyNewActiveDispLine=%d\n", rect.top, nyNewActiveDispLine ); pDoc->MapDispLineToNJE( nyNewActiveDispLine, njeLastSelectedRecord, nSubAcct ); if( njeLastSelectedRecord < pDoc->m_JEArray.GetSize() && njeLastSelectedRecord >=0 ) { TRACE("LastSelectedRecord=%d\n" ,njeLastSelectedRecord); if( m_njePrevLastSelectedRecord != njeLastSelectedRecord) { pDoc->SetLastSelectedRecord( njeLastSelectedRecord ); m_njePrevLastSelectedRecord = njeLastSelectedRecord; } } CScrollView::OnMouseMove(nFlags, point); TRACE( "Leaving OnMouseMove()\n" ); }
void CPrefView::CreateAllBitmapX() { // Pictures preparate int n=m_pX->m_scale->GetGradation(); if (m_pPictX!=NULL) delete [] m_pPictX; m_pPictX=new CPictureHolder[n]; if (m_pBitmapX!=NULL) delete [] m_pBitmapX; m_pBitmapX=new CBitmap[n]; CClientDC dc(this); OnPrepareDC(&dc); dc.SetMapMode(MM_TWIPS); // CSize size(m_Grid.GetColWidth(1),m_Grid.GetRowHeight(1)); CSize size(m_sG.cx,m_sG0.cy); dc.LPtoDP(&size); CDC* dcMemory=new CDC(); dcMemory->CreateCompatibleDC(&dc); for (int j=0; j<n; j++) { m_pBitmapX[j].CreateCompatibleBitmap(&dc,size.cx-3,size.cy-3); dcMemory->SelectObject(&(m_pBitmapX[j])); dcMemory->SelectStockObject(LTGRAY_BRUSH); dcMemory->SelectStockObject(NULL_PEN); dcMemory->Rectangle(0,0,size.cx,size.cy); dcMemory->SetBkMode(TRANSPARENT); dcMemory->SelectObject(m_curFont); dcMemory->TextOut(size.cx/2-11,size.cy-5,m_pX->m_scale->GetLex(j)); m_pPictX[j].CreateFromBitmap(&m_pBitmapX[j]); } delete dcMemory; // end pictures }
int CPhylogenView::ClearSelected(int *Selection) { CGenedocDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); *Selection = 0; CClientDC dc(this); OnPrepareDC(&dc); POSITION Pos; Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition(); while ( Pos != NULL ) { CPhyloGenBase * pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos); if ( pPGB->m_Selected == 1 ) { CDC* pDC = GetDC(); pPGB->m_Selected = 0; CRect tRect = pPGB->m_ClientRect; dc.LPtoDP( &tRect ); pDC->DrawFocusRect( tRect ); ReleaseDC( pDC ); return 1; } (*Selection)++; } return 0; }
void CScrollWnd::OnPaint() { CPaintDC dc(this); // device context for painting CDC MemDC; MemDC.CreateCompatibleDC(&dc); CBitmap MemBMP; CRect rc; GetClientRect(rc); MemBMP.CreateCompatibleBitmap(&dc, rc.Width(), rc.Height()); CBitmap* pOldBmp = MemDC.SelectObject(&MemBMP); MemDC.PatBlt(0, 0, rc.Width(), rc.Height(), WHITENESS); int nSavedDC = MemDC.SaveDC(); OnPrepareDC(&MemDC); OnDraw(&MemDC); MemDC.RestoreDC(nSavedDC); dc.BitBlt(0, 0, rc.Width(), rc.Height(), &MemDC, 0, 0, SRCCOPY); MemDC.SelectObject(pOldBmp); // OnDraw(&dc); }
void CScribbleView::OnUpdate(CView* /* pSender */, LPARAM /* lHint */, CObject* pHint) { // The document has informed this view that some data has changed. if (pHint != NULL) { if (pHint->IsKindOf(RUNTIME_CLASS(CStroke))) { // The hint is that a stroke as been added (or changed). // So, invalidate its rectangle. CStroke* pStroke = (CStroke*)pHint; CClientDC dc(this); OnPrepareDC(&dc); CRect rectInvalid = pStroke->GetBoundingRect(); dc.LPtoDP(&rectInvalid); InvalidateRect(&rectInvalid); return; } } // We can't interpret the hint, so assume that anything might // have been updated. Invalidate(TRUE); return; }
void CVisualSynanView::Recalculate(CDC& clDC, CPrintInfo* pInfo) { if( GetDocument()->NoSentences() ) return; //selecting choosen font CFont* pOldFont = NULL; //creating memory DC CRect clientRect; GetClientRect(&clientRect); OnPrepareDC(&clDC,pInfo); clDC.DPtoLP(&clientRect); if( m_bExistUsefulFont) { pOldFont = clDC.SelectObject(&m_FontForWords); } //calculating sentences coordinates GetDocument()->CalculateCoordinates(&clDC,clientRect.right, m_bShowGroups); if( pOldFont ) clDC.SelectObject(pOldFont); }
void CView::OnPaint() { // standard paint routine CPaintDC dc(this); OnPrepareDC(&dc); OnDraw(&dc); }
// Make sure caret/selection visible. The display is scrolled if necessary to // ensure that the caret or selection is (just) within the display area. // Does nothing if EnableCaret has not been called and there is no selection. void CScrView::DisplayCaret() { // Is the caret enabled? if (caret_on_ && caretpos_ == selpos_) { // Get the point and size of the caret (so we can move it into display) CPointAp point(caretpos_); CSizeAp size = caret_size(); // Widen rect so that text on either side of caret will be visible TEXTMETRIC tm; { CClientDC dc(this); OnPrepareDC(&dc); dc.GetTextMetrics(&tm); } // Add extra char width on left and 2 on right point.x -= tm.tmMaxCharWidth; if (point.x < 0) point.x = 0; size.cx += 3*tm.tmMaxCharWidth; DisplayPart(point, size); } else if (caretpos_ != selpos_) { CSizeAp tt, pp, ll; GetSize(tt, pp, ll); CPointAp start(caretpos_); CPointAp end(selpos_); CSizeAp size = caret_size(); start.x = 0; size.cy += end.y - start.y; size.cx = tt.cx; DisplayPart(start, size, caretpos_ == basepos_); } }
void CGame2View::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if (mMouseLbuttonDown) { // get client dc for conversion of final rect. // to logical coord. from device coord. CClientDC dc(this); mMouseLbuttonDown = FALSE; if(mBoundingBoxIsUp) { // erase our current box... DrawBoundingBox(mCurSelectRect); } mBoundingBoxIsUp = FALSE; // figure new box... mMouseEndLoc = point; OnPrepareDC(&dc); dc.DPtoLP(&mMouseEndLoc); mCurSelectRect.top = min(mMouseStartLoc.y,mMouseEndLoc.y); mCurSelectRect.bottom = max(mMouseStartLoc.y,mMouseEndLoc.y); mCurSelectRect.left = min(mMouseStartLoc.x,mMouseEndLoc.x); mCurSelectRect.right = max(mMouseStartLoc.x,mMouseEndLoc.x); if( ((mCurSelectRect.bottom - mCurSelectRect.top) < MIN_BOX_WIDTH) && ((mCurSelectRect.right - mCurSelectRect.left) < MIN_BOX_WIDTH) ) { mPointSelectMode = TRUE; mCurSelectPoint = mMouseEndLoc; // dc.DPtoLP(&mCurSelectPoint); } else { mPointSelectMode = FALSE; // dc.DPtoLP(&mCurSelectRect); } // do something here (we now have our selection rectangle // convert to logical coordinates from device.. // show proper stuff as selected.. ProcessSelected(); // force a redraw Invalidate(FALSE); // GetDocument()->UpdateAllViews(this); } else { CScrollView::OnLButtonUp(nFlags, point); } }
void MFCSequenceEditor::OnPaint() { // standard paint routine CPaintDC dc(this); OnPrepareDC(&dc); OnDraw(&dc); }
void CVisualSynanView::ResizeScroll() { CClientDC dc(NULL); OnPrepareDC(&dc); CSize sizeDoc = GetDocument()->GetSentencesSize(); dc.LPtoDP(&sizeDoc); SetScrollSizes(MM_TEXT, sizeDoc); }
void CScribbleView::ResyncScrollSizes() { CClientDC dc(NULL); OnPrepareDC(&dc); CSize sizeDoc = GetDocument()->GetDocSize(); dc.LPtoDP(&sizeDoc); SetScrollSizes(MM_TEXT, sizeDoc); }
void CZarplataView::ResetScrollSizes(void) { CClientDC aDC(this); OnPrepareDC(&aDC); CSize DocSize = GetDocument()->GetDocSize(); aDC.LPtoDP(&DocSize); SetScrollSizes(MM_TEXT, DocSize, CSize(300, 300)); }
void CSketcherView::ResetScrollSizes(void) { CClientDC aDC(this); OnPrepareDC(&aDC); // Set up the device context CSize DocSize = GetDocument()->GetDocSize(); // Get the document size aDC.LPtoDP(&DocSize); // Get the size in pixels SetScrollSizes(MM_TEXT, DocSize); // Set up the scrollbars }
void CContourView::OnPaint() { CPaintDC dc( this ); // device context for painting // TODO: Add your message handler code here OnPrepareDC( &dc ); OnDraw( &dc ); // Do not call CLogScrollView::OnPaint() for painting messages }