PHP WinBinder: Tab Control 3: Difference between revisions

Proofreading and grammatical changes; some minor reformatting
(New page: {{Nav PHP WinBinder}} '''''Tab Control 3''''' On the previous page we finished with a template script this page covers converting that script into a windows project script. This means th...)
 
(Proofreading and grammatical changes; some minor reformatting)
Line 2: Line 2:
'''''Tab Control 3'''''
'''''Tab Control 3'''''


On the previous page we finished with a template script this page covers converting that script into a windows project script.
On the previous page we finished with a template script. This page covers converting that script into a Windows project script. This means the script is specifically targeting a real application.
 
This means the script is specifically targeting a real application.


== Specification ==
== Specification ==
Line 12: Line 10:
* Only a single instance of the application allowed
* Only a single instance of the application allowed
* Add a logo-icon to the application window and system tray icon.
* Add a logo-icon to the application window and system tray icon.
* Application minimize to notification area (system tray) and not the Task Bar
* Application minimizes to notification area (system tray) and not the Task Bar
* Tab change detection required.
* Tab change detection required.
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
Line 37: Line 35:
Each main window of all WinBinder applications stores a 32-bit identifier that is calculated according to the initial window caption and is unique to that caption.  
Each main window of all WinBinder applications stores a 32-bit identifier that is calculated according to the initial window caption and is unique to that caption.  


wb_get_instance() will try to find, among all current top-level windows, a WinBinder window that was created with the same caption.  
wb_get_instance() will try to find, among all current top-level windows, a WinBinder window that was created with the same caption. The function returns TRUE if it finds the existing window or FALSE if it is does not.
 
The function returns TRUE if it finds the existing window or FALSE if it is does not.


For example this code was added to test 6
For example this code was added to test 6
Line 50: Line 46:
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
== Add a logo-icon ==
== Add a logo-icon ==
You can added a image top left of application using the function wb_set_image(parent,path to image)
You can added an image top left of the application using the function wb_set_image(parent,path to image)


For example this coded was added to test 6
For example, this code was added to test 6


<pre>
<pre>
Line 60: Line 56:
</pre>
</pre>
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
== Application minimize to system tray ==
== Application minimizes to system tray ==
To create a window that minimizes itself as an icon in the TaskBar status area, include the '''WBC_TASKBAR''' style flag in the style parameter of the wb_create_window function. All operations will be handled automatically.
To create a window that minimizes itself as an icon in the TaskBar status area, include the '''WBC_TASKBAR''' style flag in the style parameter of the wb_create_window function. All operations will be handled automatically.


For example the original line was:
For example, the original line was:
<pre>
<pre>
$mainwin = wb_create_window(NULL, AppWindow, "Test 6", 320, 240);
$mainwin = wb_create_window(NULL, AppWindow, "Test 6", 320, 240);
Line 73: Line 69:
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
== Tab change detection ==
== Tab change detection ==
Reason for detecting a tab change is to call a function and update any data on that page that may be out of date.
The reason for detecting a tab change is to call a function and update any data on that page that may be out of date.


Tab detection requires additional messages to be passed back to the handler function. These are not enabled by default changes are required to both the window and handler functions.
Tab detection requires additional messages to be passed back to the handler function. These are not enabled by default, and changes are required to both the window and handler functions.


=== Create Window Changes ===
=== Create Window Changes ===
A windows application is instructed to pass additional message using WBC_NOTIFY type of message defined by WBC_HEADERSEL
A Windows application is instructed to pass additional messages using WBC_NOTIFY type of message defined by WBC_HEADERSEL


The following was changed:
The following was changed:
Line 88: Line 84:
$mainwin = wb_create_window(NULL, AppWindow, "Test 6", WBC_CENTER, WBC_CENTER, 320, 240, WBC_NOTIFY| WBC_TASKBAR , WBC_HEADERSEL );
$mainwin = wb_create_window(NULL, AppWindow, "Test 6", WBC_CENTER, WBC_CENTER, 320, 240, WBC_NOTIFY| WBC_TASKBAR , WBC_HEADERSEL );
</pre>
</pre>
* When a tab is clicked the main tab ID is sent back to the handler function
* When a tab is clicked, the main tab ID is sent back to the handler function
* In addition the tab index is set to $lparm2
* In addition the tab index is set to $lparm2


=== Change Handler function parameters ===
=== Change Handler function parameters ===
The handler function requires changing to allow extra parmeter parsing.
The handler function requires changing to pass additional parameters.


This line:
This line:
Line 103: Line 99:
</pre>
</pre>


'''''[[#top | Top]]'''''
=== Test Code ===
=== Test Code ===
{|
{|
Line 137: Line 131:
'''''Test code'''''
'''''Test code'''''


With the above modifications main tab now generates its ID, in this case 9000 on any tab change.
With the above modifications, main tab now generates its ID (in this case 9000) on any tab change.
 
For reference, a wb_message_box displays all parameters passed to the handler function.
For reference a wb_message_box display all parameters passed to the handler function.
 
We are interested in which tab caused the change, its index can be found in $lparam2 hence this is used in a switch.


We are interested in which tab caused the change. Its index can be found in $lparam2 hence this is used in a switch.
Each tab is resolved using a case statement (resolves tab indexes 0 to 2)
Each tab is resolved using a case statement (resolves tab indexes 0 to 2)


Line 344: Line 336:


Double click on '''test_6.bat'''
Double click on '''test_6.bat'''




'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
== Summary ==
== Summary ==
The above script (test_6.phpw) makes a good starting point for a Windows application. Use it as a template, make changes as required alternatively use it as a guide and cut and paste the bits you need.
The above script (test_6.phpw) makes a good starting point for a Windows application. Use it as a template, make changes as required or alternatively use it as a guide and cut and paste the bits you need.


That completes a basic introduction to windows controls it covers enough material to get started including some cosmetics that are not essential but will make a completed application more pleasing.
That completes a basic introduction to windows controls. It covers enough material to get started including some cosmetics that are not essential but will make a completed application more pleasing.


The next two pages covers a [[PHP WinBinder: Project | '''stand-alone project''']]. It’s written from a scripting point of view and avoids compiling.  
The next two pages cover a [[PHP WinBinder: Project | '''stand-alone project''']]. It’s written from a scripting point of view and avoids compiling.  


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