自定义打印预览 [英] Customizing print preview

查看:81
本文介绍了自定义打印预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我有一个任务,在打印预览中嵌入一个对话框,在VS2008 MFC应用程序(带功能包,MDI)中,对话框在以前的VC6项目中运行良好。我已应用相同的技术:


TN030:自定义打印和打印预览


问题在于我的自定义对话框在实际打印预览中不可见...我不知道为什么...当然,我在互联网上搜索了嵌入自定义对话框的示例,在MFC功能包中......我没有找到任何样本......
这里是在我的app中启动PP的代码:

 void CMyScrollView :: OnFilePrintPreview()
{
// TODO:在这里添加命令处理程序代码

CPrintPreviewState * pState = new CPrintPreviewState;

if(!DoPrintPreview(IDD_DIALOGBAR_PRINTPREVIEW,this,RUNTIME_CLASS(CPreviewViewExt),pState))
{
TRACE0(" Error:OnFileImprovedprintpreview failed.\ n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
删除pState; //预览无法初始化,现在删除状态
pState = NULL;
}
}




原始预览正在开始,但我看不到内部的对话框...为什么?你能帮助我吗 ?谢谢。

解决方案


感谢您在此处发布。


>>正在开始预览,但我看到里面没有对话框...为什么?你能帮助我吗 ?谢谢。


DoPrintPreview将隐藏应用程序的主窗格。控制条(例如状态栏)可以通过在pState-> dwStates成员中指定它们来保留(这是一个位掩码,各个控制条的位由AFX_CONTROLBAR_​​MASK(
AFX_IDW_MYBAR)定义)。窗口pState-> nIDMainPane是将自动隐藏和重新显示的窗口。然后,DoPrintPreview将为标准预览UI创建一个按钮栏。如果需要特殊窗口处理,例如隐藏或显示其他窗口,则应在调用DoPrintPreview之前完成


默认情况下,当打印预览完成时,它返回控制栏到其原始状态,主窗格可见。如果需要特殊处理,则应在EndPrintPreview的覆盖中完成。如果DoPrintPreview失败,还提供特殊的
处理。


最好的问候,


Sera Yu


<强>


Hi. I have an task, to embeed an dialogbar in print-preview, in an VS2008 MFC app (with feature pack, MDI), dialogbar which is working well in an former VC6 project. I have applied the same tehnique:

TN030: Customizing Printing and Print Preview

The problem is that my custom dialogbar isn't visible in actual print preview ... and I don't know why ... of course, I have searched on internet the samples that embeed an custom dialogbar, in MFC feature pack ... and I didn't found any sample ... here is the code which start the PP in my app:

void CMyScrollView::OnFilePrintPreview() 
{
	// TODO: Add your command handler code here

	CPrintPreviewState* pState = new CPrintPreviewState;

	if(! DoPrintPreview(IDD_DIALOGBAR_PRINTPREVIEW, this, RUNTIME_CLASS(CPreviewViewExt), pState))
	{
		TRACE0("Error: OnFileImprovedprintpreview failed.\n");
		AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
		delete pState;      // preview failed to initialize, delete State now
		pState = NULL;
	}
}


the prin preview is starting, but I see no dialogbar inside ... why ? Can you help me ? Thanks.

解决方案

Hi,

thanks for posting here.

>>the prin preview is starting, but I see no dialogbar inside ... why ? Can you help me ? Thanks.

DoPrintPreview will hide the main pane of the application. Control Bars, such as the status bar, can be retained by specifying them in the pState->dwStates member (This is a bit mask and the bits for individual control bars are defined by AFX_CONTROLBAR_MASK( AFX_IDW_MYBAR)). The window pState->nIDMainPane is the window that will be automatically hidden and reshown. DoPrintPreview will then create a button bar for the standard Preview UI. If special window handling is needed, such as to hide or show other windows, that should be done before DoPrintPreview is called.

By default, when print preview finishes, it returns the control bars to their original states and the main pane to visible. If special handling is needed, it should be done in an override of EndPrintPreview. If DoPrintPreview fails, also provide special handling.

Best Regards,

Sera Yu


这篇关于自定义打印预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆