mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 09:06:04 +02:00
Update webbrowser sample (#173)
* Update webbrowser sample As per suggestions https://github.com/dotnet/winforms/issues/4443#issuecomment-759333446 Resolves dotnet/winforms#4443 * fixup! Update webbrowser sample * fixup! Update webbrowser sample * Update dotnet-desktop-guide/framework/winforms/controls/implement-two-way-com-between-dhtml-and-client.md Co-authored-by: Andy De George <[email protected]> Co-authored-by: Andy De George <[email protected]>
This commit is contained in:
co-authored by
Andy De George
parent
232f1b91e2
commit
1fe35d6424
+18
-12
@@ -1,9 +1,6 @@
|
||||
'<snippet0>
|
||||
Imports System.Windows.Forms
|
||||
Imports System.Security.Permissions
|
||||
|
||||
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
|
||||
<System.Runtime.InteropServices.ComVisibleAttribute(True)> _
|
||||
Public Class Form1
|
||||
Inherits Form
|
||||
|
||||
@@ -24,8 +21,8 @@ Public Class Form1
|
||||
Controls.Add(button1)
|
||||
End Sub
|
||||
|
||||
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
|
||||
Handles Me.Load
|
||||
Protected Overrides Sub OnLoad(e As EventArgs)
|
||||
MyBase.OnLoad(e)
|
||||
|
||||
'<snippet1>
|
||||
webBrowser1.AllowWebBrowserDrop = False
|
||||
@@ -37,7 +34,7 @@ Public Class Form1
|
||||
webBrowser1.WebBrowserShortcutsEnabled = False
|
||||
'</snippet3>
|
||||
'<snippet4>
|
||||
webBrowser1.ObjectForScripting = Me
|
||||
webBrowser1.ObjectForScripting = New MyScriptObject(Me)
|
||||
'</snippet4>
|
||||
'<snippet9>
|
||||
' Uncomment the following line when you are finished debugging.
|
||||
@@ -53,12 +50,6 @@ Public Class Form1
|
||||
"</body></html>"
|
||||
End Sub
|
||||
|
||||
'<snippet5>
|
||||
Public Sub Test(ByVal message As String)
|
||||
MessageBox.Show(message, "client code")
|
||||
End Sub
|
||||
'</snippet5>
|
||||
|
||||
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
|
||||
Handles button1.Click
|
||||
|
||||
@@ -70,4 +61,19 @@ Public Class Form1
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
'<snippet5>
|
||||
Public Class MyScriptObject
|
||||
Private _form As Form1
|
||||
|
||||
Public Sub New(ByVal form As Form1)
|
||||
_form = form
|
||||
End Sub
|
||||
|
||||
Public Sub Test(ByVal message As String)
|
||||
MessageBox.Show(message, "client code")
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
'</snippet5>
|
||||
'</snippet0>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFrameworks>net472;net5.0-windows</TargetFrameworks>
|
||||
<RootNamespace>sample</RootNamespace>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<MyType>WindowsForms</MyType>
|
||||
<StartupObject>sample.Form1</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user