PHP WinBinder: Template: Difference between revisions

m
Reverted edits by Upazixorys (Talk); changed back to last version by BobS
No edit summary
m (Reverted edits by Upazixorys (Talk); changed back to last version by BobS)
 
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 19: Line 18:
|-
|-
|
|
<pre>
<pre>
&lt;?php
<?php
Include &quot;../php/include/winbinder.php&quot;;          // Location Of Winbinder Library
Include "../php/include/winbinder.php";          // Location Of Winbinder Library


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


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


Line 37: Line 36:
   }
   }
}
}
?&gt;
?>
&lt;/pre&gt;
</pre>
|
|
&amp;nbsp;
&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 61: Line 60:
|-
|-
|
|
&lt;pre&gt;
<pre>
Include &quot;../php/include/winbinder.php&quot;;
Include "../php/include/winbinder.php";
&lt;/pre&gt;
</pre>
|
|
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.
|-
|-
|
|
&lt;pre&gt;
<pre>
$mainwin=wb_create_window(NULL,AppWindow,&quot;XXX&quot;,320,240);
$mainwin=wb_create_window(NULL,AppWindow,"XXX",320,240);
&lt;/pre&gt;
</pre>
|
|
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.  
|-
|-
|
|
&lt;pre&gt;
<pre>
wb_set_handler($mainwin,&quot;process_main&quot;);
wb_set_handler($mainwin,"process_main");
&lt;/pre&gt;
</pre>
|
|
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.   
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.   
|-
|-
|
|
&lt;pre&gt;
<pre>
wb_main_loop();
wb_main_loop();
&lt;/pre&gt;
</pre>
|
|
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).   
|-
|-
|
|
&lt;pre&gt;
<pre>
function process_main($window, $id)   
function process_main($window, $id)   
&lt;/pre&gt;
</pre>
|
|
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.
|-
|-
|
|
&lt;pre&gt;
<pre>
switch($id)   
switch($id)   
&lt;/pre&gt;
</pre>
|
|
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.   
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.   
|-
|-
|
|
&lt;pre&gt;
<pre>
wb_destroy_window($window);
wb_destroy_window($window);
&lt;/pre&gt;
</pre>
|
|
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 126: Line 125:
|-
|-
|
|
&lt;pre&gt;
<pre>




Line 134: Line 133:




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


* '''..\php\php.exe''' - Move up one folder level and down into folder php&lt;br /&gt; run PHP CLI interface program '''php.exe'''
* '''..\php\php.exe''' - Move up one folder level and down into folder php<br /> 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 155: Line 154:
|-
|-
|
|
&lt;pre&gt;
<pre>




Line 161: Line 160:




&lt;/pre&gt;
</pre>
|
|
* Replace script and paths as appropriate.
* Replace script and paths as appropriate.
Line 177: Line 176:
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=&quot;top&quot;
|-valign="top"
|
|
&lt;pre&gt;
<pre>
&lt;?php
<?php
Include &quot;../php/include/winbinder.php&quot;;      // Location Of Winbinder Library
Include "../php/include/winbinder.php";      // Location Of Winbinder Library


//=== 1) Create main window ---------------------------------------------------
//=== 1) Create main window ---------------------------------------------------
$mainwin = wb_create_window(NULL, AppWindow, &quot;Test 1&quot;, 320, 240);
$mainwin = wb_create_window(NULL, AppWindow, "Test 1", 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, &quot;process_main&quot;);       
wb_set_handler($mainwin, "process_main");       


//=== 5) Enter application loop -----------------------------------------------
//=== 5) Enter application loop -----------------------------------------------
Line 204: Line 203:
   }
   }
}
}
?&gt;
?>
&lt;/pre&gt;
</pre>
|
|
&amp;nbsp;
&nbsp;
|
|
&lt;br /&gt;
<br />
'''''Window produced by script'''''
'''''Window produced by script'''''
&amp;nbsp;[[Image:WinBinder_1.gif]]
&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