当前位置: 首页>>代码示例>>C++>>正文


C++ OnPrepareDC函数代码示例

本文整理汇总了C++中OnPrepareDC函数的典型用法代码示例。如果您正苦于以下问题:C++ OnPrepareDC函数的具体用法?C++ OnPrepareDC怎么用?C++ OnPrepareDC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OnPrepareDC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetRowCount

//--------------------------------------------------------------
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;
 }
}
开发者ID:Stas777,项目名称:Exsylor,代码行数:32,代码来源:Bmview.cpp

示例2: dc

void CDrawView::DocToClient(CRect& rect)
{
	CClientDC dc(this);
	OnPrepareDC(&dc, NULL);
	dc.LPtoDP(rect);
	//rect.NormalizeRect();
}
开发者ID:wanglaichen2,项目名称:Mfc_Gui,代码行数:7,代码来源:DrawVw.cpp

示例3: dc

void CQueView::DocToClient(CRect* rect)
{
    CClientDC dc(this);
    OnPrepareDC(&dc, nullptr);
    dc.LPtoDP(rect);
    rect->NormalizeRect();
}
开发者ID:vSzemkel,项目名称:Manam,代码行数:7,代码来源:QueView.cpp

示例4: dlg

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;
	}
}
开发者ID:johanericsson,项目名称:schedule,代码行数:34,代码来源:ScheduleViewEx.cpp

示例5: ASSERT_VALID

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;
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:33,代码来源:viewedit.cpp

示例6: dc

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);
}
开发者ID:deNULL,项目名称:seman,代码行数:29,代码来源:VisualSynanView.cpp

示例7: ASSERT

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);	
}
开发者ID:Anonymousvn,项目名称:bigbrother,代码行数:31,代码来源:ActivityView.cpp

示例8: window

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;
}
开发者ID:Microsoft,项目名称:DesktopBridgeToUWP-Samples,代码行数:28,代码来源:scribvw.cpp

示例9: ASSERT

// 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;
}
开发者ID:KB3NZQ,项目名称:hexedit4,代码行数:40,代码来源:ScrView.cpp

示例10: dc

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();
}
开发者ID:caomw,项目名称:ImageSegmentor,代码行数:25,代码来源:imageView.cpp

示例11: dc

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);
	}
}
开发者ID:amitahire,项目名称:development,代码行数:34,代码来源:game2view.cpp

示例12: GetDocument

/********************************************************************************
 * 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);
}
开发者ID:vgck,项目名称:opendr2,代码行数:34,代码来源:WhiteBoardView.cpp

示例13: dc

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);
			}
	}
}
开发者ID:lubomyr,项目名称:freespace2,代码行数:33,代码来源:campaigntreeview.cpp

示例14: dc

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;
}
开发者ID:loyoen,项目名称:Jet,代码行数:28,代码来源:PictureView.cpp

示例15: dc

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
}
开发者ID:drupalhunter-team,项目名称:TrackMonitor,代码行数:29,代码来源:OXImageViewer.cpp


注:本文中的OnPrepareDC函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。