Another Windows extension

From: Date: Thu, 20 Nov 2003 09:38:46 +0000
Subject: Another Windows extension
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-218@lists.php.net to get a copy of this message
Hi, I got another Windows extension, it's named 'view' but could be named 'win-view' since it's only work under Windows. It's purpose is to handle common, hard coded, MFC dialogs (called views). From the extension side it export 4 function:
        - view_start
        - view_set_property
        - view_get_event
        - view_visible
As you guess, once started you can set property on a view and receive event from it, controled in the PHP script by a typical Run-type loop. Internally a view run in an MFC thread so the user interface does not lock when the script work, and the events/properties are handled by the windows messaging system. They are two type of property:
        - standard properties like: show, move, size; that any view must handle
        - view properties that is specific to a view
Currently implemented viewes are:
        - Text view: a TextEdit control
        - HTML view: a WebBrowser control (iexplorer in fact)
        - DHTML view: a DHTML dialog
        (i plan to add: Movie and Flash players)
The most interesting is the DHTML one in fact. Since VS .NET (VC7 for C++) MS has added a CDHtmlDialog that is able to:
        - Display an HTML page (again iexplorer)
        - Modify the HTML dynamicaly
        - Retrieve and set HTML form elements values
As you may have noticed they are a growing number of applications that use it. For exemple User managment in Windows XP, Norton anti virus, the setup of VS .NET. The 'view' extension allow a PHP script to take avantage over this, at run time you can:
        - Load an HTML page
        - Define javascript like events to receive by a given HTML id or class
        - Add HTML code
I've also wrote a set of PHP classes that ease the use of the extension (no knowledge of all properties). I have a number of question:
        - Do you think that such an extension could be part of PECL ?
        - If it could be part of PECL how could it be for the class set ?
        - What do you think of it :p
        - Finaly: how could i name it ? :)
Eric Exemple : ---------------------------- DHTML_Test.htm ---------------------------- <html>
        <body>
                <DIV align="center">
                <form>
                        <TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1" align="center">
                                <TR>
                                        <TD width="124">Name:</TD>
                                        <TD><INPUT id="nom" type="text" name="name"></TD>
                                </TR>
                                <TR>
                                        <TD width="124">Age:</TD>
                                        <TD><INPUT id="age" type="text" name="age"></TD>
                                </TR>
                                <TR>
                                        <TD colspan="2" align="center"><INPUT type="button" value="OK" ID="OK" NAME="OK"></TD>
                                </TR>
                        </TABLE>
                        </form>
                </DIV>
                <DIV align="center">&nbsp;</DIV>
                <HR width="100%" SIZE="1">
                <P id="result" align="center"></P>
        </body>
</html> ---------------------------- DHTML_Test.php ---------------------------- <? $view_type= 'dhtml_dlg'; $wnd= view_start( $view_type ); if( !$wnd ) {
        echo "View not known: $view_type !\n";
        exit;
} view_set_property( $wnd, 'url', realpath('html_ex-test.html') ); view_set_property( $wnd, 'event_elm_click', 'OK' ); view_set_property( $wnd, 'show', '' ); while( !view_visible( $wnd ) ) {
        if( view_get_event( 0, $type, $value, $extra, $view ) ) {
                switch( $type ) {
                        case 'close':
                        case 'ok' :
                                view_set_property( $wnd, 'close', 1 );
                                break;
                        case 'element_click':
                                view_set_property( $wnd, 'get_id_value', 'age');
                                view_set_property( $wnd, 'get_id_value', 'nom');
                                break;
                        case 'get_id_value':
                                if( $value=='age' ) {
                                        $age= (string)$extra;
                                }
                                if( $value=='nom' ) {
                                        $nom= (string)$extra;
                                }
                                if( !empty($age) && !empty($nom) ) {
                                        view_set_property( $wnd, 'set_id_value', 'nom', '' );
                                        view_set_property( $wnd, 'set_id_value', 'age', '' );
                                        view_set_property( $wnd, 'set_id_html', 'result', "Hi $nom you are $age year".($age>1?'s':'')." old" );
                                        $nom= $age= '';
                                }
                        default:
                                echo "[$view] $type=$value ".($extra?"($extra)":'')."\n";
                                break;
                }
        }
} echo "Bye !\n"; ?>

« previous php.pecl.dev (#218) next »