487
edits
(New page: {{Nav PHP WinBinder 2}} '''''WinBinder Part 2 PHC-Win Resources''''' On the previous page I mentioned image duplication. We included individual images with our distribution package howeve...) |
(Proofreading and grammatical changes; some minor reformatting) |
||
Line 2: | Line 2: | ||
'''''WinBinder Part 2 PHC-Win Resources''''' | '''''WinBinder Part 2 PHC-Win Resources''''' | ||
On the previous page I mentioned image duplication. We included individual images with our distribution package however PHC-Win adds these to the final exe file. | On the previous page I mentioned image duplication. We included individual images with our distribution package, however PHC-Win adds these to the final exe file. | ||
Without making code changes these image resources are not directly accessible by WinBinder hence the reason for adding them to our distribution package. | Without making code changes, these image resources are not directly accessible by WinBinder, hence the reason for adding them to our distribution package. | ||
This page | This page describes code changes required to use images contained within the .exe file, thus eliminating the need for separately including them with the distribution package. | ||
== Embeder overview == | == Embeder overview == | ||
The embeder creates an executable file where additional files may be added. | The embeder creates an executable file where additional files may be added. | ||
These files are added to an array named PHP | These files are added to an array named PHP. Array keys are md5 encoded. A resource file is accessible via its key. | ||
Running | Running this executable creates a unique constant named '''''EMBEDED'''''. | ||
It’s worth looking at the mechanics of this process. | It’s worth looking at the mechanics of this process. | ||
Line 79: | Line 79: | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
== Problem == | == Problem == | ||
Our application uses the following code to assign images : | Our application uses the following code to assign images : | ||
Line 100: | Line 99: | ||
=== Solution === | === Solution === | ||
The solution is as follows: | |||
* Write the image resource to a file on disk | * Write the image resource to a file on disk | ||
* Allow WinBinder to assign this image file (using | * Allow WinBinder to assign this image file (using its path) | ||
* Once assigned is no longer required | * Once assigned, it is no longer required, so delete the image file | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
=== Code === | === Code === | ||
The code is split into three sections. | |||
* First section tests if code is running from the exe using EMBEDED as a reference. If running from exe gets the image resource as a file and saves it to disk with original file name. | * First section tests if code is running from the .exe using EMBEDED as a reference. If running from .exe, it gets the image resource as a file and saves it to disk with the original file name. | ||
* Second section contains original lines that remain unchanged. | * Second section contains original lines that remain unchanged. | ||
* Last section tests if code is running from the exe and deletes file from disk if true. | * Last section tests if code is running from the .exe and deletes the file from disk if true. | ||
This method allows code to be tested with original images. After compiling the exe produced is moved to folder C:\us_wb\my_dis\final for testing. | This method allows code to be tested with original images. After compiling, the .exe produced is moved to folder C:\us_wb\my_dis\final for testing. | ||
{| | {| | ||
|- | |- | ||
| | | | ||
If code is running from exe (EMBEDED true) get resource as a file and save to disk with same file name | If code is running from .exe (EMBEDED true) get resource as a file and save it to disk with same file name. | ||
| | | | ||
<pre> | <pre> | ||
Line 135: | Line 134: | ||
|- | |- | ||
| | | | ||
If running from exe image no longer required | If running from .exe, image no longer required, so delete it. | ||
| | | | ||
<pre> | <pre> | ||
Line 143: | Line 142: | ||
</pre> | </pre> | ||
|} | |} | ||
With the exception of image name each image requires identical code. | With the exception of image name, each image requires identical code. | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
== Modifications == | == Modifications == | ||
Edit file C:\us_wb\my_app\'''z_basic.phpw''' | Edit file C:\us_wb\my_app\'''z_basic.phpw''' | ||
Line 213: | Line 211: | ||
* Designing a Windows application using WinBinder is extremely easy. | * Designing a Windows application using WinBinder is extremely easy. | ||
* Compiling a project with PHC-Win really is a | * Compiling a project with PHC-Win really is a snap, and takes just a few mouse clicks. | ||
* | * A slight negative for a small Windows application is that the distributed code size is relatively large. This is not a significant issue, with the convenience and ease of use of PHP far outweighs this. | ||
* That said core elements of WinBinder are being actively worked on. Both Andrew (Frantik) and Alec Gorge “alecgorge” are pushing to reduce core size further expect significant changes. | * That said core elements of WinBinder are being actively worked on. Both Andrew (Frantik) and Alec Gorge “alecgorge” are pushing to reduce core size further; expect significant changes. | ||
* The WinBinder project remains alive and vibrant. What I really like | * The WinBinder project remains alive and vibrant. What I really like is that you can produce very powerful Windows applications using these tools. The project is well supported and you will find numerous code examples. | ||
* If you get stuck with a problem visit WinBinder’s friendly forum. | * If you get stuck with a problem, visit WinBinder’s friendly forum. | ||