Re: Open, process & print documents without user interface
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 30 Jul 2006 20:43:16 -0400
My example came in the VS.NET 2003 MSDN
CPrintDialog::GetPrinterDC
Retrieves a handle to the printer device context.
HDC GetPrinterDC( ) const;
Return Value
A handle to the printer device context if successful; otherwise NULL.
Remarks
If the bPrintSetupOnly parameter of the CPrintDialog constructor was FALSE (indicating
that the Print dialog box is displayed), then GetPrinterDC returns a handle to the printer
device context. You must call the Windows DeleteDC function to delete the device context
when you are done using it.
Example
CPrintDialog dlg(FALSE);
if (dlg.DoModal() == IDOK)
{
// Get a handle to the printer device context (DC).
HDC hdc = dlg.GetPrinterDC();
ASSERT(hdc);
// Do something with the HDC...
// Clean up.
CDC::FromHandle(hdc)->DeleteDC();
}
On Sun, 30 Jul 2006 23:38:06 GMT, "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:
Joseph M. Newcomer [MVP]
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:k79qc2p15f7ensl4262jvbig0e89r8gref@xxxxxxxxxx
So the
question is, who has responsibility for the lifetime of the kernel object?
If you do,
then you must delete it, because it won't be deleted when a temporary
object is freed
during the OnIdle processing (the temporary object is seen as a proxy for
the kernel
object, which must remain untouched).
See the example shown under CPrintDialog::GetPrinterDC, which explicitly
illustrates the
need to delete the DC.
You're right about not using FromHandle() if you are responsible for
deleting the underlying GDI object. The CPrintDialog::GetPrinterDC() doc
doesn't say one way or the other if the returned HDC needs to be deleted. I
couldn't find any example in the MSDN that came with either VC6 or VC2003.
-- David
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Re: Open, process & print documents without user interface
- From: Joseph M . Newcomer
- Re: Open, process & print documents without user interface
- From: Joseph M . Newcomer
- Re: Open, process & print documents without user interface
- From: David Ching
- Re: Open, process & print documents without user interface
- From: Joseph M . Newcomer
- Re: Open, process & print documents without user interface
- From: David Ching
- Re: Open, process & print documents without user interface
- From: Joseph M . Newcomer
- Re: Open, process & print documents without user interface
- From: David Ching
- Re: Open, process & print documents without user interface
- Prev by Date: Re: CClientDC and TabCtrl ?
- Next by Date: Re: Access violation with CFtpFileFind ::FindFile
- Previous by thread: Re: Open, process & print documents without user interface
- Next by thread: Re: Open, process & print documents without user interface
- Index(es):
Relevant Pages
|