PHP WinBinder 2: Add code: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(New page: {{Nav 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...)
 
(Proofreading and grammatical changes; some minor reformatting)
 
Line 4: Line 4:
On the previous page we finished with a bare windows application containing two buttons and indicators.
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, sole purpose is to demonstrate capabilities of PHC-Win covered on the [[PHP WinBinder 2: PHC-Win | next page]].
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 [[PHP WinBinder 2: PHC-Win | next page]].


'''''[[#top | Top]]'''''
== Individual files ==
== Individual files ==
Individual files are added to C:\us_wb\my_app\'''z_basic.phpw''' as shown below:
Individual files are added to C:\us_wb\my_app\'''z_basic.phpw''' as shown below:
Line 19: Line 18:
Include "green_2_on.inc.php";
Include "green_2_on.inc.php";
</pre>
</pre>
There are six in all each containing a single function as follows:
There are six in all, each containing a single function as follows:


'''button_1_toggle.inc.php'''
'''button_1_toggle.inc.php'''
Line 39: Line 38:
?>
?>
</pre>
</pre>
'''''[[#top | Top]]'''''
 


'''button_2_toggle.inc.php'''
'''button_2_toggle.inc.php'''
Line 59: Line 58:
?>
?>
</pre>
</pre>
'''''[[#top | Top]]'''''
 


'''red_1_on.inc.php'''
'''red_1_on.inc.php'''
Line 71: Line 70:
?>
?>
</pre>
</pre>
'''''[[#top | Top]]'''''
 


'''red_2_on.inc.php'''
'''red_2_on.inc.php'''
Line 83: Line 82:
?>
?>
</pre>
</pre>
'''''[[#top | Top]]'''''
 


'''green_1_on.inc.php'''
'''green_1_on.inc.php'''
Line 95: Line 94:
?>
?>
</pre>
</pre>
'''''[[#top | Top]]'''''
 


'''green_2_on.inc.php'''
'''green_2_on.inc.php'''
Line 107: Line 106:
?>
?>
</pre>
</pre>
'''''[[#top | Top]]'''''
 
{|
{|
|-valign="top"
|-valign="top"
Line 121: Line 120:


== Summary ==
== Summary ==
That completes our masterpiece it is now ready for packaging and distribution.
That completes our masterpiece. It is now ready for packaging and distribution.


Next page covers [[PHP WinBinder 2: PHC-Win | '''PHC-Win''']] which makes the whole process very easy.
The next page covers [[PHP WinBinder 2: PHC-Win | '''PHC-Win''']] which makes the whole process very easy.


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''

Latest revision as of 19:00, 2 February 2010

 

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
}
?>
  • Run C:\us_wb\my_app\z_basic.bat
  • Each button toggles between Red and Green.
  • Each indicator toggles between Red and Green.

Top

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.

Top