📄 subject_28381.htm
字号:
<p>
序号:28381 发表者:枫叶游子 发表日期:2003-01-21 06:08:07
<br>主题:求助:如何输出到打印机?
<br>内容:在VC console模式下编程,(不涉及MFC),用C++语言,<BR><BR>如何把结果(比方说一个数组吧)输出到打印机打印?<BR><BR>请哪位写几行代码供学习。<BR><BR>初学者的问题,先谢过
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:su_37 回复日期:2003-01-21 11:01:56
<br>内容:/*-------------------------------------------<BR> PRINT2.C -- Printing with Abort Procedure<BR> (c) Charles Petzold, 1998<BR> -------------------------------------------*/<BR><BR>#include <windows.h><BR><BR>HDC GetPrinterDC (void) ; // in GETPRNDC.C<BR>void PageGDICalls (HDC, int, int) ; // in PRINT.C<BR><BR>HINSTANCE hInst ;<BR>TCHAR szAppName[] = TEXT ("Print2") ;<BR>TCHAR szCaption[] = TEXT ("Print Program 2 (Abort Procedure)") ;<BR><BR>BOOL CALLBACK AbortProc (HDC hdcPrn, int iCode)<BR>{<BR> MSG msg ;<BR> <BR> while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))<BR> {<BR> TranslateMessage (&msg) ;<BR> DispatchMessage (&msg) ;<BR> }<BR> return TRUE ;<BR>}<BR><BR>BOOL PrintMyPage (HWND hwnd)<BR>{<BR> static DOCINFO di = { sizeof (DOCINFO), TEXT ("Print2: Printing") } ;<BR> BOOL bSuccess = TRUE ;<BR> HDC hdcPrn ;<BR> short xPage, yPage ;<BR> <BR> if (NULL == (hdcPrn = GetPrinterDC ()))<BR> return FALSE ;<BR> <BR> xPage = GetDeviceCaps (hdcPrn, HORZRES) ;<BR> yPage = GetDeviceCaps (hdcPrn, VERTRES) ;<BR> <BR> EnableWindow (hwnd, FALSE) ;<BR> <BR> SetAbortProc (hdcPrn, AbortProc) ;<BR> <BR> if (StartDoc (hdcPrn, &di) > 0)<BR> {<BR> if (StartPage (hdcPrn) > 0)<BR> {<BR> PageGDICalls (hdcPrn, xPage, yPage) ;<BR> <BR> if (EndPage (hdcPrn) > 0)<BR> EndDoc (hdcPrn) ;<BR> else<BR> bSuccess = FALSE ;<BR> }<BR> }<BR> else<BR> bSuccess = FALSE ;<BR> <BR> EnableWindow (hwnd, TRUE) ;<BR> DeleteDC (hdcPrn) ;<BR> return bSuccess ;<BR>}<BR>看看吧!!这是关于打印的列子
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:枫叶游子 回复日期:2003-01-21 11:32:49
<br>内容:谢谢。<BR>上机运行过吗?<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:su_37 回复日期:2003-01-21 14:43:14
<br>内容:这是书上的列子!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -