downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.com-event-sink.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.com.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.com-event-sink.php',
   
1 => 'com_event_sink',
  ),
 
'up' =>
  array (
   
0 => 'ref.com.php',
   
1 => 'COM Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.com-create-guid.php',
   
1 => 'com_create_guid',
  ),
 
'next' =>
  array (
   
0 => 'function.com-get-active-object.php',
   
1 => 'com_get_active_object',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.com-event-sink" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">com_event_sink</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">com_event_sink</span> &mdash; <span class="dc-title">Connect events from a COM object to a PHP object</span></p>

 </div>
 <a name="function.com-event-sink.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>com_event_sink</b></span>
    ( <span class="methodparam"><span class="type"><a href="class.variant.php" class="type variant">variant</a></span> <tt class="parameter">$comobject</tt></span>
   , <span class="methodparam"><span class="type">object</span> <tt class="parameter">$sinkobject</tt></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.php#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$sinkinterface</tt></span>
  ] )</div>

  <p class="para rdfs-comment">
   Instructs COM to sink events generated by
   <i><tt class="parameter">comobject</tt></i>
 into the PHP object
   <i><tt class="parameter">sinkobject</tt></i>
.
  </p>
  <p class="para">
   Be careful how you use this feature; if you are doing something similar
   to the example below, then it doesn&#039;t really make sense to run it in a
   web server context.
  </p>
 </div>

 <a name="function.com-event-sink.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">comobject</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">sinkobject</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       <i><tt class="parameter">sinkobject</tt></i>
 should be an instance of a class with
       methods named after those of the desired dispinterface; you may use
       <a href="function.com-print-typeinfo.php" class="function">com_print_typeinfo()</a> to help generate a template class
       for this purpose.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">sinkinterface</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       PHP will attempt to use the default dispinterface type specified by
       the typelibrary associated with <i><tt class="parameter">comobject</tt></i>
, but
       you may override this choice by setting
       <i><tt class="parameter">sinkinterface</tt></i>
 to the name of the dispinterface
       that you want to use.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>

 <a name="function.com-event-sink.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <b><tt class="constant">TRUE</tt></b> on success or <b><tt class="constant">FALSE</tt></b> on failure.
  </p>
 </div>

 <a name="function.com-event-sink.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 COM event sink example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">IEEventSinker&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</span><span style="color: #0000BB">$terminated&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">ProgressChange</span><span style="color: #007700">(</span><span style="color: #0000BB">$progress</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$progressmax</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Download&nbsp;progress:&nbsp;</span><span style="color: #0000BB">$progress</span><span style="color: #DD0000">&nbsp;/&nbsp;</span><span style="color: #0000BB">$progressmax</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">DocumentComplete</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$dom</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$url</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Document&nbsp;</span><span style="color: #0000BB">$url</span><span style="color: #DD0000">&nbsp;complete\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">OnQuit</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Quit!\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">terminated&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">$ie&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">COM</span><span style="color: #007700">(</span><span style="color: #DD0000">"InternetExplorer.Application"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;note&nbsp;that&nbsp;you&nbsp;don't&nbsp;need&nbsp;the&nbsp;&amp;&nbsp;for&nbsp;PHP&nbsp;5!<br /></span><span style="color: #0000BB">$sink&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">IEEventSinker</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">com_event_sink</span><span style="color: #007700">(</span><span style="color: #0000BB">$ie</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sink</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"DWebBrowserEvents2"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$ie</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Visible&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$ie</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Navigate</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.example.org"</span><span style="color: #007700">);<br />while(!</span><span style="color: #0000BB">$sink</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">terminated</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">com_message_pump</span><span style="color: #007700">(</span><span style="color: #0000BB">4000</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">$ie&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>

 <a name="function.com-event-sink.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.com-print-typeinfo.php" class="function" rel="rdfs-seeAlso">com_print_typeinfo()</a> - Print out a PHP class definition for a dispatchable interface</li>
    <li class="member"><a href="function.com-message-pump.php" class="function" rel="rdfs-seeAlso">com_message_pump()</a> - Process COM messages, sleeping for up to timeoutms milliseconds</li>
   </ul><p>
  </p>
 </div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites