PHP WinBinder 2: Resource: Difference between revisions

no edit summary
(More proofreading and grammatical changes)
No edit summary
Line 1: Line 1:
=[http://awuhodynaro.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]=
{{Nav PHP WinBinder 2}}
{{Nav PHP WinBinder 2}}
'''''WinBinder Part 2 PHC-Win Resources'''''
'''''WinBinder Part 2 PHC-Win Resources'''''
Line 17: Line 18:
It’s worth looking at the mechanics of this process.
It’s worth looking at the mechanics of this process.
{|
{|
|-valign="top"
|-valign="top"
|
|
'''Setup'''
'''Setup'''
Line 24: Line 25:
|
|
'''test.bat'''
'''test.bat'''
<pre>
&lt;pre&gt;
embeder2.exe new test2
embeder2.exe new test2
embeder2.exe add test2 red.bmp ./
embeder2.exe add test2 red.bmp ./
embeder2.exe list test2
embeder2.exe list test2
pause
pause
</pre>
&lt;/pre&gt;
|-valign="top"
|-valign=&quot;top&quot;
|
|
'''Batch file'''
'''Batch file'''
Line 40: Line 41:
'''Run batch file'''
'''Run batch file'''


Run the batch file '''test.bat''' result shown on the right.<br/>It clearly shows the array '''PHP''' and '''md5''' key generated
Run the batch file '''test.bat''' result shown on the right.&lt;br/&gt;It clearly shows the array '''PHP''' and '''md5''' key generated


Note: The md5 is converted to uppercase before being saved to the array.
Note: The md5 is converted to uppercase before being saved to the array.


'''File (resource) access'''<br />Access a resource using the following code format
'''File (resource) access'''&lt;br /&gt;Access a resource using the following code format
{|
{|
|-
|-
|<pre>
|&lt;pre&gt;
res:///PHP/'.strtoupper(md5('./red.exe'))
res:///PHP/'.strtoupper(md5('./red.exe'))
</pre>
&lt;/pre&gt;
|}
|}
|
|
'''Result'''
'''Result'''
<pre>
&lt;pre&gt;


C:\us_wb\phc>embeder2.exe new test2
C:\us_wb\phc&gt;embeder2.exe new test2
'.\test2.exe' created
'.\test2.exe' created


C:\us_wb\phc>embeder2.exe add test2 red.bmp ./
C:\us_wb\phc&gt;embeder2.exe add test2 red.bmp ./
Updated 'res://.\test2.exe/PHP/0374ec857381230fa83049643ce3cdee' with 776 bytes
Updated 'res://.\test2.exe/PHP/0374ec857381230fa83049643ce3cdee' with 776 bytes


C:\us_wb\phc>embeder2.exe list test2
C:\us_wb\phc&gt;embeder2.exe list test2
Res list of '.\test2.exe':
Res list of '.\test2.exe':
PHP
PHP
Line 73: Line 74:
#24
#24


C:\us_wb\phc>pause
C:\us_wb\phc&gt;pause
Press any key to continue . . .
Press any key to continue . . .
</pre>
&lt;/pre&gt;
|}
|}


Line 84: Line 85:
|-
|-
|
|
<pre>
&lt;pre&gt;
wb_set_image(wb_get_control($mainwin, IDC_FRAMERED1),'red.bmp', NOCOLOR);  
wb_set_image(wb_get_control($mainwin, IDC_FRAMERED1),'red.bmp', NOCOLOR);  
wb_set_image(wb_get_control($mainwin, IDC_FRAMERED2), 'red.bmp', NOCOLOR);  
wb_set_image(wb_get_control($mainwin, IDC_FRAMERED2), 'red.bmp', NOCOLOR);  
wb_set_image(wb_get_control($mainwin, IDC_FRAMEGREEN1),'green.bmp', NOCOLOR);  
wb_set_image(wb_get_control($mainwin, IDC_FRAMEGREEN1),'green.bmp', NOCOLOR);  
wb_set_image(wb_get_control($mainwin, IDC_FRAMEGREEN2),'green.bmp', NOCOLOR);   
wb_set_image(wb_get_control($mainwin, IDC_FRAMEGREEN2),'green.bmp', NOCOLOR);   
wb_set_image($mainwin, "uslogo.ico");  // Add logo  
wb_set_image($mainwin, &quot;uslogo.ico&quot;);  // Add logo  
</pre>
&lt;/pre&gt;
|}
|}
The above functions are expecting an image '''file path'''.
The above functions are expecting an image '''file path'''.
Line 118: Line 119:
If code is running from .exe (EMBEDED true) get resource as a file and save it 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>
&lt;pre&gt;
// Assign red image to frames
// Assign red image to frames
if(defined('EMBEDED')){    // If main exe Get image save to disk
if(defined('EMBEDED')){    // If main exe Get image save to disk
   file_put_contents('./red.bmp',file_get_contents('res:///PHP/'.strtoupper(md5('./red.bmp'))));
   file_put_contents('./red.bmp',file_get_contents('res:///PHP/'.strtoupper(md5('./red.bmp'))));
}
}
</pre>
&lt;/pre&gt;
|-
|-
|
|
These lines remain unchanged.
These lines remain unchanged.
|
|
<pre>
&lt;pre&gt;
  wb_set_image(wb_get_control($mainwin, IDC_FRAMERED1),'red.bmp', NOCOLOR);  
  wb_set_image(wb_get_control($mainwin, IDC_FRAMERED1),'red.bmp', NOCOLOR);  
  wb_set_image(wb_get_control($mainwin, IDC_FRAMERED2), 'red.bmp', NOCOLOR);  
  wb_set_image(wb_get_control($mainwin, IDC_FRAMERED2), 'red.bmp', NOCOLOR);  
</pre>
&lt;/pre&gt;
|-
|-
|
|
If running from .exe, image no longer required, so delete it.
If running from .exe, image no longer required, so delete it.
|
|
<pre>
&lt;pre&gt;
if(defined('EMBEDED')){    // If main exe
if(defined('EMBEDED')){    // If main exe
   unlink('./red.bmp');    // Delete file  
   unlink('./red.bmp');    // Delete file  
}
}
</pre>
&lt;/pre&gt;
|}
|}
With the exception of image name, each image requires identical code.
With the exception of image name, each image requires identical code.
Line 148: Line 149:
Edit file C:\us_wb\my_app\'''z_basic.phpw'''
Edit file C:\us_wb\my_app\'''z_basic.phpw'''
Replace these lines
Replace these lines
<pre>
&lt;pre&gt;
// Assign images to frames
// Assign images to frames
wb_set_image(wb_get_control($mainwin, IDC_FRAMERED1),'red.bmp', NOCOLOR);     
wb_set_image(wb_get_control($mainwin, IDC_FRAMERED1),'red.bmp', NOCOLOR);     
Line 154: Line 155:
wb_set_image(wb_get_control($mainwin, IDC_FRAMERED2),  'red.bmp', NOCOLOR);   
wb_set_image(wb_get_control($mainwin, IDC_FRAMERED2),  'red.bmp', NOCOLOR);   
wb_set_image(wb_get_control($mainwin, IDC_FRAMEGREEN2),'green.bmp', NOCOLOR);  
wb_set_image(wb_get_control($mainwin, IDC_FRAMEGREEN2),'green.bmp', NOCOLOR);  
</pre>
&lt;/pre&gt;


With
With
<pre>
&lt;pre&gt;
// Assign red image to frames
// Assign red image to frames
  if(defined('EMBEDED')){    // If main exe Get image save to disk
  if(defined('EMBEDED')){    // If main exe Get image save to disk
Line 177: Line 178:
   unlink('./green.bmp');    // Delete file  
   unlink('./green.bmp');    // Delete file  
  }
  }
</pre>
&lt;/pre&gt;


Replace this line
Replace this line
<pre>
&lt;pre&gt;
   wb_set_image($mainwin, "uslogo.ico");  // Add logo  
   wb_set_image($mainwin, &quot;uslogo.ico&quot;);  // Add logo  
</pre>
&lt;/pre&gt;
With
With
<pre>
&lt;pre&gt;
// Assign logo image to window
// Assign logo image to window
  if(defined('EMBEDED')){    // If main exe Get image save to disk
  if(defined('EMBEDED')){    // If main exe Get image save to disk
   file_put_contents('./uslogo.ico',file_get_contents('res:///PHP/'.strtoupper(md5('./uslogo.ico'))));  
   file_put_contents('./uslogo.ico',file_get_contents('res:///PHP/'.strtoupper(md5('./uslogo.ico'))));  
  }
  }
   wb_set_image($mainwin, "uslogo.ico");  // Add logo  
   wb_set_image($mainwin, &quot;uslogo.ico&quot;);  // Add logo  
  if(defined('EMBEDED')){    // If main exe
  if(defined('EMBEDED')){    // If main exe
   unlink('./uslogo.ico');  // Delete file  
   unlink('./uslogo.ico');  // Delete file  
  }
  }
</pre>
&lt;/pre&gt;
=== Test ===
=== Test ===
* Run z_basic.bat ensure your application runs
* Run z_basic.bat ensure your application runs
322

edits