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


C++ CDC::DPtoLP方法代码示例

本文整理汇总了C++中CDC::DPtoLP方法的典型用法代码示例。如果您正苦于以下问题:C++ CDC::DPtoLP方法的具体用法?C++ CDC::DPtoLP怎么用?C++ CDC::DPtoLP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDC的用法示例。


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

示例1: OnMouseMove

void CContourView::OnMouseMove( UINT nFlags, CPoint point )
{
    // TODO: Add your message handler code here and/or call default
    CDC*  dc;
    RECT therect;
    CString buffer;
    POINT pt( point );
    double zval;

    dc = this->GetDC();
    this->GetClientRect( &therect );
    dc->DPtoLP( &therect );

    dc->DPtoLP( &pt );
    buffer.Format( "                                                                                                                 " );
    TextOut( dc->m_hDC, therect.left, therect.top, buffer, buffer.GetLength() );
    if ( m_pTriangle->IsInControlDots( pt, zval ) == true )
        buffer.Format( "x=%7d  y=%7d  z=%7.2f", pt.x, pt.y, zval );
    else
        buffer.Format( "x=%7d  y=%7d", pt.x, pt.y );
    TextOut( dc->m_hDC, therect.left, therect.top, buffer, buffer.GetLength() );


    CLogScrollView::OnMouseMove( nFlags, point );
}
开发者ID:kanbang,项目名称:myexercise,代码行数:25,代码来源:ContourView.cpp

示例2: Recalculate

 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);

}
开发者ID:deNULL,项目名称:seman,代码行数:26,代码来源:VisualSynanView.cpp

示例3: OnOpenDocument

BOOL CObjDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	string pathStr = lpszPathName;
	m_Object = new CWavefrontObj(pathStr);

	CRect tRect(0, 0, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
	CDC tDC;
	CBitmap *oldBitmap;
//	CRgn ClipRgn;
	CDC scrDC;
	
	scrDC.Attach(GetDC(GetDesktopWindow()));

//	ClipRgn.CreateRectRgn(tRect.left, tRect.top, tRect.right, tRect.bottom);

	tDC.CreateCompatibleDC(&scrDC);
	tDC.SetMapMode(scrDC.GetMapMode());

	tDC.DPtoLP(&tRect);
	tDC.SetWindowExt(tRect.Size());
	tDC.SetWindowOrg(tRect.left, tRect.top);

	tDC.LPtoDP(&tRect);
	tDC.SetViewportExt(tRect.Size());
	tDC.SetViewportOrg(tRect.left, tRect.top);

	m_ThumbNail.CreateCompatibleBitmap(&scrDC, tRect.Width(), tRect.Height());
	oldBitmap = tDC.SelectObject(&m_ThumbNail);

	tDC.FillSolidRect(tRect, RGB(0xff, 0xff, 0xff));
	// create a thumbnail
	CObjView::RenderImage(&tDC, this, tRect);

	tDC.SelectObject(oldBitmap);

	m_FileName = lpszPathName;
	GetFileTitle(m_FileName, m_DisplayName.GetBuffer(_MAX_FNAME),
		_MAX_FNAME);
	m_DisplayName.ReleaseBuffer();

	// made it this far so add to program list of objects
	gObjLoader->m_WavfObjects.push_back(m_Object);

	OBJECTSTRUCT os;

	os.name = &m_DisplayName;
	os.fileName = &m_FileName;
	os.thumbNail = &m_ThumbNail;
	os.pageIndex = &gObjLoader->m_PageIndex;
	os.rsrcIndex = &m_ObjectIndex;
	os.object = m_Object;

	gObjLoader->m_ProgramInfo->BroadcastMessage(
		AddObjectMessage, &os);

	return TRUE;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:59,代码来源:ObjDoc.cpp

示例4: OnFilePrint


//.........这里部分代码省略.........
		VERIFY(strTemp.LoadString(AFX_IDS_PRINTPAGENUM));

		// If it's a doc object, we don't loop page-by-page
		// because doc objects don't support that kind of levity.

		BOOL bError = FALSE;
		if (printInfo.m_bDocObject)
		{
			OnPrepareDC(&dcPrint, &printInfo);
			OnPrint(&dcPrint, &printInfo);
		}
		else
		{
			// begin page printing loop
			for (printInfo.m_nCurPage = nStartPage;
				printInfo.m_nCurPage != nEndPage; printInfo.m_nCurPage += nStep)
			{
				OnPrepareDC(&dcPrint, &printInfo);

				// check for end of print
				if (!printInfo.m_bContinuePrinting)
					break;

				// write current page
				TCHAR szBuf[80];
				ATL_CRT_ERRORCHECK_SPRINTF(_sntprintf_s(szBuf, _countof(szBuf), _countof(szBuf) - 1, strTemp, printInfo.m_nCurPage));
				
				dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf);

				// set up drawing rect to entire page (in logical coordinates)
				printInfo.m_rectDraw.SetRect(0, 0,
					dcPrint.GetDeviceCaps(HORZRES),
					dcPrint.GetDeviceCaps(VERTRES));
				dcPrint.DPtoLP(&printInfo.m_rectDraw);

				// attempt to start the current page
				if (dcPrint.StartPage() < 0)
				{
					bError = TRUE;
					break;
				}

				// must call OnPrepareDC on newer versions of Windows because
				// StartPage now resets the device attributes.
				OnPrepareDC(&dcPrint, &printInfo);

				ASSERT(printInfo.m_bContinuePrinting);

				// page successfully started, so now render the page
				OnPrint(&dcPrint, &printInfo);

				// If the user restarts the job when it's spooling, all 
				// subsequent calls to EndPage returns < 0. The first time
				// GetLastError returns ERROR_PRINT_CANCELLED
				if (dcPrint.EndPage() < 0 && (GetLastError()!= ERROR_SUCCESS))
				{
					HANDLE hPrinter;
					if (!OpenPrinter(LPTSTR(printInfo.m_pPD->GetDeviceName().GetBuffer()), &hPrinter, NULL))
					{
						bError = TRUE;
						break;
					}

					DWORD cBytesNeeded;
					if(!GetJob(hPrinter,printInfo.m_nJobNumber,1,NULL,0,&cBytesNeeded))
					{
开发者ID:pixelspark,项目名称:corespark,代码行数:67,代码来源:viewprnt.cpp

示例5: OnPrint


//.........这里部分代码省略.........
			dcPrint.Detach();   // will be cleaned up by CPrintInfo destructor
			AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT);
			return;
		}

		// Guarantee values are in the valid range
		UINT nEndPage = printInfo.GetToPage();
		UINT nStartPage = printInfo.GetFromPage();

		if (nEndPage < printInfo.GetMinPage())
			nEndPage = printInfo.GetMinPage();
		if (nEndPage > printInfo.GetMaxPage())
			nEndPage = printInfo.GetMaxPage();

		if (nStartPage < printInfo.GetMinPage())
			nStartPage = printInfo.GetMinPage();
		if (nStartPage > printInfo.GetMaxPage())
			nStartPage = printInfo.GetMaxPage();

		int nStep = (nEndPage >= nStartPage) ? 1 : -1;
		nEndPage = (nEndPage == 0xffff) ? 0xffff : nEndPage + nStep;

		VERIFY(strTemp.LoadString(AFX_IDS_PRINTPAGENUM));

		// If it's a doc object, we don't loop page-by-page
		// because doc objects don't support that kind of levity.

		BOOL bError = FALSE;
		
		// Print Loop // Burada DocObject kýsmý silindi
		{
			// begin page printing loop
			for (printInfo.m_nCurPage = nStartPage;
				printInfo.m_nCurPage != nEndPage; printInfo.m_nCurPage += nStep)
			{
				OnPrepareDC(&dcPrint, &printInfo);

				// check for end of print
				if (!printInfo.m_bContinuePrinting)
					break;

				// write current page
				TCHAR szBuf[80];
				wsprintf(szBuf, strTemp, printInfo.m_nCurPage);
				dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf);

				// set up drawing rect to entire page (in logical coordinates)
				printInfo.m_rectDraw.SetRect(0, 0,
					dcPrint.GetDeviceCaps(HORZRES),
					dcPrint.GetDeviceCaps(VERTRES));
				dcPrint.DPtoLP(&printInfo.m_rectDraw);

				// attempt to start the current page
				if (dcPrint.StartPage() < 0)
				{
					DebugMessage("Error on print 2");
					bError = TRUE;
					break;
				}

				// must call OnPrepareDC on newer versions of Windows because
				// StartPage now resets the device attributes.
				//if (afxData.bMarked4)
					OnPrepareDC(&dcPrint, &printInfo);

				ASSERT(printInfo.m_bContinuePrinting);

				// page successfully started, so now render the page
				OnPrint(&dcPrint, &printInfo);
				TRACE("on print\n");
				int stat = dcPrint.EndPage();
				if (stat < 0 || !AbortProc(dcPrint.m_hDC, 0))
				{
					bError = TRUE;
					CString str;
					str.Format("End Page = %ld,Abort = %ld",stat,gbAbort);
					DebugMessage(str);
					DebugMessage("Error on print");
					break;
				}
			}
		}

		// cleanup document printing process
		if (!printInfo.m_bDocObject)
		{
			if (!bError)
				dcPrint.EndDoc();
			else
				dcPrint.AbortDoc();
		}

		AfxGetMainWnd()->EnableWindow();    // enable main window

		OnEndPrinting(&dcPrint, &printInfo);    // clean up after printing
		dlgPrintStatus.DestroyWindow();

		dcPrint.Detach();   // will be cleaned up by CPrintInfo destructor
	}
}
开发者ID:hozgur,项目名称:Colorway,代码行数:101,代码来源:Print.cpp

示例6: OnLButtonUp

void CSpiroView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if (m_bMovingPencil)
	{
		CImageList& il = GetApp()->m_imageList;
		il.DragLeave(this);
		il.EndDrag();
		::ShowCursor(TRUE);

		ENSURE(m_pWheel != NULL);
		CDC* pDC = GetDC();
		ENSURE(pDC != NULL);
		OnPrepareDC(pDC);

		// undo the effect of the zoom factor on the point value
		pDC->DPtoLP(&point);
		point.x = point.x * m_nZoomDenom / m_nZoomNumer;
		point.y = point.y * m_nZoomDenom / m_nZoomNumer;
		if (m_pWheel->SetPenLocation(this, pDC, point, m_nZoomNumer, m_nZoomDenom))
		{
			GetDocument()->TransferCurrentFigure();
			CreateFigure();  // create figure for the new pen location
		}

		ReleaseDC(pDC);
		ReleaseCapture();
		m_bMovingPencil = false;
	}
	else if (m_pFigureDrag != NULL)
	{
		ENSURE(m_pILDragFigure != NULL);

		CPoint ptWindow(point);
		CDC* pDC = GetDC();
		ENSURE(pDC != NULL);

		// get new position for the figure being drawn and insert it into figure arrays
		
		CPoint	ptCorner(point.x - m_ptHotSpotDragFigure.x, point.y - m_ptHotSpotDragFigure.y);
		OnPrepareDC(pDC);
		pDC->DPtoLP(&ptCorner);   // convert corner of figure to logical coords

		ptCorner.x = ptCorner.x * m_nZoomDenom / m_nZoomNumer;  // undo effect of zooming
		ptCorner.y = ptCorner.y * m_nZoomDenom / m_nZoomNumer;


		if (m_pFigureDrag->MoveFigure(ptCorner, GetDocument()))   // move figure to new place
		{
			CSpiroRect	rect;
			m_pFigureDrag->GetBoundingRect(&rect);
			rect.Scale(m_nZoomNumer, m_nZoomDenom);
			pDC->LPtoDP(&rect);
			InvalidateRect(&rect);
			ReleaseDC(pDC);
		}

 		m_pILDragFigure->DragLeave(this);
		m_pILDragFigure->EndDrag();
 		UpdateWindow();
		delete m_pILDragFigure;  
		delete m_pBitmapDragFigure;   
		m_pBitmapDragFigure = NULL;
		m_pILDragFigure = NULL;

		ReleaseCapture();
		m_pFigureDrag = NULL;
	}

	CScrollView::OnLButtonUp(nFlags, point);
}
开发者ID:Jinjiego,项目名称:VCSamples,代码行数:70,代码来源:spiroView.cpp

示例7: OnLButtonDown

void CSpiroView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if (m_bDrawingActive)
		return;

	if (m_bDroppingAnchor || m_bDroppingWheel)
	{
		ASSERT(!m_bDrawingDone);
		CWheel* pWheelDrop = NULL;
		CRing*	pRingDrop = NULL;
		CSpiroDoc* pDoc = GetDocument();
		ENSURE(pDoc != NULL);

		//convert the client coordinates to logical coordinates
		CDC* pDC = GetDC();
		ENSURE(pDC != NULL);
		OnPrepareDC(pDC);

		// Convert client coordinates to Logical coordinates
		CPoint pointScaled(point);
		pDC->DPtoLP(&pointScaled);
		point.x = pointScaled.x * m_nZoomDenom / m_nZoomNumer;  // undo scaling effects
		point.y = pointScaled.y * m_nZoomDenom / m_nZoomNumer;

		CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
		ENSURE(pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame)));

		if (m_bDroppingAnchor)
		{
			ASSERT(m_iPieceDropped >= 0 && m_iPieceDropped < TOTALRINGS);
			pRingDrop = new CRing(CRing::m_rgnRads[m_iPieceDropped] - RINGWIDTH,
				CRing::m_rgnRads[m_iPieceDropped],
				CRing::m_rgco[m_iPieceDropped], RGB(0, 0, 0));

			ENSURE(pRingDrop != NULL);  
			m_bDroppingAnchor = false;
			ENSURE(m_pAnchor == NULL);
			m_pAnchor = pRingDrop;
			m_pAnchor->SetPosition(point);
			m_dDataAnchorFirst = m_pAnchor->GetFigData();
		}
		else if (m_bDroppingWheel)
		{
			CBasePiece** ppPiece = (m_pAnchor == NULL? &m_pAnchor : &m_pWheel);
			ASSERT(m_iPieceDropped >= 0 && m_iPieceDropped < TOTALWHEELS);
			pWheelDrop = new CWheel(CWheel::m_rgnRads[m_iPieceDropped],
								CWheel::m_rgco[m_iPieceDropped],
								CWheel::m_rgcoPattern[m_iPieceDropped]);
								

			ENSURE(pWheelDrop != NULL);
			ENSURE(*ppPiece == NULL);
			*ppPiece = pWheelDrop;
			m_bDroppingWheel = false;
			(*ppPiece)->SetPosition(point);

			if (m_pWheel != NULL)
			{
				m_pWheel->SetWheelMode();

				// set the default pen location. pDC and zoom ration are dummies
				m_pWheel->SetPenLocation(this, pDC, CPoint(0, 0), 1, 1);

				ENSURE(m_pAnchor != NULL);

				CPoint ptContact;
				double dAngle;
				// Get contact position from the anchor and set wheel position
				// Decides if wheel is internal in case of being a ring
				m_pAnchor->GetContactPosition(pointScaled, m_nZoomNumer, 
										m_nZoomDenom, ptContact, dAngle);
			
				if (m_pWheel->GetPerimeter() >= m_pAnchor->GetPerimeter())
				{
					pointScaled.x = 0;
					pointScaled.y = 0;   // force the wheel out of the ring

					// get contact position again to make sure it's right
					m_pAnchor->GetContactPosition(pointScaled, m_nZoomNumer, 
											m_nZoomDenom, ptContact, dAngle);
				}

 				m_pWheel->SetPosition(ptContact, dAngle);
				m_dDataWheelFirst = m_pWheel->GetFigData();
				m_ptWheelPosFirst = m_pWheel->m_ptPos;
				PressButton(0);  // get the color settings for the new wheel
				CreateFigure();
			}

			m_iPieceDropped += TOTALRINGS + 1;
#ifdef _DEBUG
			int nID = pFrame->m_wndToolBarSpiro.GetItemID(m_iPieceDropped);
			ASSERT(nID >= ID_ENORMOUSWHEEL && nID <= ID_TINYWHEEL);
#endif
		}

		// uncheck the button used to select the piece in the toolbar
		UINT nButtonID = pFrame->m_wndToolBarSpiro.GetItemID(m_iPieceDropped);
		pFrame->m_wndToolBarSpiro.GetToolBarCtrl().CheckButton(nButtonID, FALSE);

//.........这里部分代码省略.........
开发者ID:Jinjiego,项目名称:VCSamples,代码行数:101,代码来源:spiroView.cpp

示例8: OnOptPrint

void CMainFrame::OnOptPrint()
{
	CPrintDialog dlg(FALSE);
	if (IDOK!=dlg.DoModal())
	{
		return;
	}

	HDC hdcPrinter = dlg.GetPrinterDC();
	if (hdcPrinter == NULL){
		MessageBox("无法找到打印机",NULL,MB_OK|MB_ICONSTOP);
	}else{
		CDC dcPrinter;
		dcPrinter.Attach(hdcPrinter);

		// call StartDoc() to begin printing
		DOCINFO docinfo;
		memset(&docinfo, 0, sizeof(docinfo));
		docinfo.cbSize = sizeof(docinfo);
		docinfo.lpszDocName = "事件记录报表";

		// if it fails, complain and exit gracefully
		if (dcPrinter.StartDoc(&docinfo) < 0){
			MessageBox("无法初始化打印机",NULL,MB_OK|MB_ICONSTOP);
		}else{
			dcPrinter.SetMapMode(MM_TWIPS);
			CFont *pOldFont;
			CFont fnt;
			if(fnt.CreatePointFont(70,"宋体",&dcPrinter)){
				pOldFont=(CFont*)dcPrinter.SelectObject(&fnt);                  
			}else{
				pOldFont=(CFont*)dcPrinter.SelectStockObject(DEVICE_DEFAULT_FONT);
			}
			CPoint pt(dcPrinter.GetDeviceCaps(HORZRES),dcPrinter.GetDeviceCaps(VERTRES));
			dcPrinter.DPtoLP (&pt);
			pt.y=-pt.y;
			CSize sz=dcPrinter.GetTextExtent("序号   ");
			CSize sz1=dcPrinter.GetTextExtent("报警时间                          ");
			CSize sz2=dcPrinter.GetTextExtent("变量名                            ");
			CSize sz3=dcPrinter.GetTextExtent("变量描述                                     ");
			CSize sz4=dcPrinter.GetTextExtent("报警时测量值  ");
			CSize sz5=dcPrinter.GetTextExtent("单位   ");
			CSize sz6=dcPrinter.GetTextExtent("报警类型   ");
			CSize sz7=dcPrinter.GetTextExtent("状态   ");
			int lineHeight=sz.cy*1.5;
			int lineCount=(pt.y-sz.cy*10)/lineHeight;
			if(lineCount<0) return;
			long id=0;
			CString str;
			int i,iPage=0;
			int cLeftGap=800;
			while(evtsList[id].valid){
				// start a page
				if (dcPrinter.StartPage() < 0){
					MessageBox("无法初始化页",NULL,MB_OK|MB_ICONSTOP);
					dcPrinter.AbortDoc();
				}else{
					// actually do some printing
					//print title
					iPage++;
					str.Format("事件记录报表 第%2d页",iPage);
					dcPrinter.TextOut(cLeftGap,-lineHeight*3,str);
					//str.Format("序号  事件");
					str.Format("序号");
					dcPrinter.TextOut(cLeftGap,-lineHeight*5,str);
					str.Format("报警时间");
					dcPrinter.TextOut(cLeftGap+sz.cx,-lineHeight*5,str);
					str.Format("变量名");
					dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx,-lineHeight*5,str);
					str.Format("变量描述");
					dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx,-lineHeight*5,str);
					str.Format("报警时测量值");
					dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx,-lineHeight*5,str);
					str.Format("单位");
					dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx,-lineHeight*5,str);
					str.Format("报警类型");
					dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx+sz5.cx,-lineHeight*5,str);
					str.Format("状态");
					dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx+sz5.cx+sz6.cx,-lineHeight*5,str);
					for(i=0;i<lineCount;i++){
						if(evtsList[id].valid){
							CArgs args;
							parse_arg_ey(evtsList[id].data, &args, ";");
							str.Format("%3d",id);
							dcPrinter.TextOut(cLeftGap,-lineHeight*(6+i),str);
							str.Format("%s",args.argv[0]);
							dcPrinter.TextOut(cLeftGap+sz.cx,-lineHeight*(6+i),str);
							str.Format("%s",args.argv[2]);
							dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx,-lineHeight*(6+i),str);
							str.Format("%s",args.argv[1]);
							dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx,-lineHeight*(6+i),str);
							str.Format("%s",args.argv[6]);
							dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx,-lineHeight*(6+i),str);
							str.Format("%s",args.argv[7]);
							dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx,-lineHeight*(6+i),str);
							str.Format("%s",args.argv[4]);
							dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx+sz5.cx,-lineHeight*(6+i),str);
							str.Format("%s",args.argv[5]);
							dcPrinter.TextOut(cLeftGap+sz.cx+sz1.cx+sz2.cx+sz3.cx+sz4.cx+sz5.cx+sz6.cx,-lineHeight*(6+i),str);
							id++;
//.........这里部分代码省略.........
开发者ID:george-kuo,项目名称:GoSysWare,代码行数:101,代码来源:MainFrm.cpp

示例9: TargetOpenDocument

BOOL CTextureDoc::TargetOpenDocument(LPCTSTR lpszPathName, bool isOnlyForThumbnail) 
{
	CString message;
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	
	bool loadedTexture = false;
	CHashString hashName(lpszPathName);
	static DWORD msgHash_SetLoadParameters = CHashString(_T("SetLoadParameters")).GetUniqueID();
	LOADPARAMETERS lp1;

	if (!isOnlyForThumbnail)
	{
		m_pTextureObject = CRenderObject<>::LoadTexture(lpszPathName);
	}
	else
	{
		TEXTUREOBJECTPARAMS top;
		top.Name = &hashName;
		static DWORD msgHash_GetTexture = CHashString(_T("GetTexture")).GetUniqueID();
		m_ToolBox->SendMessage(msgHash_GetTexture, sizeof(TEXTUREOBJECTPARAMS), &top);

		if (top.TextureObjectInterface == NULL)
		{
			static DWORD msgHash_GetLoadParameters = CHashString(_T("GetLoadParameters")).GetUniqueID();
			m_ToolBox->SendMessage(msgHash_GetLoadParameters, sizeof(LOADPARAMETERS), &lp1);

			LOADPARAMETERS lp2(TEX_MEM_SYSMEM);
			m_ToolBox->SendMessage(msgHash_SetLoadParameters, sizeof(LOADPARAMETERS), &lp2);
			m_pTextureObject = CRenderObject<>::LoadTexture(lpszPathName);
			loadedTexture = true;
		}
		else
		{
			m_pTextureObject = top.TextureObjectInterface;
		}
	}

	if (loadedTexture)
		m_ToolBox->SendMessage(msgHash_SetLoadParameters, sizeof(LOADPARAMETERS), &lp1);

	CRect tRect(0, 0, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
	CDC tDC;
	CBitmap *oldBitmap;
	CRgn ClipRgn;
	CDC scrDC;
	
	scrDC.Attach(GetDC(GetDesktopWindow()));

	ClipRgn.CreateRectRgn(tRect.left, tRect.top, tRect.right, tRect.bottom);

	tDC.CreateCompatibleDC(&scrDC);
	
	tDC.SetMapMode(scrDC.GetMapMode());

	tDC.DPtoLP(&tRect);
	tDC.SetWindowExt(tRect.Size());
	tDC.SetWindowOrg(tRect.left, tRect.top);

	tDC.LPtoDP(&tRect);
	tDC.SetViewportExt(tRect.Size());
	tDC.SetViewportOrg(tRect.left, tRect.top);

	m_ThumbNail.CreateCompatibleBitmap(&scrDC, tRect.Width(), tRect.Height());
	oldBitmap = tDC.SelectObject(&m_ThumbNail);

	tDC.FillSolidRect(tRect, RGB(0xff, 0x00, 0x00));
	// create a thumbnail
	CTextureView::RenderImage(&tDC, this, tRect);

	tDC.SelectObject(oldBitmap);
	if (m_pTextureObject != NULL)
		GetFileTitle(m_pTextureObject->GetTextureName()->GetString(), m_DisplayName.GetBuffer(_MAX_FNAME), _MAX_FNAME);
	
	if (loadedTexture)
	{
		static DWORD msgHash_RemoveTexture = CHashString(_T("RemoveTexture")).GetUniqueID();
		TEXTUREOBJECTPARAMS top;
		top.Name = &hashName;
		top.TextureObjectInterface = m_pTextureObject;
		m_ToolBox->SendMessage(msgHash_RemoveTexture, sizeof(TEXTUREOBJECTPARAMS), &top);
	}

	m_DisplayName.ReleaseBuffer();

	// made it this far so add to program list of objects
	//SINGLETONINSTANCE(CTextureEditor)->GetTextureDataList()->push_back(m_TextureObject);

	//OBJECTPAGEINFO objPageInfo;
	//objPageInfo.name = &m_DisplayName;
	//objPageInfo.thumbNail = &m_ThumbNail;
	//objPageInfo.pageIndex = SINGLETONINSTANCE(CTextureEditor)->m_PageIndex;
	//objPageInfo.rsrcIndex = m_ObjectIndex;
	//objPageInfo.object = m_TextureObject;
	//static DWORD msgHash_AddObjectMessage = CHashString(_T("AddObjectMessage")).GetUniqueID();
	//m_ToolBox->SendMessage(msgHash_AddObjectMessage, sizeof(OBJECTPAGEINFO), &objPageInfo);
	return TRUE;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:98,代码来源:TextureDoc.cpp


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