<?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: "Hello world" application

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

//------------------------------------------------------------ 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("APPNAME",           "Hello world!");    // Application name

// Control identifiers

define("ID_ABOUT",          101);
define("ID_OPEN",           102);

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

// Create main window, then assign a procedure and an icon to it

$mainwin wb_create_window(NULLAppWindowAPPNAME " - PHP " PHP_VERSION320240);
wb_set_handler($mainwin"process_main");
wb_set_image($mainwinPATH_RES "hyper.ico");

// Create menu

wb_create_control($mainwinMenu, array(
    
"&File",
        array(
ID_OPEN,  "&Open...\tCtrl+O"NULLPATH_RES "menu_open.bmp""Ctrl+O"),
        
null,           // Separator
        
array(IDCLOSE,  "E&xit\tAlt+F4",    NULLPATH_RES "menu_exit.bmp"),
    
"&Help",
        array(
ID_ABOUT"&About...",        NULLPATH_RES "menu_help.bmp")
));

// Create toolbar

wb_create_control($mainwinToolBar, array(
    
null,                                   // Toolbar separator
    
array(ID_OPEN,  NULL,   "Open a file",              1),
    
null,                                   // Toolbar separator
    
array(ID_ABOUTNULL,   "About this application",   13),
    array(
IDCLOSE,  NULL,   "Exit this application",    14),
), 
00161500PATH_RES "toolbar.bmp");

// Create status bar

$statusbar wb_create_control($mainwinStatusBarAPPNAME);

// Create label control inside the window

wb_create_control($mainwinLabel"This is a demo 'Hello world'\n" .
  
"application made with WinBinder.\n" .
  
"It has a toolbar, a status bar and a menu.",
  
1070290800WBC_CENTER);

// Enter application loop

wb_main_loop();

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

/* Process main window commands */

function process_main($window$id)
{
    global 
$statusbar;

    static 
$file_filter = array(
        array(
"PHP source code",    "*.php?"),
        array(
"Web page",           "*.htm?"),
        array(
"Text document",      "*.txt"),
        array(
"All files",          "*.*")
    );

    switch(
$id) {

        case 
ID_ABOUT:
            
wb_message_box($window"WinBinder version " WBC_VERSION .
              
"\nPHP version " PHP_VERSION .  "\n" .
              
wb_get_system_info("osversion"), "About " APPNAMEWBC_INFO);
            break;

        case 
ID_OPEN:
            
$filename wb_sys_dlg_open($window"Get It"$file_filter);
            if(
$filename)
                
wb_set_text($statusbar$filename);
            break;

        case 
IDCLOSE:       // IDCLOSE is predefined
            
wb_destroy_window($window);
            break;
    }
}

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

?>