HOW: ????? ????? C# ?? Internet Explorer Script ????

?????? ????????? ?????? ?????????
???? ???????: 313891 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ?????? ???? ????? ??? ????? ??? ???? ??????? ???? ??? ??????? ?? ????? ???? ???? ?????? (COM) (?????? ??? ??????) ??? ??????? ????? ???? Windows .NET. ??? ???? ??????? ????? ????? ??????? ???? ??? ??????? ?? ????? COM ??? ????? ???????? ????? ?? Internet Explorer.

?????? ??? ??????? ??? ????? ????? ??????? ????? ??????? ?? COM ???? ????? ?????? ?????? Microsoft .NET Framework ????? ":
??? .NET Framework ???????? ??? COM
http://msdn2.microsoft.com/en-us/library/zsfww439(vs.71).aspx

???????

???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ???? ???????:
  • Microsoft Visual Studio .NET
  • Microsoft Internet Explorer (???????) ??????? 5.5 ?? ????????? ??????

????? ???? ????? ?? Internet Explorer Script ?????

  1. ????? ???? ???? Windows ??????? ?????:
    1. ??? ????? Microsoft Visual Studio .NET.
    2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
    3. ?? ???? ?????? ????? ???? ? ???? ??? Visual C# ?????? ??? ????? Project ?? ???? ??? ????? ?????? Windows ??? ?????.
  2. ????? ????? ???? ??????? ???? ???? ?????.
  3. ????? ??? GuidAttribute ????? ??????. ??? ?? ???? ?????? ??????? ???? ???? ??? ????? ?????? ???? ?????? ???? Guid. ????? ??????? ??? Guidgen.exe ????? GUID ??? ???????.
    [GuidAttribute("0422D916-C11A-474e-947D-45A107038D12") ]
        
        public interface ControlEvents 
    
    		
        {
            //  Insert code here.
        }
    					
  4. ????? ??? InterfaceType ??? ????? ???? ???? COM ?????? IDispatch:
    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
        public interface ControlEvents 
    
    		
        {
           
            // Insert code here.
        }
    					
  5. ????? DispIdAttribute ?? ????? ?? ????? ???? ??? ????? ?????? ????? COM (DISPID) ?? ????? ?? ???:
    public interface ControlEvents 
    	
        {
            [DispIdAttribute(0x60020000)]
            void ClickEvent(int x, int y);
        }
    					
  6. ????? ??? ??? ???? ?????? ????? ??????? ????.
  7. ???? ?????? ????? ?????? ??? ????? ???? ????? Windows ???????.
  8. ????? ??? ComSourceInterfaces ??? ???? ?????? ?????? ????? ???????? ????? ?????? ??? COM:
    [ClassInterface(ClassInterfaceType.None),ComSourceInterfaces(typeof(ControlEvents))]
    	public class MyWindowControl : System.Windows.Forms.UserControl 
        {
    
          // Insert code here.
        }
    					
  9. ????? ???? ?????? ??? ????? ???????? ?????? (DLL).
  10. ????? ???? ?????? ??? ??? ???? HTML ??? ?????. ??? ???? ??????:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=iso-8859-1' />
    
    <HTML>
    	<HEAD>
    		<TITLE>Sink managed event in Internet Explorer</TITLE>
    		
    		
    	</HEAD>
    	
    	<BODY>
    		
    		<OBJECT id="ctrl" classid="YourDllName.dll#ActiveXSourcing.MyWindowControl">
    		</OBJECT>
    		<SCRIPT LANGUAGE="JScript">
                function ctrl::ClickEvent(a,b)
                {
                    alert("MyWindowControl_ClickEvent");
                }
    		</SCRIPT>
    		
    	</BODY>
    </HTML>
    					
  11. ?? ?? ???? ?????? ?????? ?????? "????? .NET Framework" (Mscorcfg.msc) ??? ??????? ???????? ??????? ????????.

????? ??? ????????? ????????

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace ActiveXSourcing
{
	public delegate void ClickEventHandler(int x, int y); 

	//Source interface for events to be exposed.
	//Add GuidAttribute to the source interface to supply an explicit System.Guid.
	//Add InterfaceTypeAttribute to indicate that interface is IDispatch interface.
	[GuidAttribute("0422D916-C11A-474e-947D-45A107038D12") ]
	[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
	public interface ControlEvents 

		//Add a DisIdAttribute to any members in the source 
		//interface to specify the COM DispId.
	{
		[DispIdAttribute(0x60020000)]
		void ClickEvent(int x, int y);
	}

	//Add a ComSourceInterfaces attribute to the control to 
	//identify the list of interfaces that are exposed as COM event sources. 
	[ClassInterface(ClassInterfaceType.None),ComSourceInterfaces(typeof(ControlEvents))]
	public class MyWindowControl : System.Windows.Forms.UserControl 
		//, ComInteropControlInterface
	{
        System.Windows.Forms.TextBox tx = new TextBox();

		private void InitializeComponent()
		{
			
			this.Name = "MyWindowControl";

		}
	
		event ActiveXSourcing.ClickEventHandler ClickEvent;
    	
		public MyWindowControl() : base()
		{				               

			initMyWindowControl();

		}
        
		private void initMyWindowControl() 
		{

			Size = new System.Drawing.Size(300, 50);
			tx.Text = "Click on the TextBox to invoke  'ClickEvent'";
			tx.Size = this.Size;                  
			tx.Click += new System.EventHandler(ClickHandler);
			this.Controls.Add(tx);
			
		}
            
        
		private void ClickHandler(object sender, System.EventArgs e)
		{
			if (ClickEvent != null) 
			{
				ClickEvent(0, 0);
			}
		}
	}
}
				

?????

????? ?? ?????????? ???? ??? ????? Microsoft ??????? ??? ?????:
?????? ?????? ???????
http://msdn2.microsoft.com/en-us/library/edzehd2t(vs.71).aspx

???? ????? ???? ??? .NET (Mscorcfg.msc)
http://msdn2.microsoft.com/en-us/library/2bc0cxhc(vs.71).aspx

interoperating ?? ?????? ??? ??????
http://msdn2.microsoft.com/en-us/library/sd10k43k(vs.71).aspx

?????? ?????? ????? ????? ?????? ???? ?????? ?? Microsoft Internet Explorer
http://msdn.microsoft.com/msdnmag/issues/02/01/UserCtrl/default.aspx
?????? ??? ??????? ??????? ???? ??? ??? ??????? ????? ?????? ?? "????? ??????? ?? Microsoft:
316510BUG: ??????? ???? ??? ??????? ??????? ??????? ?? Internet Explorer

???????

???? ???????: 313891 - ????? ??? ??????: 30/???? ??????/1428 - ??????: 3.4
????? ???
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Internet Explorer 5.5
????? ??????: 
kbmt kbcominterop kbhowto kbhowtomaster kbsample KB313891 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????313891

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com