Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 5633

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>com_event_sink</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="COM 和 .Net(Windows)函数"
HREF="ref.com.html"><LINK
REL="PREVIOUS"
TITLE="com_create_guid"
HREF="function.com-create-guid.html"><LINK
REL="NEXT"
TITLE="com_get_active_object"
HREF="function.com-get-active-object.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.com-create-guid.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.com-get-active-object.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.com-event-sink"
></A
>com_event_sink</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN22050"
></A
><P
>    (PHP 4 &#62;= 4.2.3, PHP 5)</P
>com_event_sink&nbsp;--&nbsp;
     Connect events from a COM object to a PHP object
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN22053"
></A
><H2
>Description</H2
>bool <B
CLASS="methodname"
>com_event_sink</B
> ( variant comobject, object sinkobject [, mixed sinkinterface] )<BR
></BR
><P
>&#13;     Instructs COM to sink events generated by
     <CODE
CLASS="parameter"
>comobject</CODE
> into the PHP object
     <CODE
CLASS="parameter"
>sinkobject</CODE
>.  PHP will attempt to use the default
     dispinterface type specified by the typelibrary associated with
     <CODE
CLASS="parameter"
>comobject</CODE
>, but you may override this choice by
     setting <CODE
CLASS="parameter"
>sinkinterface</CODE
> to the name of the
     dispinterface that you want to use.
    </P
><P
>&#13;     <CODE
CLASS="parameter"
>sinkobject</CODE
> 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.html"
><B
CLASS="function"
>com_print_typeinfo()</B
></A
> to help generate a template class
     for this purpose.
    </P
><P
>&#13;     Be careful how you use this feature; if you are doing something similar
     to the example below, then it doesn't really make sense to run it in a
     web server context.
    </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN22076"
></A
><P
><B
>例 1. COM event sink example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">class </font><font color="#0000BB">IEEventSinker </font><font color="#007700">{<br />&nbsp;&nbsp;var </font><font color="#0000BB">$terminated </font><font color="#007700">= </font><font color="#0000BB">false</font><font color="#007700">;<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">ProgressChange</font><font color="#007700">(</font><font color="#0000BB">$progress</font><font color="#007700">, </font><font color="#0000BB">$progressmax</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Download progress: $progress / $progressmax</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">DocumentComplete</font><font color="#007700">(&amp;</font><font color="#0000BB">$dom</font><font color="#007700">, </font><font color="#0000BB">$url</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Document $url complete</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">OnQuit</font><font color="#007700">() {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Quit!\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">terminated </font><font color="#007700">= </font><font color="#0000BB">true</font><font color="#007700">;<br />&nbsp;&nbsp;}<br />}<br /></font><font color="#0000BB">$ie </font><font color="#007700">= new </font><font color="#0000BB">COM</font><font color="#007700">(</font><font color="#DD0000">"InternetExplorer.Application"</font><font color="#007700">);<br /></font><font color="#FF8000">// note that you don't need the &amp; for PHP 5!<br /></font><font color="#0000BB">$sink </font><font color="#007700">=&amp; new </font><font color="#0000BB">IEEventSinker</font><font color="#007700">();<br /></font><font color="#0000BB">com_event_sink</font><font color="#007700">(</font><font color="#0000BB">$ie</font><font color="#007700">, </font><font color="#0000BB">$sink</font><font color="#007700">, </font><font color="#DD0000">"DWebBrowserEvents2"</font><font color="#007700">);<br /></font><font color="#0000BB">$ie</font><font color="#007700">-&gt;</font><font color="#0000BB">Visible </font><font color="#007700">= </font><font color="#0000BB">true</font><font color="#007700">;<br /></font><font color="#0000BB">$ie</font><font color="#007700">-&gt;</font><font color="#0000BB">Navigate</font><font color="#007700">(</font><font color="#DD0000">"http://www.php.net"</font><font color="#007700">);<br />while(!</font><font color="#0000BB">$sink</font><font color="#007700">-&gt;</font><font color="#0000BB">terminated</font><font color="#007700">) {<br />&nbsp;&nbsp;</font><font color="#0000BB">com_message_pump</font><font color="#007700">(</font><font color="#0000BB">4000</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">$ie </font><font color="#007700">= </font><font color="#0000BB">null</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;     See also <A
HREF="function.com-print-typeinfo.html"
><B
CLASS="function"
>com_print_typeinfo()</B
></A
>,
     <A
HREF="function.com-message-pump.html"
><B
CLASS="function"
>com_message_pump()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.com-create-guid.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.com-get-active-object.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>com_create_guid</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.com.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>com_get_active_object</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>