📄 subject_60959.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> CCreateContext cct;<BR> cct.m_pCurrentDoc=NULL;<BR> cct.m_pCurrentFrame=NULL;<BR> cct.m_pLastView=NULL;<BR> cct.m_pNewViewClass=RUNTIME_CLASS(printview); //printview是新建的View 的类名<BR> pNew=(printview*)(printwnd->CreateView(&cct)); //CFrameWnd * printwnd <BR> if(!pNew)<BR> {<BR> AfxMessageBox("print error!");<BR> return FALSE;<BR> }<BR> pNew->ShowWindow(SW_HIDE);<BR><BR> pNew->viewPrint();<BR><BR><BR><BR>void printview::viewPrint() <BR>{<BR> CView::OnFilePrint(); <BR>}<BR><BR>void printview::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) <BR>{<BR> <BR> CView::OnBeginPrinting(pDC, pInfo);<BR>}<BR><BR>void printview::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo) <BR>{<BR> <BR> CView::OnEndPrinting(pDC, pInfo);<BR>}<BR><BR> <BR><BR>BOOL printview::OnPreparePrinting(CPrintInfo* pInfo) <BR>{<BR> int m_ntotlepage=3;<BR> int currentpage=0;<BR> pInfo->SetMaxPage(m_ntotlepage); //设置总共打印页数<BR> return CView::DoPreparePrinting(pInfo);/////////////////在默认的基础上有改变!!!<BR>}<BR><BR>void printview::OnPrint(CDC* pDC, CPrintInfo* pInfo) <BR>{<BR> currentpage=pInfo->m_nCurPage; //改变当前页<BR><BR> 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 + -