PHP WinBinder 2: Add code
|
PHP WinBinder 2 : Introduction | WinBinder portable | Add code | PHC-Win | Resource
|
|
| UniServer 5-Nano PHP WinBinder 2. |
WinBinder Part 2 Adding code and files
On the previous page we finished with a bare windows application containing two buttons and indicators.
This page looks at adding functionality to these buttons. Code will be split across several include files. The sole purpose is to demonstrate capabilities of PHC-Win covered on the next page.
Individual files
Individual files are added to C:\us_wb\my_app\z_basic.phpw as shown below:
Include "../wb/php/include/winbinder.php"; // Location Of Winbinder Library Include "button_1_toggle.inc.php"; Include "button_2_toggle.inc.php"; Include "red_1_on.inc.php"; Include "red_2_on.inc.php"; Include "green_1_on.inc.php"; Include "green_2_on.inc.php";
There are six in all, each containing a single function as follows:
button_1_toggle.inc.php
<?php
function button_1_toggle(){
global $mainwin;
$text = wb_get_text(wb_get_control($mainwin, IDC_BUTTONRED1)); // get button txt
if($text == 'Red 1'){
red_1_on();
wb_set_text(wb_get_control($mainwin, IDC_BUTTONRED1),'Green 1'); // Change button text
}
if($text == 'Green 1'){
green_1_on();
wb_set_text(wb_get_control($mainwin, IDC_BUTTONRED1),'Red 1'); // Change button text
}
}
?>
button_2_toggle.inc.php
<?php
function button_2_toggle(){
global $mainwin;
$text = wb_get_text(wb_get_control($mainwin, IDC_BUTTONRED2)); // get button txt
if($text == 'Red 2'){
red_2_on();
wb_set_text(wb_get_control($mainwin, IDC_BUTTONRED2),'Green 2'); // Change button text
}
if($text == 'Green 2'){
green_2_on();
wb_set_text(wb_get_control($mainwin, IDC_BUTTONRED2),'Red 2'); // Change button text
}
}
?>
red_1_on.inc.php
<?php
function red_1_on(){
global $mainwin;
wb_set_visible(wb_get_control($mainwin, IDC_FRAMERED1),TRUE);; // red 1 on
wb_set_visible(wb_get_control($mainwin, IDC_FRAMEGREEN1),FALSE); // green 1 off
}
?>
red_2_on.inc.php
<?php
function red_2_on(){
global $mainwin;
wb_set_visible(wb_get_control($mainwin, IDC_FRAMERED2),TRUE);; // red 2 on
wb_set_visible(wb_get_control($mainwin, IDC_FRAMEGREEN2),FALSE); // green 2 off
}
?>
green_1_on.inc.php
<?php
function green_1_on(){
global $mainwin;
wb_set_visible(wb_get_control($mainwin, IDC_FRAMERED1),FALSE);; // red 1 off
wb_set_visible(wb_get_control($mainwin, IDC_FRAMEGREEN1),TRUE); // green 1 on
}
?>
green_2_on.inc.php
<?php
function green_2_on(){
global $mainwin;
wb_set_visible(wb_get_control($mainwin, IDC_FRAMERED2),FALSE);; // red 2 off
wb_set_visible(wb_get_control($mainwin, IDC_FRAMEGREEN2),TRUE); // green 2 on
}
?>
|
Summary
That completes our masterpiece. It is now ready for packaging and distribution.
The next page covers PHC-Win which makes the whole process very easy.
