Printing a CTreeView
Adam Partridge -- AdamP@abcsystems.com
Wednesday, July 10, 1996
MFC 4.1/WIN 95
I have a SDI app with a single view (a CTreeView). I want the user to
be able to print and print-preview the CTreeView, my question is simple.
How do I do this?
satish_elnet@mail.cswl.com
Monday, July 15, 1996
[Mini-digest: 2 responses]
MFC 4.1/WIN 95
I have a SDI app with a single view (a CTreeView). I want the user to
be able to print and print-preview the CTreeView, my question is simple.
How do I do this?
Its very simple to do.
Overide OnPrint function of CTreeView and do the following:-
YourView::OnPrint(CDC* pDC,CPrintInfo* pInfo)
{
CClientDC dcScreen(NULL);
pDC->SetMapMode(MM_ANISOTROPIC);
//map 1 screen logical inch to 1 printer.
pDC->SetWindowExt(dcScreen.GetDeviceCaps(LOGPIXELSX),
dcScreen.GetDeviceCaps(LOGPIXELSX));
pDC->SetViewPortExt(pDC->GetDeviceCaps(LOGPIXELSX),
pDC->GetDeviceCaps(LOGPIXELSX));
CPen pen(PS_SOLID,1,RGB(0,0,0));
CPen* OldPen = pDC->SelectObject(&pen);
SendMessage(WM_PAINT,(WPARAM)pDC->m_hDC);
pDC->SelectObject(OldPen);
}
The above code does what you needed.
rgds,
satish_elnet@cswl.com
-----From: Alberto Massari
At 16.45 10/07/96 -0000, you wrote:
>MFC 4.1/WIN 95
>I have a SDI app with a single view (a CTreeView). I want the user to
>be able to print and print-preview the CTreeView, my question is simple.
>How do I do this?
Override OnDraw in that way
void CMyView::OnDraw(CDC* pDC)
{
if(pDC->IsPrinting())
{
GetTreeCtrl()->SendMessage(WM_PAINT,(WPARAM)pDC->m_hDC,0);
}
}
Alberto
----------------------------
|\ _,,,--,,_
/,`.-'`' ._ \-;;,_
|,4- ) )_ .;.( `'-'
'---''(_/._)-'(_\_)
------------------------------------------------------------------
Alby@MusArt.dist.unige.it is: Alberto Massari
Laboratorio di Informatica Musicale
D.I.S.T. Dipartimento di Informatica, Sistemistica e Telematica
Universita' di Genova
Via all'Opera Pia 13,
I - 16145 Genova ITALIA http://MusArt.dist.unige.it/~alby/
------------------------------------------------------------------
| Вернуться в корень Архива
|