Changes

Jump to navigation Jump to search

PHP WinBinder: Tab Control 3

1,210 bytes added, 01:14, 24 November 2010
no edit summary
=[http://ipelasuq.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
{{Nav PHP WinBinder}}
'''''Tab Control 3'''''
For example:
<&lt;pre>&gt;wb_create_control($tab, Frame, "&quot;Change"&quot;, 185, 14, 92, 110, 0, 0, 0); // create framewb_create_control($tab, Frame, ""&quot;&quot;, 0, 0, 295, 173, 0, 0, 0); // create frame<&lt;/pre>&gt;
The above code will add two frames to tab index 0 (first page)
== Single application instance ==
A single instance application can use this function:
<&lt;pre>&gt;
bool wb_get_instance (string caption [, bool bringtofront])
<&lt;/pre>&gt;
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.
For example this code was added to test 6
<&lt;pre>&gt;
//=== 1) Create main window ---------------------------------------------------
define("&quot;CAPTION"&quot;, "&quot;Test 6"&quot;); // Set caption to match application
if(wb_get_instance(CAPTION, TRUE)) // Is there an existing instance?
die; // Yes: bring it to the front and quit
<&lt;/pre>&gt;
'''''[[#top | Top]]'''''
== Add a logo-icon ==
For example, this code was added to test 6
<&lt;pre>&gt;
//=== 3) Assign handler function to the main window --------------------------
wb_set_handler($mainwin, "&quot;process_main"&quot;); wb_set_image($mainwin, "&quot;./" &quot; . "&quot;uslogo.ico"&quot;); // Add logo<&lt;/pre>&gt;
'''''[[#top | Top]]'''''
== Application minimizes to system tray ==
For example, the original line was:
<&lt;pre>&gt;$mainwin = wb_create_window(NULL, AppWindow, "&quot;Test 6"&quot;, 320, 240);<&lt;/pre>&gt;
Change to this:
<&lt;pre>&gt;$mainwin = wb_create_window(NULL, AppWindow, "&quot;Test 6"&quot;, WBC_CENTER, WBC_CENTER, 320, 240, WBC_TASKBAR);<&lt;/pre>&gt;
'''''[[#top | Top]]'''''
== Tab change detection ==
The following was changed:
<&lt;pre>&gt;$mainwin = wb_create_window(NULL, AppWindow, "&quot;Test 6"&quot;, WBC_CENTER, WBC_CENTER, 320, 240, WBC_TASKBAR);<&lt;/pre>&gt;
To this:
<&lt;pre>&gt;$mainwin = wb_create_window(NULL, AppWindow, "&quot;Test 6"&quot;, WBC_CENTER, WBC_CENTER, 320, 240, WBC_NOTIFY| WBC_TASKBAR , WBC_HEADERSEL );<&lt;/pre>&gt;
* 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
This line:
<&lt;pre>&gt;
function process_main($window, $id)
<&lt;/pre>&gt;
Changes to this:
<&lt;pre>&gt;
function process_main($window, $id, $ctrl=0, $lparam1=0, $lparam2=0)
<&lt;/pre>&gt;
=== Test Code ===
{|
|-valign="&quot;top"&quot;
|
<&lt;pre>&gt;
// TAB Change - Test
case 9000; // ID of main TAB
$text="&quot;ID = $id \n CTRL = $ctrl \n PARAM1 = $lparam1 \n PARAM2 = $lparam2 "&quot;; wb_message_box($window, $text,"&quot;TAB Pressed."&quot;, WBC_INFO);
switch($lparam2) {
case 0: // Tab index 0 or page 1
wb_message_box($window, "&quot;Case 0"&quot;,"&quot;TAB 0 Page 1"&quot;, WBC_OK); // Call init 1
break;
case 1: // Tab index 1 or page 2
wb_message_box($window, "&quot;Case 1"&quot;,"&quot;TAB 1 Page 2"&quot;, WBC_OKCANCEL); // Call init 2
break;
case 2: // Tab index 2 or page 3
wb_message_box($window, "&quot;Case 2"&quot;,"&quot;TAB 2 Page 3"&quot;, WBC_WARNING); // Call init 3
break;
}
break;
// END TAB Change - Test
<&lt;/pre>&gt;
|
<&lt;br />&gt;
'''''Test code'''''
== Test 6 Script ==
{|
|-valign="&quot;top"&quot;
|
<&lt;pre>&gt;<&lt;?phpInclude "&quot;../php/include/winbinder.php"&quot;; // Location Of Winbinder Library
//-- Constants ----------------------------------------------------------------
//ID's Page 1
define("&quot;ID_L1101"&quot;, 1101); //Labeldefine("&quot;ID_L1102"&quot;, 1102);define("&quot;ID_E1301"&quot;, 1301); // Edit boxdefine("&quot;ID_PB1201"&quot;, 1201); // Push buttondefine("&quot;ID_PB1202"&quot;, 1202); // Push buttondefine("&quot;ID_PB1203"&quot;, 1203); // Push button
//ID's Page 2
define("&quot;ID_L2101"&quot;, 2101); //Labeldefine("&quot;ID_L2102"&quot;, 2102);define("&quot;ID_E2301"&quot;, 2301); // Edit boxdefine("&quot;ID_PB2201"&quot;, 2201); // Push buttondefine("&quot;ID_PB2202"&quot;, 2202); // Push buttondefine("&quot;ID_PB2203"&quot;, 2203); // Push button
//ID's Page 3
define("&quot;ID_L3101"&quot;, 3101); //Labeldefine("&quot;ID_L3102"&quot;, 3102);define("&quot;ID_E3301"&quot;, 3301); // Edit boxdefine("&quot;ID_PB3201"&quot;, 3201); // Push buttondefine("&quot;ID_PB3202"&quot;, 3202); // Push buttondefine("&quot;ID_PB3203"&quot;, 3203); // Push button
//=== 1) Create main window ---------------------------------------------------
define("&quot;CAPTION"&quot;, "&quot;Test 6"&quot;); // Set caption to match application
if(wb_get_instance(CAPTION, TRUE)) // Is there an existing instance?
die; // Yes: bring it to the front and quit
$mainwin = wb_create_window(NULL, AppWindow, "&quot;Test 6"&quot;, WBC_CENTER, WBC_CENTER, 320, 240, WBC_NOTIFY| WBC_TASKBAR , WBC_HEADERSEL );
//=== 2) Create controls for the main window ----------------------------------
//Create Tab 0 - Page 1
wb_create_items($tab, "&quot;Page1"&quot;); wb_create_control($tab, Label, "&quot;Test label A"&quot;, 10, 14, 112, 20, ID_L1101, 0, 0, 0); wb_create_control($tab, Label, "&quot;Test label B"&quot;, 10, 34, 112, 20, ID_L1102, 0, 0, 0); wb_create_control($tab, EditBox, ""&quot;&quot;, 10, 54, 112, 20, ID_E1301, 0, 0, 0); wb_create_control($tab, PushButton, "&quot;Button A"&quot;, 10, 90, 80, 22, ID_PB1201, 0, 0, 0); wb_create_control($tab, PushButton, "&quot;Button B"&quot;, 100, 90, 80, 22, ID_PB1202, 0, 0, 0); wb_create_control($tab, PushButton, "&quot;Button C"&quot;, 190, 90, 80, 22, ID_PB1203, 0, 0, 0);
wb_create_control($tab, Frame, "&quot;Change"&quot;, 185, 14, 92, 110, 0, 0, 0); // create framewb_create_control($tab, Frame, ""&quot;&quot;, 0, 0, 295, 173, 0, 0, 0); // create frame
//Create Tab 1 - Page 2
wb_create_items($tab, "&quot;Page2"&quot;); wb_create_control($tab, Label, "&quot;Test label C"&quot;, 10, 14, 112, 20, ID_L2101, 0, 0, 1); wb_create_control($tab, Label, "&quot;Test label D"&quot;, 10, 34, 112, 20, ID_L2102, 0, 0, 1); wb_create_control($tab, EditBox, ""&quot;&quot;, 10, 54, 112, 20, ID_E2301, 0, 0, 1); wb_create_control($tab, PushButton, "&quot;Button D"&quot;, 10, 90, 80, 22, ID_PB2201, 0, 0, 1); wb_create_control($tab, PushButton, "&quot;Button E"&quot;, 100, 90, 80, 22, ID_PB2202, 0, 0, 1); wb_create_control($tab, PushButton, "&quot;Button F"&quot;, 190, 90, 80, 22, ID_PB2203, 0, 0, 1);
//Create Tab 2 - Page 3
wb_create_items($tab, "&quot;Page3"&quot;); wb_create_control($tab, Label, "&quot;Test label E"&quot;, 10, 14, 112, 20, ID_L3101, 0, 0, 2); wb_create_control($tab, Label, "&quot;Test label F"&quot;, 10, 34, 112, 20, ID_L3102, 0, 0, 2); wb_create_control($tab, EditBox, ""&quot;&quot;, 10, 54, 112, 20, ID_E3301, 0, 0, 2); wb_create_control($tab, PushButton, "&quot;Button G"&quot;, 10, 90, 80, 22, ID_PB3201, 0, 0, 2); wb_create_control($tab, PushButton, "&quot;Button H"&quot;, 100, 90, 80, 22, ID_PB3202, 0, 0, 2); wb_create_control($tab, PushButton, "&quot;Button I"&quot;, 190, 90, 80, 22, ID_PB3203, 0, 0, 2);
//=== 3) Assign handler function to the main window --------------------------
wb_set_handler($mainwin, "&quot;process_main"&quot;); wb_set_image($mainwin, "&quot;./" &quot; . "&quot;uslogo.ico"&quot;); // Add logo
//=== 5) Enter application loop -----------------------------------------------
// TAB Change - Test
case 9000; // ID of main TAB
$text="&quot;ID = $id \n CTRL = $ctrl \n PARAM1 = $lparam1 \n PARAM2 = $lparam2 "&quot;; wb_message_box($window, $text,"&quot;TAB Pressed."&quot;, WBC_INFO);
switch($lparam2) {
case 0: // Tab index 0 or page 1
wb_message_box($window, "&quot;Case 0"&quot;,"&quot;TAB 0 Page 1"&quot;, WBC_OK); // Call init 1
break;
case 1: // Tab index 1 or page 2
wb_message_box($window, "&quot;Case 1"&quot;,"&quot;TAB 1 Page 2"&quot;, WBC_OKCANCEL); // Call init 2
break;
case 2: // Tab index 2 or page 3
wb_message_box($window, "&quot;Case 2"&quot;,"&quot;TAB 2 Page 3"&quot;, WBC_WARNING); // Call init 3
break;
}
//== Page 1
case ID_PB1201: // Button A
wb_set_text(wb_get_control($window, ID_L1101),"&quot;12345"&quot;); wb_set_text(wb_get_control($window, ID_L1102),"&quot;67890"&quot;);
break;
case ID_PB1202: // Button B
wb_set_text(wb_get_control($window, ID_L1101),"&quot;67890"&quot;); wb_set_text(wb_get_control($window, ID_L1102),"&quot;12345"&quot;);
break;
case ID_PB1203: // Button C
$text1 = wb_get_text(wb_get_control($window, ID_E1301));
wb_set_text(wb_get_control($window, ID_L1101),"&quot;Page 1 "&quot;.$text1); wb_set_text(wb_get_control($window, ID_L1102),"&quot;Page 1 "&quot;.$text1);
break;
//== Page 3
case ID_PB3201: // Button G
wb_message_box($window, "&quot;Page 3."&quot;,"&quot;BUTTON G"&quot;, WBC_INFO);
break;
case ID_PB3202: // Button H
wb_message_box($window, "&quot;Page 3."&quot;,"&quot;BUTTON H"&quot;, WBC_QUESTION);
break;
case ID_PB3203: // Button I
wb_message_box($window, "&quot;Page 3."&quot;,"&quot;BUTTON I"&quot;, WBC_YESNO);
break;
function button_D($window){
wb_set_text(wb_get_control($window, ID_L2101),"&quot;xxxx"&quot;); wb_set_text(wb_get_control($window, ID_L2102),"&quot;yyyy"&quot;);
}
function button_E($window){
wb_set_text(wb_get_control($window, ID_L2101),"&quot;yyyy"&quot;); wb_set_text(wb_get_control($window, ID_L2102),"&quot;xxxx"&quot;);
}
function button_F($window){
$text1 = wb_get_text(wb_get_control($window, ID_E2301));
wb_set_text(wb_get_control($window, ID_L2101),"&quot;Page 2 "&quot;.$text1); wb_set_text(wb_get_control($window, ID_L2102),"&quot;Page 2 "&quot;.$text1);
}
?>&gt;
<&lt;/pre>&gt;
|}
322

edits

Navigation menu