⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_60959.htm

📁 vc
💻 HTM
字号:
<p>
序号:60959 发表者:夏雪宜 发表日期:2003-11-17 10:14:15
<br>主题:如何做打印程序?
<br>内容:我想做一个打印程序。我的视图是分割成两个窗口,分别对应于两个视图,现在我在其中的一个视图中想写打印程序,但是不知道OnFilePrint和OnFilePrintPreview(对应于工具条上的两个按钮)这两个函数和OnPrint、OnPreparePrinting、OnEndPrintPreview、OnEndPrinting等函数的调用关系如何?我现在这个分割视图中的一个视类中映射了OnPrint、OnPreparePrinting、OnEndPrintPreview、OnEndPrinting这些虚函数,但当我按打印按钮并不执行我OnPrint、OnPreparePrinting中写的程序啊?这是为什么?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:夏雪宜 回复日期:2003-11-17 10:16:36
<br>内容:我看了技术内幕上的打印程序,他好像没有映射OnFilePrint和OnFilePrintPreview两个函数,但直接可以调用OnPrint、OnPreparePrinting、OnEndPrintPreview、OnEndPrinting等须函数。
<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-11-17 10:37:04
<br>内容:我看了深入浅出mfc中写的是在OnFIleOpen()中调用了OnPrint、OnPreparePrinting、OnEndPrintPreview、OnEndPrinting等需函数,我现在有点不明白为什么我将视图分割后在分割视类中映射的OnFileOpen为什么不调用上面OnPrint、OnPreparePrinting、OnEndPrintPreview、OnEndPrinting等须函数?
<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>回复者:ohye212 回复日期:2003-11-17 10:42:53
<br>内容:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CCreateContext cct;<BR>&nbsp;&nbsp;&nbsp;&nbsp;cct.m_pCurrentDoc=NULL;<BR>&nbsp;&nbsp;&nbsp;&nbsp;cct.m_pCurrentFrame=NULL;<BR>&nbsp;&nbsp;&nbsp;&nbsp;cct.m_pLastView=NULL;<BR>&nbsp;&nbsp;&nbsp;&nbsp;cct.m_pNewViewClass=RUNTIME_CLASS(printview);&nbsp;&nbsp;//printview是新建的View 的类名<BR>&nbsp;&nbsp;&nbsp;&nbsp;pNew=(printview*)(printwnd-&gt;CreateView(&amp;cct)); //CFrameWnd * printwnd&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(!pNew)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(&#34;print error!&#34;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return FALSE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;pNew-&gt;ShowWindow(SW_HIDE);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;pNew-&gt;viewPrint();<BR><BR><BR><BR>void printview::viewPrint() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CView::OnFilePrint();&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR>void printview::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;CView::OnBeginPrinting(pDC, pInfo);<BR>}<BR><BR>void printview::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo) <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;CView::OnEndPrinting(pDC, pInfo);<BR>}<BR><BR> <BR><BR>BOOL printview::OnPreparePrinting(CPrintInfo* pInfo) <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; int m_ntotlepage=3;<BR>&nbsp;&nbsp;&nbsp;&nbsp;int currentpage=0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;pInfo-&gt;SetMaxPage(m_ntotlepage);&nbsp;&nbsp;&nbsp;&nbsp;//设置总共打印页数<BR>&nbsp;&nbsp;&nbsp;&nbsp;return CView::DoPreparePrinting(pInfo);/////////////////在默认的基础上有改变!!!<BR>}<BR><BR>void printview::OnPrint(CDC* pDC, CPrintInfo* pInfo) <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; currentpage=pInfo-&gt;m_nCurPage;&nbsp;&nbsp;&nbsp;&nbsp; //改变当前页<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;CView::OnPrint(pDC, pInfo);<BR>}<BR>void printview::OnDraw(CDC* pDC)<BR>{<BR>//根据当前页currentpage显示数据<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-11-17 10:48:13
<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 + -