Printing Views Derived from CFormView
Vinay Desai -- Vinay.Desai@americas.nycomed.com
Sunday, February 09, 1997
Environment: Visual C++ 4.2b, NT4.0 SP2, HotFix
I have written an application that uses a view class derived from
CFormView. The derived view uses a CListCtrl control.
Unresolved issue: I have been unable to print this view. Basically my
calls to the Framework supplied print support results in the display of a
blank screen. Attempts at using pWnd->Print(pDC, PRF_CHILDREN)
results in a Assertion Failure (see code snippets below) or a blank page.
I can print this derived view using CDC::BitBlt, but there has got to be a
better way. The VIEWEX sample code that is supposed to contain code
for printing from a CFormView, doesn't contain any such code. I have
searched the contents of Microsoft Technet (Feb '97 CD) and Microsoft
MSDN (Web) for sample code but haven't come up with a sample yet. No
info was obtained in Scott Wingo's MC FAQ either. A post to
comp.os.ms-windows.programmer.tools.mfc has yet to be answered,
although I have seen similar questions posed to the same group.
-------------------------------------------
void CElemPropView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// CElemPropView is a derived view from CFormView
// IDD_MYFORM is the dialog template resource for the derived view
CFormView::OnPrint(pDC,pInfo);
CElemPropView * pWnd = (CElemPropView*) GetDlgItem(IIDD_MYFORM);
ASSERT(pWnd!=NULL); // ASSERTION Failure
pWnd->Print(pDC,PRF_CLIENT);
}
if I try the following,
void CElemPropView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// CElemPropView is a derived view from CFormView
// IDD_MYFORM is the dialog template resource for the derived view
CFormView::OnPrint(pDC,pInfo);
CElemPropView * pWnd = this;
ASSERT(pWnd!=NULL); // ASSERTION Successful but blank page printed
pWnd->Print(pDC,PRF_CLIENT);
}
Any suggestions or tips are welcome.
Vinay Desai, Ph.D.
email:Vinay.Desai@Americas.Nycomed.com
Paul Gerhart -- pgerhart@voicenet.com
Sunday, February 09, 1997
Vinay Desai wrote:
>
> Environment: Visual C++ 4.2b, NT4.0 SP2, HotFix
>
> I have written an application that uses a view class derived from
> CFormView. The derived view uses a CListCtrl control.
I have an app just the same (CFormView uses a CListCtrl control).
The base class wont do this automatically - you must extract the cells
(rows) from the CListCtrl your self.
I think the Brain/Lovette book covers this well. I cloned their
approach.
If you need a code snippet, email me back.
--
#########################
# Paul Gerhart #
# pgerhart@voicenet.com #
#########################
Become an MFC-L member
| Вернуться в корень Архива
|