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

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


Printing a CFormView?

Michael C. Irvin -- M.Irvin@dialogic.com
Wednesday, April 17, 1996

Environment:  VC++ 4.0 / Windows NT 4.0 Beta 1

Hello Everyone,

I'm fairly new to MFC programming, but I have been doing a lot
of reading (Inside Visual C++ Version 4 -- Kruglinski) and I
have gotten thru 17 chapters.  I have just finished reading
the chapter on printing and the steps needed to complete this.
However, I am kind of at a loss as how to print controls in
a CFormView to a printer.  As the framework takes care of 
almost everything in this type of view, I assume that something
would need to be overwritten (OnPrint/OnPrepareDC...) but I
wouldn't know what to even do in the OnPrint to "draw" a
control.

As of right now, I have some edit controls placed in a
CFormView and I am sure that would be able to respond to
OnPrint() messages, but how does one "tell" a control
to "draw" itself with the given CDC?  I guess there is
the possibility that I would need to either "translate"
what the controls would look like via simple drawing
commands, or I could possibly try to do a window capture
into a bitmap to be printed.

Any comments or suggestions would be appretiated.

Thanks in advance,
MCI

--
Dialogic\Dialogic\Dialogic\Dialogic\Dialogic\Dialogic\Dialogic\Dialogi
|    Michael C. Irvin -- Software Engineer -- M.Irvin@Dialogic.com   c
c   "If I could only reach that dial inside and turn it up" -- Rush  |
igolaiD/cigolaiD/cigolaiD/cigolaiD/cigolaiD/cigolaiD/cigolaiD/cigolaiD




Don Booth -- Don@donbooth.demon.co.uk
Sunday, April 21, 1996

> 
> Hello Everyone,
> 
> I'm fairly new to MFC programming, but I have been doing a lot
> of reading (Inside Visual C++ Version 4 -- Kruglinski) and I
> have gotten thru 17 chapters.  I have just finished reading
> the chapter on printing and the steps needed to complete this.
> However, I am kind of at a loss as how to print controls in
> a CFormView to a printer.  As the framework takes care of 
> almost everything in this type of view, I assume that something
> would need to be overwritten (OnPrint/OnPrepareDC...) but I
> wouldn't know what to even do in the OnPrint to "draw" a
> control.
> 
> As of right now, I have some edit controls placed in a
> CFormView and I am sure that would be able to respond to
> OnPrint() messages, but how does one "tell" a control
> to "draw" itself with the given CDC?  I guess there is
> the possibility that I would need to either "translate"
> what the controls would look like via simple drawing
> commands, or I could possibly try to do a window capture
> into a bitmap to be printed.
> 
> Any comments or suggestions would be appretiated.
> 
> Thanks in advance,
> MCI
> 
> --

There is a sample called VIEWEX (in Visual C++ V1.0 only) that demonstrates a
simple technique to print a CFormView.  Basically you navigate all the controls
in the formview and send them a WM_PAINT message in your CFormView::OnPrint 
overide.  The sample was withdrawn in releases after V1.0 because this
technique does not work for all controls but is OK for the edit controls
you have.


-- 
Don Booth       INTERNET: don@donbooth.demon.co.uk

PGP public key available : mail me with subject GET KEY




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