From: ybc on
Hi,

I try to create a non-user interface program which gets file name from
command line, open and format the document, and print the labels. What
application framework can be used? How process print with MFC? Detailed
information is appreciated.

Thanks,

ybc

From: Joseph M. Newcomer on
You can directly invoke the Print Dialog using the flags to return the printer DC for the
default printer (no UI pops up); this is one of the most expedient ways of getting the
printer DC. Just give it a parent window handle of NULL. After that, it's just
programming. Use a console app, enable MFC in it if you want to use CString (for VS.NET,
I've not looked into what is involved to get just the CString components; maybe someone
can post an answer that avoids bringing the whole MFC runtime in...)
joe

On Wed, 26 Jul 2006 23:02:01 -0700, ybc <ybc(a)discussions.microsoft.com> wrote:

>Hi,
>
>I try to create a non-user interface program which gets file name from
>command line, open and format the document, and print the labels. What
>application framework can be used? How process print with MFC? Detailed
>information is appreciated.
>
>Thanks,
>
>ybc
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: ybc on
Hi Joe,
Thanks for your replay.
When I use CPrintDialog::CreatePrinterDC() to return a handle of DC it's a
HDC type, how to get a handle of CDC type so I can use its StartDC() and
StartPage() functions?
Thanks,
ybc

"Joseph M. Newcomer" wrote:

> You can directly invoke the Print Dialog using the flags to return the printer DC for the
> default printer (no UI pops up); this is one of the most expedient ways of getting the
> printer DC. Just give it a parent window handle of NULL. After that, it's just
> programming. Use a console app, enable MFC in it if you want to use CString (for VS.NET,
> I've not looked into what is involved to get just the CString components; maybe someone
> can post an answer that avoids bringing the whole MFC runtime in...)
> joe
>

From: Joseph M. Newcomer on
CDC dc;
dc.Attach(handle_of_dc)

when the CDC leaves scope, the DC will be released.
joe

On Thu, 27 Jul 2006 22:48:01 -0700, ybc <ybc(a)discussions.microsoft.com> wrote:

>Hi Joe,
>Thanks for your replay.
>When I use CPrintDialog::CreatePrinterDC() to return a handle of DC it's a
>HDC type, how to get a handle of CDC type so I can use its StartDC() and
>StartPage() functions?
>Thanks,
>ybc
>
>"Joseph M. Newcomer" wrote:
>
>> You can directly invoke the Print Dialog using the flags to return the printer DC for the
>> default printer (no UI pops up); this is one of the most expedient ways of getting the
>> printer DC. Just give it a parent window handle of NULL. After that, it's just
>> programming. Use a console app, enable MFC in it if you want to use CString (for VS.NET,
>> I've not looked into what is involved to get just the CString components; maybe someone
>> can post an answer that avoids bringing the whole MFC runtime in...)
>> joe
>>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: David Ching on

"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:odikc257ni90u0me7vbo41hdntsqa3p7bf(a)4ax.com...
> CDC dc;
> dc.Attach(handle_of_dc)
>
> when the CDC leaves scope, the DC will be released.
> joe
>

Or:

CDC *pDC = CDC::FromHandle (handle_of_dc);

-- David