SHDocVW Internetexplorer PlugIn问题 - 取消事件 [英] Problem with SHDocVW Internetexplorer PlugIn - Cancel Event

查看:78
本文介绍了SHDocVW Internetexplorer PlugIn问题 - 取消事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在处理一些打印内容:

我必须使用样式表打印出几个.xml文件。

因此我通过SHDocVW选择Internetexplorer PlugIn。

我的问题:

通过ExecWB发送打印命令后

第一个.xml文件

预览或打印机选择窗口发生

(取决于传递的参数)。这种行为还可以。

但是:如果用户取消我不知道如何获得这个

事件,那么我将不会继续使用其他文件

打印。

有人有想法!?


我的实现基于以下文章:
http://msdn.microsoft.com/library/default.asp?

URL = / library / en-us / dnie55 / html / wb_print.asp

(使用Internet Explorer WebBrowser控件打印)

Hello,

I''m currently working on some printing stuff:
I have to print out several .xml files using a stylesheet.
Therefor I choose the Internetexplorer PlugIn via SHDocVW.
My problem:
After sending the print command via ExecWB for the
first .xml document either
the preview or the printer selection window occurs
(depending on the passed parameter). This behaviour is ok.
But: If the user cancels I do not know how to get this
event, so that I will no continue with the other documents
to print.
Someone has an idea!?

My implementation is based on the article:
http://msdn.microsoft.com/library/default.asp?
URL=/library/en-us/dnie55/html/wb_print.asp
(Printing with the Internet Explorer WebBrowser Control)

推荐答案

您好,


感谢您在小组中发帖。


根据我的理解,现在问题是:您使用网络浏览器控制

in a Windows窗体打印网页。现在您使用ExecWB打印xml

文件。但是,如果用户在打印机

选择/预览窗口中单击取消按钮,则需要在程序中跟踪此事件,因此

您不会继续打印其他xml文件,对吧?如果我在这里发现任何误解,请点击此处。


为了确保您的代码如何运作,请您发布您的主页

创建Web浏览器控件并在此处调用ExecWB的代码片段?获得它后,我们将进行研究并回复更多信息。


祝你好运,

Yanhong Huang

Microsoft在线合作伙伴支持


安全! - www.microsoft.com/security

此帖子原样是按原样提供的。没有保证,也没有授予任何权利。

Hello,

Thanks for posting in the group.

Based on my understanding, now the question is: You use Web browser control
in a Windows form to print a web page. Now you use ExecWB to print a xml
file. However, if the user clicks cancel button when in printer
selection/preview window, you want to track this event in the program so
that you won''t continue print other xml files, right? Please post here if I
have misunderstood anything here.

In order to make sure how you code works, could you please post your main
code slice on creating web browser control and calling ExecWB here? After
getting it, we will perform research and reply with more information here.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


你好黄,

是的,这是正确的。

这里你有部分代码(C#):


private void CFrmPrint_Activated(对象发送者,

System.EventArgs e )$ / b
对象nullObject = null;

this.Visible = false;

this.m_ieBrowser.Navigate (m_sDocument,ref nullObject,

ref nullObject,ref nullObject,ref nullObject);


}


private void m_ieBrowser_DocumentComplete(object sender,

AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)

{

timCheckBrowser_Tick(null,null);

}


private void timCheckBrowser_Tick(对象发件人,

System.EventArgs e)

{

object nullObject = null;

this.timCheckBrowser.Enabled = false;


while(m_ieBrowser.Busy)

{

System.Wi ndows.Forms.Application.DoEvents();

}


//设置页眉和页脚

//棘手:必须通过注册表完成,

//请参阅MSDN文章:

// http://msdn.microsoft.com/library/default.asp?

URL = / library / en-us / dnie55 / html / wb_print.asp


RegistryKey pRegKey = Registry.CurrentUser;


//创建:创建新的,或打开现有密钥!

pRegKey = pRegKey.CreateSubKey

(" Software \\ Microsrosoft \\Internet Explorer \\PageSetup");


//存储用于重置的实际页眉和页脚

Object oHeader = pRegKey.GetValue(" header");

Object oFooter = pRegKey.GetValue(" footer" ;);


pRegKey.SetValue(" header",m_sHeader);

pRegKey.SetValue(" footer",m_sFooter);


//打印方法

异常ex = null;

尝试

{

SHDocVw.OLECMDEXECOPT opt =

SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT;


//m_ieBrowser.ExecWB

(SHDocVw.OLECMDID .OLECMDID_H IDETOOLBARS,

// opt,ref nullObject,ref nullObject);


if(m_bPromptUser)

opt = SHDocVw.OLECMDEXECOPT .OLECMDEXECOPT_PROMPTUSER;

else

opt =

OHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER;


if(b) m_bPreview)

{

m_ieBrowser.ExecWB

(SHDocVw.OLECMDID.OLECMDID_PRINTPREVIEW,

opt,ref nullObject, ref

nullObject);

}

else

{

m_ieBrowser.ExecWB (SHDocVw.OLECMDID.OLECMDID_PRINT,

opt,ref nullObject,ref

nullObject);

}

系统.Threading.Thread.Sleep(100); //因为

重置页面布局!

/ *

System.Diagnostics.PerformanceCounter PC

= new System.Diagnostics.PerformanceCounter();

PC.CategoryName =" Prozess";

PC.CounterName =" Threadanzahl";

PC.InstanceName =" FestoEngineeringTool";

m_ThreadCount =(int)PC.NextValue();

* /

}

catch(exception ex1){ex = ex1; }

终于

{

pRegKey.SetValue(" header",oHeader);

pRegKey.SetValue (footer,oFooter);


System.Windows.Forms.Application.DoEvents

();

}

if(ex!= null)throw(ex);


}

private void m_ieBrowser_PrintTemplateTeardown(object

发件人,

AxSHDocVw.DWebBrowserEvents2_PrintTemplateTeardown活动e)

{

//在这里我应该获取信息

//用户推动取消或打印!!!!!!!!!!!!

this.Close();

}
Hello Huang,
yes, that''s correct.
Here you''ve got part of the code (C#):

private void CFrmPrint_Activated(object sender,
System.EventArgs e)
{
object nullObject = null;
this.Visible = false;
this.m_ieBrowser.Navigate(m_sDocument, ref nullObject,
ref nullObject, ref nullObject, ref nullObject);

}

private void m_ieBrowser_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
timCheckBrowser_Tick(null, null);
}

private void timCheckBrowser_Tick(object sender,
System.EventArgs e)
{
object nullObject = null;
this.timCheckBrowser.Enabled = false;

while (m_ieBrowser.Busy)
{
System.Windows.Forms.Application.DoEvents();
}

// Set the Header and the Footer
// tricky: has to be done via the Registry,
// see therefor the MSDN article:
// http://msdn.microsoft.com/library/default.asp?
URL=/library/en-us/dnie55/html/wb_print.asp

RegistryKey pRegKey = Registry.CurrentUser;

// Create: creates a new, or opens an existing key!
pRegKey = pRegKey.CreateSubKey
("Software\\Microsoft\\Internet Explorer\\PageSetup");

// store the actual header and footer for resetting
Object oHeader = pRegKey.GetValue("header");
Object oFooter = pRegKey.GetValue("footer");

pRegKey.SetValue("header", m_sHeader);
pRegKey.SetValue("footer", m_sFooter);

// PRINT METHOD
Exception ex = null;
try
{
SHDocVw.OLECMDEXECOPT opt =
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT;

//m_ieBrowser.ExecWB
(SHDocVw.OLECMDID.OLECMDID_HIDETOOLBARS,
// opt, ref nullObject, ref nullObject);

if (m_bPromptUser)
opt = SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER;
else
opt =
OHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER ;

if (m_bPreview)
{
m_ieBrowser.ExecWB
(SHDocVw.OLECMDID.OLECMDID_PRINTPREVIEW,
opt, ref nullObject, ref
nullObject);
}
else
{
m_ieBrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT ,
opt, ref nullObject, ref
nullObject);
}
System.Threading.Thread.Sleep(100); // because of
resetting Page layout!

/*
System.Diagnostics.PerformanceCounter PC
= new System.Diagnostics.PerformanceCounter();
PC.CategoryName = "Prozess";
PC.CounterName = "Threadanzahl";
PC.InstanceName = "FestoEngineeringTool";
m_ThreadCount = (int)PC.NextValue();
*/
}
catch (Exception ex1) { ex = ex1; }
finally
{
pRegKey.SetValue("header", oHeader);
pRegKey.SetValue("footer", oFooter);

System.Windows.Forms.Application.DoEvents
();
}
if (ex != null) throw(ex);

}
private void m_ieBrowser_PrintTemplateTeardown(object
sender,
AxSHDocVw.DWebBrowserEvents2_PrintTemplateTeardown Event e)
{
// HERE I SHOULD GET THE INFORMATION
// WETHER THE USER PUSHED CANCEL OR PRINT!!!!!!!!!!!!
this.Close();
}
----- Originalnachricht -----
您好,

感谢您在小组中发帖。

基于根据我的理解,现在的问题是:您在Windows窗体中使用
Web浏览器控件来打印网页。现在使用
ExecWB打印xmlfile。但是,如果用户在
printerselection / preview窗口中单击取消按钮,则您希望在程序中跟踪此事件
,这样您就不会继续打印其他xml文件,对吧?
如果我在这里误解了任何内容,请在这里发帖。

为了确保你的代码如何工作,你能不能在
上发布你的主代码片创建网页浏览器控件并调用
ExecWB在这?在此之后,我们将在这里进行研究并回复更多
信息。
致以最诚挚的问候,
Yanhong Huang
微软在线合作伙伴支持

获得安全保障! - www.microsoft.com/security
此帖子提供按原样没有保修,
不授予任何权利。
-----Originalnachricht-----
Hello,

Thanks for posting in the group.

Based on my understanding, now the question is: You use Web browser controlin a Windows form to print a web page. Now you use ExecWB to print a xmlfile. However, if the user clicks cancel button when in printerselection/preview window, you want to track this event in the program sothat you won''t continue print other xml files, right? Please post here if Ihave misunderstood anything here.

In order to make sure how you code works, could you please post your maincode slice on creating web browser control and calling ExecWB here? Aftergetting it, we will perform research and reply with more information here.
Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
.



你好,


我刚刚查看了您在第一篇文章中提到的链接。在那个

artilce中,我们可以看到有一个名为Printing Workarounds的部分,它在页面设置对话框中使用CbtProcto跟踪窗口消息引入了
。我想b $ b我们也可以利用这个功能和以下两个

参数:


HCBT_CLICKSKIPPED

HCBT_KEYSKIPPED
http://msdn.microsoft.com/library/en...rinterface/win

dowing / hooks / hookreference / hookfunctions / cbtproc.asp?frame = true


但是,正如本文所述,此方法没有记录,并且不受Microsoft支持的b $ b。没有承诺任何这些技术

将继续在该产品的未来版本中使用。因此,在考虑任何这些技术时请谨慎使用




BTW,将来最好将这些问题发布在

关注新闻组。

microsoft.public.windows.inetexplorer.ie5.programm ing.components.webbrowser_

ctl


所有IE浏览器控件问题,配置和其他问题都在上面的新闻组中发布了




我们建议适当发布的原因是你将获得最合适的
合格的受访者群体,以及新闻组定期的其他合作伙伴可以分享他们的知识或从您的互动中学习

和我们。此外,这是为了确保响应者能够更好地跟踪问题。感谢您的理解。


再次感谢您使用Microsoft MSDN新闻组。


祝你好运,

Yanhong Huang

微软在线合作伙伴支持


安全! - www.microsoft.com/security

此帖子原样是按原样提供的。没有保证,也没有授予任何权利。

Hello,

I just reviewed the link that you mentioned in the first post. In that
artilce, we could see there is a part named "Printing Workarounds", which
introduces using CbtProcto track window messages in Page Setup dialog. I
think we may also make use of this function and the following two
parameters:

HCBT_CLICKSKIPPED
HCBT_KEYSKIPPED

http://msdn.microsoft.com/library/en...rinterface/win
dowing/hooks/hookreference/hookfunctions/cbtproc.asp?frame=true

However, as this article mentioned, this method is undocumented and
unsupported by Microsoft. There is no promise that any of these techniques
will continue to work in future versions of the product. So please use
caution when considering any of these techniques.

BTW, in the future, it would be best to post these questions in the
following newsgroup.
microsoft.public.windows.inetexplorer.ie5.programm ing.components.webbrowser_
ctl

All IE Web browser control issues, configuration and other questions are
posted in the newsgroup above.

The reason why we recommend posting appropriately is you will get the most
qualified pool of respondents, and other partners who the newsgroups
regularly can either share their knowledge or learn from your interaction
with us. Also, this is to make sure that the responders can better track
the problem. Thank you for your understanding.

Thanks again for using Microsoft MSDN Newsgroups.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


这篇关于SHDocVW Internetexplorer PlugIn问题 - 取消事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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