PHP WinBinder: Alternative control 4: Difference between revisions

Proofreading and grammatical changes; some minor reformatting
(New page: {{Nav PHP WinBinder}} '''''Alternative control part 4''''' WinBinder has a few limitations most of which can be worked around. One limitation, there is no direct way to detect that an app...)
 
(Proofreading and grammatical changes; some minor reformatting)
 
Line 2: Line 2:
'''''Alternative control part 4'''''
'''''Alternative control part 4'''''


WinBinder has a few limitations most of which can be worked around. One limitation, there is no direct way to detect that an application has been restored from the tray menu.
WinBinder has a few limitations, most of which can be worked around. One limitation is that there is no direct way to detect that an application has been restored from the tray menu.


However for our application this detection is required a servers status may have change while our application is minimised to the tray menu. For example a server may be closed from Apanel hence restoring our application requires buttons and indicators to be updated.
this detection is required for our application. A server's status may have change while our application is minimised to the tray menu. For example a server, may be closed from Apanel and when our application is restored, it requires the buttons and indicators to be updated.


A crude method of perfuming this is to use a refresh button problem is when should a user press this button. This page shows how to detect when the application window regains focus. This allows the refresh button to be replaced with a more useful button.
A crude method of perfuming this is to use a refresh button, but when should a user press this button? This page shows how to detect when the application window regains focus. This allows the refresh button to be replaced with a more useful button.


=== Preliminary ===
=== Preliminary ===
I made copies of test_7.phpw and test_7.bat renamed them to test_8.phpw and test_8.bat respectively.
I made copies of test_7.phpw and test_7.bat and renamed them to test_8.phpw and test_8.bat respectively.
 
The batch file test_8.bat was edited to run test_8.phpw.
Batch file test_8.bat was edited to run test_8.phpw.


'''''File test_8.phpw'':'''
'''''File test_8.phpw'':'''
Line 23: Line 22:
  global $focus_old;
  global $focus_old;
</pre>
</pre>
'''''[[#top | Top]]'''''


== Timer ==
== Timer ==
Line 30: Line 27:
|-valign="top"
|-valign="top"
|
|
A timer was added providing a periodic tick, on each tick calls the handler function.  
A timer was added to provide a periodic tick; on each tick it calls the handler function.  
 
The handler code checks if it is a timer event and calls our main_timer()function.
Handler code checks it is a timer event and calls our main_timer() function.
When starting or stopping the servers, this function updates a progress indicator and server status.
When starting or stopping the servers this function updates a progress indicator and server status.


Handler code as shown on the right.  
The handler code is as shown on the right.  


|
|
Line 53: Line 48:
|-valign="top"
|-valign="top"
|
|
This periodic tick provides an ideal solution for checking a controls focus.
This periodic tick provides an ideal solution for checking a control's focus.


Function '''wb_get_focus()''' returns a handle to the window or control that has the keyboard focus.
Function '''wb_get_focus()''' returns a handle to the window or control that has the keyboard focus.


Function '''wb_get_text(handle)''' returns the text from a window, control, or control item. If it’s a window returns its caption (UniController) text.
Function '''wb_get_text(handle)''' returns the text from a window, control, or control item. If it’s a window, it returns its caption (UniController) text.


Variable '''$txt''' holds some text of a control currently in focus.
Variable '''$txt''' holds some text of a control currently in focus.


'''$txt != $focus_old''' a new control is in focus. Is it our window.
if '''$txt != $focus_old''', a new control is in focus. Is it our window?


If it is call function  '''main_init()'''
If it is, call function  '''main_init()'''


Save the current focused control text in '''$focus_old'''
Save the current focused control text in '''$focus_old'''.


|
|
Line 87: Line 82:
</pre>
</pre>
|}
|}
Function main_init() is called only when the new focus is that of our window application. If the focus of a control has not changed there is nothing to do.
Function main_init() is called only when the new focus is that of our window application. If the focus of a control has not changed, there is nothing to do.


For testing add a line just below main_init() as shown below:
For testing, add a line just below main_init() as shown below:
<pre>
<pre>
main_init();                                        //Yes: Update button and indicators  
main_init();                                        //Yes: Update button and indicators  
Line 95: Line 90:
</pre>   
</pre>   


'''''[[#top | Top]]'''''
=== Test ===
=== Test ===


Line 103: Line 97:
To see this functionality in action run '''test_8.bat'''
To see this functionality in action run '''test_8.bat'''


Expected results
Expected results:
* When the application starts, an alert pop-up is produced.
* When the application starts, an alert pop-up is produced.
* Minimise and restore application, an alert pop-up is produced.
* Minimise and restore application, an alert pop-up is produced.
* Click outside and then inside the application, an alert pop-up is produced.
* Click outside and then inside the application, an alert pop-up is produced.
* From the drop down menu “Passwords” select “Set MySQL password”<br /> close the pop-up windows and click on the application, an alert pop-up is produced.
* From the drop down menu “Passwords”, select “Set MySQL password”<br /> close the pop-up windows and click on the application, an alert pop-up is produced.
|
|
[[Image:WinBinder_final.gif]]
[[Image:WinBinder_final.gif]]
|}
|}
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
== Final ==
== Final ==
The above completes this tutorial I was going to leave it there and let you fill in the detail.
The above completes this tutorial. I was going to leave it there and let you fill in the detail.
 
However I thought better of it and decided that a working reference would be better, allowing you to change it as required.
However thought better of it and decided a working reference would be better allowing you to change it as required.


I made copies of  test_7b.phpw, test_8.phpw and test_8.bat renamed them test_9b.phpw, test_9.phpw and test_9_final.bat respectively.
I made copies of  test_7b.phpw, test_8.phpw and test_8.bat and renamed them test_9b.phpw, test_9.phpw and test_9_final.bat respectively.


'''''Batch file'':''' test_9_final.bat was modified to have the following content:
'''''Batch file'':''' test_9_final.bat was modified to have the following content:
Line 129: Line 122:
The batch file was then converted to an executable using [[PHP WinBinder: Project#Create an EXE file | Bat_To_Exe_Converter.exe]].
The batch file was then converted to an executable using [[PHP WinBinder: Project#Create an EXE file | Bat_To_Exe_Converter.exe]].


'''''Note'':''' These two files (test_9_final.bat and test_9_final.exe) are included in folder UniServer\plugins\winbinder \'''alt_con_1''' copy them to folder UniServer and run.
'''''Note'':''' These two files (test_9_final.bat and test_9_final.exe) are included in folder UniServer\plugins\winbinder \'''alt_con_1'''. Copy them to folder UniServer and run.


=== New window application ===
=== New window application ===
Script test_9b.phpw was converted into a real windows application changes the following server parameters:
Script test_9b.phpw was converted into a real windows application and changes the following server parameters:
* Appache listen port
* Appache listen port
* Apache ssl port
* Apache ssl port
Line 144: Line 137:
That essentially concludes this tutorial.
That essentially concludes this tutorial.


If the plugin is going to be used only for controlling the server it’s probably worth making a few minor modification explained on the [[PHP WinBinder: Overlay | '''next page''']].
If the plugin is going to be used only for controlling the server. it’s probably worth making a few minor modification explained on the [[PHP WinBinder: Overlay | '''next page''']].


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