<?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)

 Borderless window demonstration

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

//------------------------------------------------------------ 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""WinBinder Borderless Window");   // The window title will be seen in the taskbar and on Alt+tab

define("WIDTH",     576);
define("HEIGHT",    400);

define("ID_ONTOP",  101);

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

// Only one instance of application allowed

if(wb_get_instance(APPNAMETRUE))
    die;

// Create main window

$font_title wb_create_font("Verdana"200x80FFFFFTA_BOLD);
$font_text wb_create_font("Tahoma"10WHITEFTA_BOLD);

$mainwin wb_create_window(NULLNakedWindowAPPNAMEWBC_CENTERWBC_CENTERWIDTHHEIGHT,
  
WBC_INVISIBLE WBC_NOTIFY WBC_CUSTOMDRAWWBC_REDRAW);
wb_set_area($mainwinWBC_TITLE00WIDTH86);

// Draw and create window background

//draw_on_window($mainwin, WIDTH, HEIGHT);

// Create some ImageButtons

$states wb_load_image(PATH_RES 'states.bmp');

$btn wb_create_control($mainwinImageButton"Toggle Always on Top"103463232ID_ONTOPWBC_IMAGE);
wb_set_image($btn$states);

$btn wb_create_control($mainwinImageButton"Button 2",             4234632320WBC_IMAGE);
wb_set_image($btn$states);

$btn wb_create_control($mainwinImageButton"Button 3",             7434632320WBC_IMAGE);
wb_set_image($btn$states);

$btn wb_create_control($mainwinImageButton"Button 4",             10634632320WBC_IMAGE WBC_DISABLED);
wb_set_image($btn$states);

$btn wb_create_control($mainwinImageButton"Close this window",    WIDTH -  403463232IDCLOSEWBC_IMAGE);
wb_set_image($btn$states);
wb_destroy_image($btn);

// Last touches

wb_set_handler($mainwin"process_main");
wb_set_image($mainwinPATH_RES 'hyper.ico');     // Icon will be seen in the taskbar and on Alt+tab
wb_set_visible($mainwinTRUE);

wb_main_loop();

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

/* Process main window commands */

function process_main($window$id$ctrl$lparam1=0$lparam2=0)
{
    switch(
$id) {

        case 
IDDEFAULT:

            if(
$lparam1 WBC_REDRAW) {
                
$dim wb_get_size($windowtrue);
                
$winwidth $dim[0];
                
$winheight $dim[1];
                
draw_on_window($lparam2$winwidth$winheight);
            }
            break;

        case 
IDCLOSE:
            
wb_destroy_window($window);
            
wb_destroy_font();              // Destroy all fonts
            
break;

        case 
ID_ONTOP:
            static 
$ontop false;
            
$ontop = !$ontop;
            
wb_set_style($windowWBC_TOP$ontop);
    }
}

/* Draw main window image */

function draw_on_window($buffer$width$height)
{
    global 
$font_title$font_text;

    
// Create a bitmap and draw on it

    
wb_draw_rect($buffer00$width$heightBLACK);
    
wb_draw_rect($buffer00$width700x8D5A2D);
    
wb_draw_rect($buffer0326$width700x8D5A2D);

    
// Create a repeating pattern

    
$pattern wb_create_image(1616);
    
wb_draw_rect($pattern0016160x704010);
    
wb_draw_rect($pattern3310100xB08050);
    
wb_draw_rect($pattern66440x704010);
    for(
$i 0$i $width$i += 16) {
        
wb_draw_image($buffer$pattern$i0);
        
wb_draw_image($buffer$pattern$i70);
        
wb_draw_image($buffer$pattern$i326);
        
wb_draw_image($buffer$pattern$i$height 16);
    }
    
wb_destroy_image($pattern);

    
// Draw some text

    
wb_draw_text($bufferAPPNAME022$width40$font_titleWBC_CENTER);
    for(
$x 10$y 95$y 310$x += 5$y += 20)
        
wb_draw_text($buffer"To put this application on top on other windows, click the first button below.",
          
$x$y00$font_text);
}

//-------------------------------------------------------------------------- END

?>