Graphen drucken

weicor

Grünschnabel
Hallo!
Ich braüchte etwas Hilfe. Ich habe eine MFC Anwendung geschrieben, die Graphen darstellt. Jetzt möchte ich nur noch die Graphen auch drucken können, das macht es ja auch, nur viel zu klein.
Wie vergrößere ich das Druckbild?
 
Guter Vorschlag, Danke! Aber wie mach ich das? Hab nicht so die Ahnung davon!
Würde mich freuen wenn du mir das erklären könntest!
 
Also im Moment hab ich nur die zwei Funktionen eingefügt:

BOOL CVGraphicView::OnPreparePrinting(CPrintInfo* pInfo)
{
pInfo->SetMaxPage(1);
return DoPreparePrinting(pInfo);
}

void CVGraphicView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 1000;
SetScrollSizes(MM_LOENGLISH, sizeTotal);
OnDraw(pDC);
}
 
da ich selber nicht weiss, wie man das am besten löst, habe ich mal herumgesucht. Bei der MSDN Lib beim Thema CPrintInfo das Beispiel DIBLOOK angeben. Ich habe mir das mal angesehen und folgende interessante Routine entdeckt:
Code:
void CDibView::OnDraw(CDC* pDC)
{
	CDibDoc* pDoc = GetDocument();

	HDIB hDIB = pDoc->GetHDIB();
	if (hDIB != NULL)
	{
		LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
		int cxDIB = (int) ::DIBWidth(lpDIB);         // Size of DIB - x
		int cyDIB = (int) ::DIBHeight(lpDIB);        // Size of DIB - y
		::GlobalUnlock((HGLOBAL) hDIB);
		CRect rcDIB;
		rcDIB.top = rcDIB.left = 0;
		rcDIB.right = cxDIB;
		rcDIB.bottom = cyDIB;
		CRect rcDest;
		if (pDC->IsPrinting())   // printer DC
		{
                        /// Ab hier wird's interessant! 
                        /// (Wird für Druck aufgerufen)
    

			// get size of printer page (in pixels)
			int cxPage = pDC->GetDeviceCaps(HORZRES);
			int cyPage = pDC->GetDeviceCaps(VERTRES);
			// get printer pixels per inch
			int cxInch = pDC->GetDeviceCaps(LOGPIXELSX);
			int cyInch = pDC->GetDeviceCaps(LOGPIXELSY);

			//
			// Best Fit case -- create a rectangle which preserves
			// the DIB's aspect ratio, and fills the page horizontally.
			//
			// The formula in the "->bottom" field below calculates the Y
			// position of the printed bitmap, based on the size of the
			// bitmap, the width of the page, and the relative size of
			// a printed pixel (cyInch / cxInch).
			//
			rcDest.top = rcDest.left = 0;
			rcDest.bottom = (int)(((double)cyDIB * cxPage * cyInch)
					/ ((double)cxDIB * cxInch));
			rcDest.right = cxPage;
		}
		else   // not printer DC
		{
			rcDest = rcDIB;
		}
		::PaintDIB(pDC->m_hDC, &rcDest, pDoc->GetHDIB(),
			&rcDIB, pDoc->GetDocPalette());
	}
}
Hilft dir das weiter? Ich kann dir das Beispielprojekt schicken, falls du es nicht ohnehin schon angesehen hast.
 
Vielen Dank! Ich werds mir ansehen und ausprobieren. Wenn du mir das Beispiel schicken könntest wär auch nicht schlecht.
 
Zurück