<?php

/*******************************************************************************

 WINBINDER - A native Windows binding for PHP

 Copyright  2004-2005 Hypervisual - see LICENSE.TXT for details
 Author: Rubem Pechansky (http://www.hypervisual.com/winbinder/contact.php)

 Code sample: A simple digital clock with scrolling text

*******************************************************************************/

//------------------------------------------------------------ SYSTEM PARAMETERS

define("PATH_SCRIPT",   dirname(__FILE__) . "/");
define("PATH_DATA",     PATH_SCRIPT);
define("PATH_INC",      PATH_SCRIPT "../include/");
define("PATH_RES",      PATH_SCRIPT "../resources/");

//----------------------------------------------------------------- DEPENDENCIES

include PATH_INC "winbinder.php";

//-------------------------------------------------------------------- CONSTANTS

define("ID_APP_TIMER",  201);
define("SHORT_FMT",     "h:i:s A");
define("LONG_FMT",      "l, F dS, Y --- ");

//-------------------------------------------------------------- EXECUTABLE CODE

// Create main window, then assign a procedure to it

$mainwin wb_create_window(NULLPopupWindow"WB clock"12090);
wb_set_handler($mainwin"process_main");

// Create label control inside the window

$label wb_create_control($mainwinLabeldate("h:i:s A"), 012112200WBC_CENTER);
wb_set_font($labelwb_create_font("Tahoma"11nullFTA_BOLD));

// Create status bar

$statusbar wb_create_control($mainwinStatusBardate(SHORT_FMT));
wb_set_font($statusbarwb_create_font("Courier New"8));

// Create the timer

wb_create_timer($mainwinID_APP_TIMER120);

// Enter application loop

wb_main_loop();

//-------------------------------------------------------------------- FUNCTIONS

/* Process main window commands */

function process_main($window$id)
{
    global 
$label$statusbar;
    static 
$pos;

    switch(
$id) {

        case 
ID_APP_TIMER:

            
// Show the current time in hours, minutes and seconds

            
wb_set_text($labeldate(SHORT_FMT));

            
// Truncate text

            
$text date(LONG_FMT);
            
$len strlen($text);
            
wb_set_text($statusbarsubstr($text $text$pos$len));
            
$pos $pos $len $pos 0;
            break;

        case 
IDCLOSE:

            
wb_destroy_window($window);
            break;
    }
}

//------------------------------------------------------------------ END OF FILE

?>