简体   繁体   English

捕获嵌入winform的网站上发生的事件

[英]Catch an event fired on a website embedded in a winform

I have a web page that is embedded in my winform. 我有一个嵌入我的winform的网页。

When i click a button on my application the form shows up and navigates to a settings page. 当我单击应用程序上的按钮时,表单将显示并导航到设置页面。

What i want is to catch an event fired on the website. 我想要的是抓住网站上发生的事件。 eg if the user changes some settings on the webpage and clicks OK then i should catch that even and close my form automatically. 例如,如果用户更改了网页上的某些设置并单击“确定”,那么我应该自动捕获并自动关闭我的表单。

Is this even possible? 这甚至可能吗?

Here is the JS code for the OK click event 这是OK单击事件的JS代码

if (statusOK) {
Ext.Msg.show({
title : '',
buttons : Ext.Msg.OK,
msg : 'Default settings saved.',
 icon : Ext.Msg.INFO
}); 

Any help will be appreciated. 任何帮助将不胜感激。

Thanks 谢谢

In your web page, you can do a redirect to some specialy crafted URL, like myapp://doStuff. 在您的网页中,您可以重定向到某个特制的URL,例如myapp:// doStuff。

And in the web browser control, you can subscribe to Navigating event that will be fired when page tries to go to another URL. 在Web浏览器控件中,您可以订阅当页面尝试转到另一个URL时将触发的Navigating事件。 In that handler you can detect your specially crafted URLs and execute needed actions. 在该处理程序中,您可以检测特制URL并执行所需操作。

You can do the following in javascript 您可以在javascript中执行以下操作

 window.external.MyFunction();

That will call the MyFunction() function in winforms. 这将在winforms中调用MyFunction()函数。

In your cs file you need: 在您的cs文件中,您需要:

[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]

before your class definition. 在你的课程定义之前。 And MyFunction() needs to be public. MyFunction()需要公开。 In that function you can do to your form whatever you want. 在该功能中,无论您想要什么,您都可以使用您的表格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 听取从不同winform触发的自定义事件 - Listening for a custom event fired from different winform 在WinForm C#上捕获KeyUp事件 - Catch KeyUp Event on WinForm C# (Winform)在触发MouseHover事件后将其添加后,无法单击链接标签 - (Winform) Cannot click the linklabel after adding it as MouseHover event fired 我想在WinForm中捕获ctrl + space键事件 - I coudlnt catch ctrl+space key event in WinForm 双击将项目从一个列表框复制到另一个列表框。 Doubleclick事件未触发。 Winform C# - Copy item from one listbox to another on double click. Doubleclick event not fired. Winform C# 通过一个可能从多个线程触发的事件处理程序更新Winform ListView控件 - Updating Winform ListView control by one event handler that may be fired from several threads CheckBox.CheckedChanged没有在winform上触发 - CheckBox.CheckedChanged not fired on winform 如何捕获在Visual Studio 2015中单击“保存工作项”按钮时引发的事件? - How to catch the event which is fired when “Save Work Item” button clicked in Visual Studio 2015? C# - 是否有可能赶上<process> .Exited 事件从主进程中触发?</process> - C# - Is it possible to catch a <Process>.Exited event fired from the main process? 在网站中使用Winform的dll - use dll of winform in a website
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM