15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Printing/MFC

David Little -- dlittle@equinoxcorp.com
Friday, November 01, 1996

Environment: Windows 95, Visual C++ 4.1

I have an existing app (DOS FORTRAN) which prints some reports, and a
CView SDI class to handle the printing.  I have a problem printing more 
than one page.  I can calculate when it is time to change pages, but the 
usual call to EndPage/StartPage always fails.  It is impossible to
calculate the length of the report prior to actually printing it, and it
is equally impossible to use the OnPrepareDC/OnPrint/OnPrepareDC loop. 

Any suggestions would be GREATLY appreciated.

Thanks!
David




Eric L. Hedegaard -- erich@peoplefirst.com
Monday, November 04, 1996

[Mini-digest: 2 responses]

David Little wrote:
> 
> Environment: Windows 95, Visual C++ 4.1
> 
> I have an existing app (DOS FORTRAN) which prints some reports, and a
> CView SDI class to handle the printing.  I have a problem printing more
> than one page.  I can calculate when it is time to change pages, but the
> usual call to EndPage/StartPage always fails.  It is impossible to
> calculate the length of the report prior to actually printing it, and it
> is equally impossible to use the OnPrepareDC/OnPrint/OnPrepareDC loop.
> 
> Any suggestions would be GREATLY appreciated.
> 
> Thanks!
> David

David,

I don't fully understand how you are trying to print your report, but as
I understand it the StartPage/EndPage sequence is called automatically
for you if you are using the MFC printing architecture.  StartPage() is
called after the first return from OnPrepareDC() (in Windows95) and
EndPage() is called after the return from OnPrint().  Is it possible
that your explicit calling of these functions conflicts with what the
MFC architecture is doing?

I'm certainly no expert on printing in Windows, but a couple of projects
I am currently working on require printed reports to be produced.  In my
case I have a third party library function which produces a
human-readable report from a binary data-file.  I temporarily store the
report data in a memory buffer and print it using CDC::DrawText()(not
the best way but it was a quick-and-dirty way to get the job done). 
When I have printed the last page I set CPrintInfo::m_bContinuePrinting
to FALSE in OnPrint() to terminate the process.

There is an excellent article by Jeff Prosise in the April 1996 issue of
the Microsoft Systems Journal titled "Programming Windows 95 with MFC,
Part VIII:  Printing and Print Previewing".  It has helped me quite a
bit with my current projects.  If you haven't already read it you might
want to try to find a copy.  There may be additional information which
could be of use to you.

Sincerely,

Eric L. Hedegaard
PeopleFirst Finance, LLC
-----From: dima@ssm6000.samsung.ru (Dulepov Dmitry)

        [Mailer: "Groupware E-Mail". Version 1.01.035]


There are two ways I used:

1. You will need to override CYourView::OnFilePrint() and do all pr=
inting yourself. Copy necessary code from from Viewprnt.cpp in MFC'=
s source directory.

2. Use standard MFC, way but use CPrintInfo::SetMaxPage(0xFFFE) /* =
not 0xFFFF !!! */ and set CPrintInfo::m_bContinuePrinting to FALSE =
when you completed your work.
*** Note: If you use default printing implementation you cannot cal=
l StartPage()/EndPage() because MFC does it for you and second call=
s always will fail.


Both these ways work fine in my applications.

Hope, this help!


Dmitry A. Dulepov
Samsung Electronics Co., Ltd.
Russian Research Center
Phone: +7 (095) 213-9207
Fax: +7 (095) 213-9196
E-mail: dima@src.samsung.ru
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D





| Вернуться в корень Архива |