PHP WinBinder: Template: Difference between revisions

Jump to navigation Jump to search
no edit summary
(Proofreading and grammatical changes; some minor reformatting)
No edit summary
Line 1: Line 1:
=[http://acisabukody.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
{{Nav PHP WinBinder}}
{{Nav PHP WinBinder}}
'''''Windows application template'''''
'''''Windows application template'''''
Line 18: Line 19:
|-
|-
|
|
<pre>
&lt;pre&gt;
<?php
&lt;?php
Include "../php/include/winbinder.php";          // Location Of Winbinder Library
Include &quot;../php/include/winbinder.php&quot;;          // Location Of Winbinder Library


$mainwin = wb_create_window(NULL, AppWindow, "XXX", 320, 240); // Create main window
$mainwin = wb_create_window(NULL, AppWindow, &quot;XXX&quot;, 320, 240); // Create main window


wb_set_handler($mainwin, "process_main");        // Assign handler to main window.  
wb_set_handler($mainwin, &quot;process_main&quot;);        // Assign handler to main window.  
wb_main_loop();                                  // Enter application loop  
wb_main_loop();                                  // Enter application loop  


Line 36: Line 37:
   }
   }
}
}
?>
?&gt;
</pre>
&lt;/pre&gt;
|
|
&nbsp;
&amp;nbsp;
|
|
This really is an elegant script because it masks all the complexity associated with creating a Windows application.
This really is an elegant script because it masks all the complexity associated with creating a Windows application.
Line 60: Line 61:
|-
|-
|
|
<pre>
&lt;pre&gt;
Include "../php/include/winbinder.php";
Include &quot;../php/include/winbinder.php&quot;;
</pre>
&lt;/pre&gt;
|
|
Every Windows script you create must contain this line. It pulls in all the WinBinder functions. If your script is located in another folder, change the path accordingly.
Every Windows script you create must contain this line. It pulls in all the WinBinder functions. If your script is located in another folder, change the path accordingly.
|-
|-
|
|
<pre>
&lt;pre&gt;
$mainwin=wb_create_window(NULL,AppWindow,"XXX",320,240);
$mainwin=wb_create_window(NULL,AppWindow,&quot;XXX&quot;,320,240);
</pre>
&lt;/pre&gt;
|
|
This function creates an application window with title XXX (change this to something meaningful). The window will have a width of 320 pixels and height of 240; again, these are changeable.  
This function creates an application window with title XXX (change this to something meaningful). The window will have a width of 320 pixels and height of 240; again, these are changeable.  
|-
|-
|
|
<pre>
&lt;pre&gt;
wb_set_handler($mainwin,"process_main");
wb_set_handler($mainwin,&quot;process_main&quot;);
</pre>
&lt;/pre&gt;
|
|
Generally every window action (mouse movement, button click) requires processing. This is performed by a single function assigned to the main window. The function receives the ID of an event that requires processing. The function "process_main" is referred to as a handler. Hence Assign handler to main window. Note that if this function cannot handle the request it is passed onto a system default handler.   
Generally every window action (mouse movement, button click) requires processing. This is performed by a single function assigned to the main window. The function receives the ID of an event that requires processing. The function &quot;process_main&quot; is referred to as a handler. Hence Assign handler to main window. Note that if this function cannot handle the request it is passed onto a system default handler.   
|-
|-
|
|
<pre>
&lt;pre&gt;
wb_main_loop();
wb_main_loop();
</pre>
&lt;/pre&gt;
|
|
This function effectively keeps the window alive. The call to wb_main_loop() must be the last executable statement of the PHP script. All statements after it will be ignored (this does not apply to any functions after it).   
This function effectively keeps the window alive. The call to wb_main_loop() must be the last executable statement of the PHP script. All statements after it will be ignored (this does not apply to any functions after it).   
|-
|-
|
|
<pre>
&lt;pre&gt;
function process_main($window, $id)   
function process_main($window, $id)   
</pre>
&lt;/pre&gt;
|
|
The handler function processes all events occurring in our window $window. Each event produces an ID. Any event not handled is passed on to a default system handler.
The handler function processes all events occurring in our window $window. Each event produces an ID. Any event not handled is passed on to a default system handler.
|-
|-
|
|
<pre>
&lt;pre&gt;
switch($id)   
switch($id)   
</pre>
&lt;/pre&gt;
|
|
The handler consists of a switch statement with each case corresponding to a specific ID. In this example a single case is shown: '''IDCLOSE'''. This constant is set to 8. Closing a window (clicking the "X" in the top right corner) sends ID 8 to the handler.   
The handler consists of a switch statement with each case corresponding to a specific ID. In this example a single case is shown: '''IDCLOSE'''. This constant is set to 8. Closing a window (clicking the &quot;X&quot; in the top right corner) sends ID 8 to the handler.   
|-
|-
|
|
<pre>
&lt;pre&gt;
wb_destroy_window($window);
wb_destroy_window($window);
</pre>
&lt;/pre&gt;
|
|
Every program must include this function. It terminates the window and performs a clean-up operation  
Every program must include this function. It terminates the window and performs a clean-up operation  
Line 125: Line 126:
|-
|-
|
|
<pre>
&lt;pre&gt;




Line 133: Line 134:




</pre>
&lt;/pre&gt;
|
|


* '''..\php\php.exe''' - Move up one folder level and down into folder php<br /> run PHP CLI interface program '''php.exe'''
* '''..\php\php.exe''' - Move up one folder level and down into folder php&lt;br /&gt; run PHP CLI interface program '''php.exe'''
* '''-c ..\php\php-wb.ini''' - Force PHP to use configuration file '''php-wb.ini'''
* '''-c ..\php\php-wb.ini''' - Force PHP to use configuration file '''php-wb.ini'''
* '''test_1.phpw''' - PHP script to run (note extension '''phpw''' you can use '''php''')  
* '''test_1.phpw''' - PHP script to run (note extension '''phpw''' you can use '''php''')  
Line 154: Line 155:
|-
|-
|
|
<pre>
&lt;pre&gt;




Line 160: Line 161:




</pre>
&lt;/pre&gt;
|
|
* Replace script and paths as appropriate.
* Replace script and paths as appropriate.
Line 176: Line 177:
The file is divided into sections. These are required for all windows applications.   
The file is divided into sections. These are required for all windows applications.   
{|
{|
|-valign="top"
|-valign=&quot;top&quot;
|
|
<pre>
&lt;pre&gt;
<?php
&lt;?php
Include "../php/include/winbinder.php";      // Location Of Winbinder Library
Include &quot;../php/include/winbinder.php&quot;;      // Location Of Winbinder Library


//=== 1) Create main window ---------------------------------------------------
//=== 1) Create main window ---------------------------------------------------
$mainwin = wb_create_window(NULL, AppWindow, "Test 1", 320, 240);
$mainwin = wb_create_window(NULL, AppWindow, &quot;Test 1&quot;, 320, 240);


//=== 2) Create controls for the main window ----------------------------------
//=== 2) Create controls for the main window ----------------------------------


//=== 3) Assign handler function to the main window  --------------------------
//=== 3) Assign handler function to the main window  --------------------------
wb_set_handler($mainwin, "process_main");       
wb_set_handler($mainwin, &quot;process_main&quot;);       


//=== 5) Enter application loop -----------------------------------------------
//=== 5) Enter application loop -----------------------------------------------
Line 203: Line 204:
   }
   }
}
}
?>
?&gt;
</pre>
&lt;/pre&gt;
|
|
&nbsp;
&amp;nbsp;
|
|
<br />
&lt;br /&gt;
'''''Window produced by script'''''
'''''Window produced by script'''''
&nbsp;[[Image:WinBinder_1.gif]]
&amp;nbsp;[[Image:WinBinder_1.gif]]
* The above window is a blank application.
* The above window is a blank application.
* It has two active controls
* It has two active controls
322

edits

Navigation menu