<?php

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

 WINBINDER - The native Windows binding for PHP for PHP

 Copyright © Hypervisual - see LICENSE.TXT for details
 Author: Rubem Pechansky (http://winbinder.org/contact.php)

 Code sample: How to generate a tabbed dialog/window using the form editor

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

//------------------------------------------------------------ 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

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

create_main_window();
wb_main_loop();

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

/* Create main window */

function create_main_window()
{
	// Create the dialog box

	include 'dialog_options.form.php';
	$maintab = wb_get_control($options_dlg, IDC_MAINTAB);
	include 'dialog_options_general.form.php';
	include 'dialog_options_advanced.form.php';

	// Set up some values

	$ctrl = wb_get_control($maintab, IDC_WELCOMETEXT);
	wb_set_text($ctrl, "This code demonstrates how to implement tabs using the form editor (FE).\n\n" .
		"This example is a simple \"Options\" dialog box which you may use it as a template for your own projects.\n\n" .
		"There are three separate project files, one for the dialog base, and one for each tab.\n\n" .
		"You may even open two or more instances of FE to see one tab while you are creating another one."
	);

	$ctrl = wb_get_control($maintab, IDC_LANGUAGE);
	$languages = array('Dutch', 'English', 'French', 'German', 'Italian', 'Portuguese', 'Russian');
	foreach($languages as $lang) {
		wb_create_items($ctrl, $lang);
	}

	// Show it

	wb_set_visible($options_dlg, true);
	wb_set_handler($options_dlg, 'process_options');
}

/* Process main window commands */

function process_options($window, $id, $ctrl=null, $lparam1=null, $lparam2=null)
{
	switch($id) {

		case IDOK:

			// Fall-through

		case IDCLOSE:
		case IDCANCEL:
			wb_destroy_window($window);
			break;
	}
}

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

?>