Beispiel #1
0
        private void AdviseIOPCDataCallback()
        {
            Type l_SinkType = typeof(IOPCDataCallback);
            Guid l_SinkGuid = l_SinkType.GUID;

            m_PointContainer.FindConnectionPoint(ref l_SinkGuid, out m_CallbackPoint);
            if (m_CallbackPoint == null)
            {
                return;
            }

            m_CallbackPoint.Advise(this, out m_CallbackCookie);
        }
Beispiel #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public Class2SubjectDlg()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

#if NO
            // UCOMIConnectionPointContainer
            // System.Runtime.InteropServices.ComTypes.IConnectionPointContainer
            System.Runtime.InteropServices.ComTypes.IConnectionPointContainer icpc = (System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)axWebBrowser.GetOcx(); // ADDed

            Guid g = typeof(DWebBrowserEvents).GUID;
            icpc.FindConnectionPoint(ref g, out icp);
            icp.Advise(this, out cookie);
#endif
        }
Beispiel #3
0
        public frmBrowse(ArrayList urlList)
        {
            InitializeComponent();

            this.cbUrlList.Items.AddRange(urlList.ToArray());
            if (urlList.Count > 0)
            {
                this.cbUrlList.SelectedIndex = 0;
            }

            System.Runtime.InteropServices.ComTypes.IConnectionPointContainer icpc =
                (System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)axWebBrowser1.GetOcx(); // ADDed

            Guid g = typeof(DWebBrowserEvents).GUID;

            icpc.FindConnectionPoint(ref g, out icp);
            icp.Advise(this, out cookie);
        }
        public void Connect(WebBrowser webBrowser)
        {
            if (_sinkCookie != int.MaxValue)
            {
                throw new InvalidOperationException();
            }

            var activeXInstance = webBrowser.GetType().InvokeMember("ActiveXInstance",
                                                                    BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                                                    null, webBrowser, new object[] { }); // as SHDocVw.WebBrowser;

            var cpc  = (System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)activeXInstance;
            var guid = typeof(DWebBrowserEvents2).GUID;

            System.Runtime.InteropServices.ComTypes.IConnectionPoint _sinkCP;
            cpc.FindConnectionPoint(ref guid, out _sinkCP);
            _sinkCP.Advise(this, out _sinkCookie);
        }