https://wiki.uniformserver.com/index.php?title=PHP_WinBinder:_Alternative_control_1&feed=atom&action=historyPHP WinBinder: Alternative control 1 - Revision history2024-03-28T16:54:35ZRevision history for this page on the wikiMediaWiki 1.41.0https://wiki.uniformserver.com/index.php?title=PHP_WinBinder:_Alternative_control_1&diff=4068&oldid=prevRic: New page: {{Nav PHP WinBinder}} '''''Alternative control''''' WinBinder is very powerful allowing you to create either simple or complex Windows programs. Uniform server 4-Mona series introduced Un...2010-01-28T07:26:03Z<p>New page: {{Nav PHP WinBinder}} '''''Alternative control''''' WinBinder is very powerful allowing you to create either simple or complex Windows programs. Uniform server 4-Mona series introduced Un...</p>
<p><b>New page</b></p><div>{{Nav PHP WinBinder}}<br />
'''''Alternative control'''''<br />
<br />
WinBinder is very powerful allowing you to create either simple or complex Windows programs. Uniform server 4-Mona series introduced UniController a simple Windows program to control both Apache and MySQL servers. From a users point of view it is extremely easy to use and understand hence it remains popular.<br />
<br />
This section covers a similar interface for Uniform Server Nano-5 series. It’s a no frills application that demonstrates the capability of WinBinder. It’s a step-by-step guide and includes a working example at each step of the design.<br />
<br />
==Specification==<br />
A design starts with a specification, this can be a written document or as in this case a description of what it is intended to do for example:<br />
{|width="100%"<br />
|-valign="top"<br />
|'''''UniController'':'''<br />
* Has&nbsp;a&nbsp;minimal&nbsp;user&nbsp;interface&nbsp;and&nbsp;built&nbsp;in&nbsp;diagnostics.<br />
* Checks server ports in use<br />
* Has the capability to run multi-servers.<br />
* Independent control of Apache and MySQL servers<br />
* Apache configuration syntax check.<br />
* Option to open a MySQL CMD (command) window.<br />
|width="247px"|[[Image:UnicontrollerV2.gif]]<br />
|<br />
Apart from test all buttons perform what’s displayed.<br><br />
Test hides its functionality because it supports options that are rarely used.<br />
* The initial click checks server port status.<br />
* Then offers a choice to check Apache configuration syntax.<br />
* Finally offers a choice to run a MySQL prompt.<br />
|}<br />
<br />
'''''Note'':'''<br />
<br />
Original buttons used a rollover effect this adds unnecessary complexity and will not be implemented in this design.<br />
<br />
UniServer 5-Nano series don’t use a virtual drive the label and input box are deleted. This leaves a gap, we can fill with two additional buttons. <br />
<br />
The "About" button occupies valuable space adding nothing to functionality hence replace with a button that performs something useful.<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
== Starting point ==<br />
{|<br />
|-valign="top"<br />
|<br />
* Create a new folder UniServer\plugins\winbinder\'''alt_con_1'''<br />
* From folder UniServer\plugins\winbinder\'''examples''' copy files '''test_1.bat''' and '''test_1.phpw''' to it.<br />
<br />
Run test_1.bat it crates a basic window.<br />
<br />
This window needs to be modified as follows:<br />
<br />
Edit file '''test_1.phpw'''<br />
<br />
There are three changes to section 1 and a single chage in section 3 as follows: <br />
<br />
* 1) Run as Single application instance [[PHP WinBinder: Tab Control 3#Single application instance |see page]]<br />'''''Note'':''' This program's name is '''UniController'''<br />
<br />
* 1) Application minimize to system tray [[PHP WinBinder: Tab Control 3#Application minimize to system tray |see page]] (style WBC_TASKBAR)<br />
<br />
* 1) Application always on top use style WBC_TOP<br />
<br />
* 3) Add a logo (icon) [[PHP WinBinder: Tab Control 3#Add a logo-icon |see page]]<br />
|<br />
'''test_1.phpw'''<br />
<pre><br />
<?php<br />
Include "../php/include/winbinder.php"; // Location Of Winbinder Library<br />
<br />
//=== 1) Create main window ---------------------------------------------------<br />
define("CAPTION", "UniController"); // Set caption to match application<br />
if(wb_get_instance(CAPTION, TRUE)) // Is there an existing instance?<br />
die; // Yes: bring it to the front and quit<br />
<br />
$mainwin = wb_create_window(NULL, AppWindow, "UniController", WBC_CENTER,<br />
WBC_CENTER, 255, 165, WBC_NOTIFY| WBC_TASKBAR | WBC_TOP , WBC_HEADERSEL);<br />
<br />
<br />
//=== 2) Create controls for the main window ----------------------------------<br />
<br />
//=== 3) Assign handler function to the main window --------------------------<br />
wb_set_handler($mainwin, "process_main");<br />
wb_set_image($mainwin, "./" . "uslogo.ico"); // Add logo <br />
<br />
//=== 5) Enter application loop -----------------------------------------------<br />
wb_main_loop(); <br />
<br />
//=== 4) Handler Function -----------------------------------------------------<br />
function process_main($window, $id) <br />
{<br />
switch($id) { <br />
<br />
case IDCLOSE: // Constant IDCLOSE (8) predefined <br />
wb_destroy_window($window); // Destroy the window<br />
break; <br />
}<br />
}<br />
?><br />
</pre><br />
|}<br />
'''''[[#top | Top]]'''''<br />
<br />
== Add Controls ==<br />
Create a copy of '''test_1.phpw''' rename it '''test_2.phpw'''<br />
<br />
Add controls as shown below:<br />
<br />
'''test_2.phpw'''<br />
<pre><br />
<?php<br />
Include "../php/include/winbinder.php"; // Location Of Winbinder Library<br />
<br />
//-- Constants ----------------------------------------------------------------<br />
<br />
define("ID_L1101", 1101); // Label Server version <br />
<br />
define("ID_PB_ALL", 1201); // Push button Start/Stop servers<br />
define("ID_PB_APACHE", 1202); // Push button Start/Stop Apache <br />
define("ID_PB_MYSQL", 1203); // Push button Start/Stop MySQL<br />
<br />
define("ID_PB_APANEL", 1204); // Push button Apanel<br />
define("ID_PB_PHPMYADMIN", 1205); // Push button phpMyAdmin<br />
define("ID_PB_MYCMD", 1206); // Push button My CMD<br />
define("ID_PB_LOGS", 1207); // Push button Logs<br />
define("ID_PB_TEST", 1208); // Push button Test<br />
define("ID_PB_EDIT", 1209); // Push button Edit<br />
<br />
define("ID_F_APACHE_RED", 1420); // Frame indicator red Apache <br />
define("ID_F_APACHE_GREEN", 1421); // Frame indicator green Apache<br />
define("ID_F_MYSQL_RED", 1422); // Frame indicator red MySQL <br />
define("ID_F_MYSQL_GREEN", 1423); // Frame indicator green MySQL<br />
<br />
define("ID_F_LOGO", 1424); // Images logo <br />
<br />
//=== 1) Create main window ===================================================<br />
define("CAPTION", "UniController"); // Set caption to match application<br />
if(wb_get_instance(CAPTION, TRUE)) // Is there an existing instance?<br />
die; // Yes: bring it to the front and quit<br />
<br />
$mainwin = wb_create_window(NULL, AppWindow, "UniController", WBC_CENTER,<br />
WBC_CENTER, 240, 155, WBC_NOTIFY| WBC_TASKBAR | WBC_TOP , WBC_HEADERSEL);<br />
<br />
//=== 2) Create controls for the main window ==================================<br />
//-- Label version<br />
wb_create_control($mainwin, Label, "Server 5.0-Nano", 114, 6, 101, 41, ID_L1101, 0, 0, 3);<br />
<br />
//-- Image logo<br />
$frame = wb_create_control($mainwin, Frame, "", 4, 4, 99, 39, ID_F_LOGO, WBC_IMAGE); // Apache OFF<br />
wb_set_image($frame, 'Logo.bmp', NOCOLOR);<br />
<br />
//-- Create indicators<br />
$frame = wb_create_control($mainwin, Frame, "", 209, 27, 20, 12, ID_F_APACHE_RED, WBC_IMAGE); // Apache OFF<br />
wb_set_image($frame, 'red.bmp', NOCOLOR);<br />
$frame = wb_create_control($mainwin, Frame, "", 209, 27, 20, 12, ID_F_APACHE_GREEN, WBC_IMAGE); // Apache ON<br />
wb_set_image($frame, 'green.bmp', NOCOLOR);<br />
<br />
$frame = wb_create_control($mainwin, Frame, "", 209, 52, 20, 12, ID_F_MYSQL_RED, WBC_IMAGE); // MySQL OFF<br />
wb_set_image($frame, 'red.bmp', NOCOLOR);<br />
$frame = wb_create_control($mainwin, Frame, "", 209, 52, 20, 12, ID_F_MYSQL_GREEN, WBC_IMAGE); // MySQL ON<br />
wb_set_image($frame, 'green.bmp', NOCOLOR);<br />
<br />
//-- Buttons<br />
wb_create_control($mainwin, PushButton, 'Start All', 4, 49, 99, 20, ID_PB_ALL, 0, 0, 0);<br />
wb_create_control($mainwin, PushButton, 'Start Apache', 110, 24, 90, 20, ID_PB_APACHE, 0, 0, 0);<br />
wb_create_control($mainwin, PushButton, 'Start MySQL', 110, 49, 90, 20, ID_PB_MYSQL, 0, 0, 0);<br />
wb_create_control($mainwin, PushButton, 'Apanel', 4, 74, 99, 20, ID_PB_APANEL, 0, 0, 0);<br />
wb_create_control($mainwin, PushButton, 'phpMyAdmin', 4, 99, 99, 20, ID_PB_PHPMYADMIN, 0, 0, 0);<br />
<br />
wb_create_control($mainwin, PushButton, 'My CMD', 109, 74, 57, 20, ID_PB_MYCMD, 0, 0, 0);<br />
wb_create_control($mainwin, PushButton, 'Logs', 173, 74, 57, 20, ID_PB_LOGS, 0, 0, 0);<br />
<br />
wb_create_control($mainwin, PushButton, 'Test', 109, 99, 57, 20, ID_PB_TEST, 0, 0, 0);<br />
wb_create_control($mainwin, PushButton, 'Edit', 173, 99, 57, 20, ID_PB_EDIT, 0, 0, 0);<br />
<br />
//=== 3) Assign handler function to the main window ===========================<br />
wb_set_handler($mainwin, "process_main");<br />
wb_set_image($mainwin, "./" . "uslogo.ico"); // Add logo <br />
<br />
//=== 5) Enter application loop ===============================================<br />
wb_main_loop(); <br />
<br />
//=== 4) Handler Function =====================================================<br />
function process_main($window, $id) <br />
{<br />
switch($id) { <br />
<br />
case IDCLOSE: // Constant IDCLOSE (8) predefined <br />
wb_destroy_window($window); // Destroy the window<br />
break; <br />
}<br />
}<br />
?><br />
<br />
</pre><br />
It’s a fully functional Windows program. To see it in action run file UniServer\plugins\winbinder\alt_con_1\'''test_2.bat'''<br />
<br />
'''''[[#top | Top]]'''''<br />
=== Images ===<br />
For comparision I have shown the two controllers side-by-side:<br />
{|<br />
|-valign="top"<br />
|<br />
'''''New Version'''''<br /><br />
[[Image:WinBinder_Unicon_1.gif]]<br />
|<br />
'''''Old Version'''''<br /><br />
[[Image:UnicontrollerV2.gif]]<br />
|<br />
<br /><br /><br />
'''''New Version'''''<br />
* In terms of physical size the new version is smaller.<br />
* Ergonomically it is cleaner<br />
* It retains a simple click and “go” approach.<br />
* New buttons add additional functionality.<br />
|}<br />
It may look pretty! However for a real application it lacks functionality click any button and you will find it produces no results. <br />
<br />
Remainder of this tutorial looks at adding functionality.<br />
<br />
Make a copy of test_2.phpw and rename it test_3.phpw add the following:<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
== Includes ==<br />
In order to tap into UniServr’s control core you need to include the following two files:<br />
<pre><br />
include "../../../unicon/main/includes/config.inc.php"; // US Core<br />
include "../../../unicon/main/includes/functions.php"; // US Core <br />
</pre><br />
They provide pre-defined variables, constants and functions that can be used in your windows application.<br />
<br />
'''''[[#top | Top]]'''''<br />
== Initialisation ==<br />
Before adding any functionality to the push buttons some basic initialisation is required.<br />
<br />
=== Port Check ===<br />
Server ports may already be in use preventing this server running. Just below the constant section add port checking code as shown below<br />
<pre><br />
//Port check and alert<br />
if(port_in_use(get_apache_port()) && get_apache_tracker() == "free"){<br />
$port = get_apache_port();<br />
wb_message_box(NULL, "Apache port: $port \nIn use by another program.","Apach Port", WBC_WARNING); <br />
}<br />
if(port_in_use(get_apache_ssl_port()) && get_apache_tracker() == "free"){<br />
$port = get_apache_ssl_port();<br />
wb_message_box(NULL, "Apache poert: $port\nIn use by another program.","Apache Port", WBC_WARNING); <br />
}<br />
if(port_in_use(get_mysql_port()) && get_mysql_tracker() == "free"){<br />
$port = get_mysql_port();<br />
wb_message_box(NULL, "MySQL port: $port\nIn use by another program.","MySQL Port", WBC_WARNING); <br />
}<br />
</pre><br />
The above could be written as a single alert however one per port emphasises there is a real problem.<br />
<br />
'''''Note'':''' Ports are obtained from appropriate configuration files using core functions get_apache_port(), get_apache_ssl_port() and get_mysql_port()<br />
<br />
A user can change these at any time so always read the current value from a configuration file before using. <br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
=== Server moved check ===<br />
The servers are portable to achieve this every time the control program is started it must run function run_location_tracker(). <br />
<br />
This function compares current server location to that stored in tracker file (UniServer\unicon\main\location_tracker.txt) if the two paths are different all absolute paths in appropriate configuration files are rewritten to new location and tracker file updated accordingly. If the two paths match no action is taken.<br />
<br />
Above the window creation line add the following:<br />
<pre><br />
run_location_tracker(); // Have servers moved if moved update configuration<br />
</pre><br />
'''''[[#top | Top]]'''''<br />
=== Server Version ===<br />
Current server version is contained in variable $us_version to display this to a user:<br />
Change the following line:<br />
<pre><br />
//-- Label version<br />
wb_create_control($mainwin, Label, "Server 5.0-Nano", 114, 6, 101, 41, ID_L_VERSION, 0, 0, 3);<br />
</pre><br />
To this:<br />
<pre><br />
//-- Label version<br />
wb_create_control($mainwin, Label, "Server $us_version", 114, 6, 101, 41, ID_L_VERSION, 0, 0, 3);<br />
</pre><br />
The label caption is updated to that of the current server version.<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
=== Main init function ===<br />
Before starting the main loop with function wb_main_loop() add any initialisation to section 3. Currently the logo image is set in this section.<br />
<br />
For our program we want a general purpose initialisation function '''main_init()''' that runs once when the program is started and thereafter when we perform specific actions. A call to this function is added to this section as follows:<br />
<pre><br />
wb_set_image($mainwin, "./" . "uslogo.ico"); // Add logo <br />
main_init();<br />
</pre><br />
If you run the script a fatal error will occur.<br />
<br />
To the end of your script add the following dummy function. We will fill the details in later<br />
<pre><br />
//=== Initialise Main =========================================================<br />
function main_init(){<br />
global $mainwin;<br />
wb_message_box($mainwin, "Main Init","Temp", WBC_OK); <br />
}<br />
//===================================================== END Initialise Main ===<br />
</pre><br />
'''''[[#top | Top]]'''''<br />
<br />
=== Summary ===<br />
That completes the initial groundwork to see an example run test_3.bat the code is contained in file test_3.phpw<br />
<br />
With the above structure in place we can start adding functionally.<br />
<br />
'''''[[#top | Top]]'''''<br />
== Function main_init() ==<br />
The three buttons "Start All", "Start Apache" and "Start MySQL" toggle between two states start and stop.<br />
<br />
A separate variable is not required to store a button state by virtue of its caption each button inherently has a memory.<br />
<br />
Apache and MySQL operating state define button and indicator states as follows.<br />
<br />
* Apache indicator: Red server not running. Green server running<br />
* MuSQL indicator: Red server not running. Green server running<br />
* Start All button: No servers running displays "Start All" both servers running displays "Stop All" One or other server running button disabled.<br />
* Apache button: Server not running displays "Start Apache" server running displays "Stop Apache" <br />
* MySQL button: Server not running displays "Start MySQL" server running displays "Stop MySQL" <br />
* Apanel button: Apache not running button disabled. Apache running button enabled.<br />
* phpMyAdmin button: Apache not running button disabled. Apache running button enabled.<br />
<br />
Starting our application requires the above states to be checked and button and indicators updated accordingly. A user starting or stopping a server again requires the above state check and updates. Code for this is placed in the main_init() function<br />
<br />
Code as follows:<br />
{|<br />
|-valign="top"<br />
|<br />
<br /><br /><br /><br /><br />
Set status of servers<br />
<br />
Variables $AP and $MP are shorthand for<br />
* Servers running “TRUE”<br />
* Or not running “FALSE”<br />
just makes coding a little easier<br />
<br />
<br /><br /><br /><br /><br /><br />
Both servers not running<br />
<br />
Set button message a set indicator accordingly<br />
<br />
<br /><br /><br /><br /><br /><br /><br /><br />
MySQL running $MP<br />
<br />
Set button message a set indicator accordingly<br />
<br />
<br /><br /><br /><br /><br /><br /><br /><br />
Apache running $AP<br />
<br />
Set button message a set indicator accordingly<br />
<br />
<br /><br /><br /><br /><br /><br /><br /><br />
Both servers running<br />
<br />
Set button message a set indicator accordingly<br />
|<br />
<pre><br />
//== Set status of servers<br />
<br />
// Apache running as a program $AP<br />
if(apache_running()){<br />
$AP = TRUE;<br />
}<br />
else{<br />
$AP = FALSE;<br />
}<br />
<br />
// MySQL running as a program $MP<br />
if(mysql_running()){<br />
$MP = TRUE;<br />
}<br />
else{<br />
$MP = FALSE;<br />
} <br />
<br />
//00<br />
if(!$AP & !$MP){<br />
mp_apache_indicator_on(FALSE); // OFF<br />
mp_mysql_indicator_on(FALSE); // OFF<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_APANEL), FALSE); // Disable Apanel<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_PHPMYADMIN), FALSE); // Disable phpMyAdmin<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_MYCMD), FALSE); // Disabe MySQL CMD button<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_ALL), TRUE); // Enable ALL server button <br />
wb_set_text(wb_get_control($mainwin, ID_PB_APACHE),'Start Apache'); // set button<br />
wb_set_text(wb_get_control($mainwin, ID_PB_MYSQL),'Start MySQL'); // set button <br />
wb_set_text(wb_get_control($mainwin, ID_PB_ALL),'Start All'); // set button <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_APACHE), TRUE); // Enable Apache button <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_MYSQL), TRUE); // Enable MySQL button<br />
}<br />
<br />
//01<br />
if(!$AP & $MP){<br />
mp_apache_indicator_on(FALSE); // OFF<br />
mp_mysql_indicator_on(TRUE); // ON<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_APANEL), FALSE); // Disable Apanel<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_PHPMYADMIN), FALSE); // Disable phpMyAdmin<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_MYCMD), TRUE); // Enable MySQL CMD button<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_ALL), FALSE); // Disable All server button <br />
wb_set_text(wb_get_control($mainwin, ID_PB_APACHE),'Start Apache'); // set button<br />
wb_set_text(wb_get_control($mainwin, ID_PB_MYSQL),'Stop MySQL'); // set button<br />
wb_set_text(wb_get_control($mainwin, ID_PB_ALL),'Stop ???'); // set button <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_APACHE), TRUE); // Enable Apache button <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_MYSQL), TRUE); // Enable MySQL button<br />
}<br />
<br />
//10<br />
if($AP & !$MP){<br />
mp_apache_indicator_on(TRUE); // ON<br />
mp_mysql_indicator_on(FALSE); // OFF <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_APANEL), TRUE); // Enable Apanel <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_PHPMYADMIN), TRUE); // Disable phpMyAdmin<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_MYCMD), FALSE); // Disabe MySQL CMD button<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_ALL), FALSE); // Disable All server button <br />
wb_set_text(wb_get_control($mainwin, ID_PB_APACHE),'Stop Apache'); // set button<br />
wb_set_text(wb_get_control($mainwin, ID_PB_MYSQL),'Start MySQL'); // set button <br />
wb_set_text(wb_get_control($mainwin, ID_PB_ALL),'Stop ???'); // set button <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_APACHE), TRUE); // Enable Apache button <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_MYSQL), TRUE); // Enable MySQL button<br />
}<br />
<br />
//11<br />
if($AP & $MP){<br />
mp_apache_indicator_on(TRUE); // ON <br />
mp_mysql_indicator_on(TRUE); // ON<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_APANEL), TRUE); // Enable Apanel <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_PHPMYADMIN), TRUE); // Disable phpMyAdmin<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_MYCMD), TRUE); // Enable MySQL CMD button<br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_ALL), TRUE); // Enable ALL server button <br />
wb_set_text(wb_get_control($mainwin, ID_PB_APACHE),'Stop Apache'); // set button<br />
wb_set_text(wb_get_control($mainwin, ID_PB_MYSQL),'Stop MySQL'); // set button<br />
wb_set_text(wb_get_control($mainwin, ID_PB_ALL),'Stop All'); // set button <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_APACHE), TRUE); // Enable Apache button <br />
wb_set_enabled(wb_get_control($mainwin, ID_PB_MYSQL), TRUE); // Enable MySQL button<br />
}<br />
</pre> <br />
|}<br />
'''''[[#top | Top]]'''''<br />
=== Indicator functions ===<br />
{|<br />
|-valign="top"<br />
|<br />
<br /><br />
There are two funtions that toggle the indicator states<br />
<br />
* mp_apache_indicator_on(state)<br />
** State TRUE indicator red<br />
** State FALSE indicator green <br />
<br />
* mp_mysql_indicator_on(state)<br />
** State TRUE indicator red<br />
** State FALSE indicator green <br />
<br />
The code switches between red and green images. Using images is relatively faster than drawing the indicators.<br />
<br />
<br />
Add code to end of script <br />
|<br />
<pre><br />
//=== Indicator 1 ==============================================================<br />
// Apache standard program indicator<br />
function mp_apache_indicator_on($status){<br />
global $mainwin;<br />
<br />
if($status){ // True on green<br />
wb_set_visible(wb_get_control($mainwin, ID_F_APACHE_GREEN),TRUE); // green on<br />
wb_set_visible(wb_get_control($mainwin, ID_F_APACHE_RED),FALSE); // red off<br />
}<br />
else // False off red<br />
{<br />
wb_set_visible(wb_get_control($mainwin, ID_F_APACHE_RED),TRUE); // red on<br />
wb_set_visible(wb_get_control($mainwin, ID_F_APACHE_GREEN),FALSE); // green off<br />
}<br />
}<br />
//======================================================== END Indicator 1 ===<br />
<br />
//=== Indicator 2 ==============================================================<br />
// MySQL standard program indicator<br />
function mp_mysql_indicator_on($status){<br />
global $mainwin;<br />
<br />
if($status){ // True on green<br />
wb_set_visible(wb_get_control($mainwin, ID_F_MYSQL_GREEN),TRUE); // green on<br />
wb_set_visible(wb_get_control($mainwin, ID_F_MYSQL_RED),FALSE); // red off<br />
}<br />
else // False off red<br />
{<br />
wb_set_visible(wb_get_control($mainwin, ID_F_MYSQL_RED),TRUE); // red on<br />
wb_set_visible(wb_get_control($mainwin, ID_F_MYSQL_GREEN),FALSE); // green off<br />
}<br />
}<br />
//======================================================== END Indicator 2 ===<br />
</pre><br />
|}<br />
'''''[[#top | Top]]'''''<br />
<br />
== Test ==<br />
To see this code in action run '''test_4.bat''' (code contained in test_4.phpw)<br />
<br />
'''''Not''e:''' Test button calls function '''main_init()''' this forces a button and indicator refresh.<br />
<br />
Run Uniform Server, from UniTray start and stop each server press Test button and observe button and indicator states. <br />
<br />
After testing close both Uniform Server and application script.<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
== Summary ==<br />
That’s covered a lot of ground however more functionality is requied. <br />
<br />
Next step is to start and stop servers this is covered on the [[PHP WinBinder: Alternative control 2 | '''next page''']].<br />
<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
----<br />
<br />
[[Category: Tutorials]]<br />
[[Category: How To]]<br />
[[Category: Uniform Server 5.0-Nano]]</div>Ric