PHP WinBinder: Tab Control: Difference between revisions

Proofreading and grammatical changes; some minor reformatting
(New page: {{Nav PHP WinBinder}} '''''Tab Control''''' When applications become too visually large its better to split the functionality into logical sections and use a tab control to access each se...)
 
(Proofreading and grammatical changes; some minor reformatting)
 
Line 2: Line 2:
'''''Tab Control'''''
'''''Tab Control'''''


When applications become too visually large its better to split the functionality into logical sections and use a tab control to access each section.
When applications become too visually large, it's better to split the functionality into logical sections and use a tab control to access each section.


This page covers creating a windows application based only on the tab control and controls placed on the tabbed pages. The techniques used are applicable to larger applications where a tab control is part of a larger application.
This page covers creating a Windows application based only on the tab control and controls placed on the tabbed pages. The techniques used are applicable to larger applications where a tab control is part of a larger application.


== Cotrol Creation ==
== Control Creation ==
Creating a tab control and adding controls to each tab requires the use of all parameters that can be passed to the create control function.
Creating a tab control and adding controls to each tab requires the use of all parameters that can be passed to the create control function.


For reference the parameters are shown below:
For reference, the parameters are shown below:
{|
{|
|-
|-
Line 35: Line 35:
|'''ntab'''|| is the index of the tab page that the control is to be inserted on, if any.  
|'''ntab'''|| is the index of the tab page that the control is to be inserted on, if any.  
|}
|}
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
== Tabs ==
== Tabs ==
To create a tab application, start with a blank canvas (use example1 as a template) and follow this sequence:
To create a tab application, start with a blank canvas (use example1 as a template) and follow this sequence:
Line 45: Line 45:
'''''Note'':''' Individual tabs have a numerical index, first tab starts at 0.   
'''''Note'':''' Individual tabs have a numerical index, first tab starts at 0.   


'''''[[#top | Top]]'''''
=== Main Tab Area ===
=== Main Tab Area ===
{|
{|
Line 63: Line 62:
[[Image:WinBinder_4.gif]]
[[Image:WinBinder_4.gif]]
|}
|}
'''''[[#top | Top]]'''''


=== Add individual tabs ===
=== Add individual tabs ===
Line 92: Line 90:
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


== Handles and ID’s ==
== Handles and IDs ==
Everyone has his or her own personal preference regarding programming style. I like to define handles to variables with a name that reflects the tab page and allocate ID’s to match tab page and control type.
Everyone has his or her own personal preference regarding programming style. I like to define handles to variables with a name that reflects the tab page and allocate ID’s to match tab page and control type.
{|
{|
Line 106: Line 104:
 
 
|
|
'''''ID's'':'''
'''''IDs'':'''
* Labels start at 100
* Labels start at 100
* Push buttons start at 200
* Push buttons start at 200
Line 117: Line 115:
Handle variable '''$label_p2_1''' with an ID (2000+100) '''2100'''
Handle variable '''$label_p2_1''' with an ID (2000+100) '''2100'''


'''''Note 1'':''' The above is just a guide however what is written in stone all variables and ID’s '''must be unique'''.
'''''Note 1'':''' The above is just a guide. However what is written in stone is that all variables and IDs '''must be unique'''.


'''''Note 2'':''' Although assigning handles to variables appears a logical way to proceed code becomes difficult to maintain. Similarly using pure ID’s makes it difficult to change code. Both these issues are resolved on the next page [[PHP WinBinder: Tab Control 2 | '''Tab Control 2''']] 
'''''Note 2'':''' Although assigning handles to variables appears a logical way to proceed, code becomes difficult to maintain. Similarly using pure IDs makes it difficult to change code. We'll address these issues a bit later.


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


== Adding controls to tabs ==
== Adding controls to tabs ==
We currently have three tabs to each of these we will add two labels, three buttons and a EditBox. This will allow you to easily see the differences.
We currently have three tabs. To each of these we will add two labels, three buttons and a EditBox. This will allow you to easily see the differences.
{|
{|
|-
|-
Line 159: Line 157:
 
 
|
|
The far right digit assigns a control to that tab number (remember tabs are indexed starting at 0)
The far right digit assigns a control to that tab number (remember, tabs are indexed starting at 0)
 
 
Fourth number from right is a controls ID this must be unique. It follows the convention outlined above.


Fourth number from right is a controls ID. This must be unique. It follows the convention outlined above.


For labels and edit boxes their handle is captured in a variable these follow the convention outlined above.  
For labels and edit boxes, their handle is captured in a variable following the convention.  
|}
|}
The above produces the following:
The above produces the following:
[[Image:WinBinder_6.gif]]
[[Image:WinBinder_6.gif]]


Currently there is no functionality hence pressing a button has no effect.
Currently there is no functionality, hence pressing a button has no effect.


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
Line 237: Line 233:
</pre>
</pre>
|
|
<br />
 
 
'''''Functionality'''''
'''''Functionality'''''


Line 392: Line 389:


Navigate to folder
Navigate to folder
UniServer\plugins\winbinder\'''examples'''
UniServer\plugins\winbinder\'''examples'''


Line 399: Line 395:




I mentioned above code maintainability.
I mentioned code maintainability above.


Each use of a handle variable in a function requires that it be declared as a global. This just adds to bloat and makes code a little more difficult to read and is to be avoided.
Each use of a handle variable in a function requires that it be declared as a global. This just adds to the bloat and makes code a little more difficult to read and is to be avoided.


Using raw ID numbers means if you decided to change the numbering order you need to change all occurrences. On a single script this is probably not to difficult however if this is over several scripts can be a pain.
Using raw ID numbers means if you decide to change the numbering order, you need to change all occurrences. On a single script this is probably not to difficult, but if this is over several scripts, it can be a pain.


The above are resolved on the next page
The above problems are resolved on the next page.




For this example what is important is the structure of the script. It’s a working script we can change into a working template.
In this example, the structure of the script is the important part. It’s a working script that we can change into a working template.
|}
|}
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


== Summary ==
== Summary ==
The tab control is an excellent choice for producing windows applications. It allows you to have separate functionality on individual pages (tabs). Using the tab control although a little more complex to configure is well worth the effort.
The tab control is an excellent choice for producing windows applications. It allows you to have separate functionality on individual pages (tabs). Using the tab control, although a little more complex to configurem is well worth the effort.


Although the above is a working script we want to modify it to a working template for a real applications. The [[PHP WinBinder: Tab Control 2 | '''next page''']] shows how to resolves issues that were highlighted.
Even though this is a working script, we want to modify it to a working template for a real application. The [[PHP WinBinder: Tab Control 2 | '''next page''']] shows how to resolve the issues that were highlighted.


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