|
|
|
|
|
- Overview
- Opening a dynamic tab pane
- Opening a tab pane via the "+" button
- Opening a tab pane using TabOpen
- Tip: Creating a "Menu" tab to allow the user to choose the type of tab pane to create
- Handling a dynamic tab pane
- Changing the active dynamic tab pane
- Getting the text of the active dynamic tab pane
- Retrieving the name of the internal window displayed in a pane
- Access the content of the internal window displayed in a pane
- Properties specific to Tab controls
Handling a dynamic programmatically
WINDEV allows you to programmatically handle Dynamic Tab controls with the TabXXX functions and multiple WLanguage properties. You can also use the Tab control variable directly in the code. Caution: Static and dynamic tab panes are not identified the same way: - static tab panes are identified by the number of the active pane.
- dynamic tab panes are identified by the alias of the active pane.
Remark: If the internal window handled in the dynamic tab uses HFSQL data files, it must also use an independent HFSQL context. Opening a dynamic tab pane There are different methods to open a dynamic tab pane: - via the "+" button of the Tab control. In this case, the options specified in the Tab control description window are taken into account.
- programmatically with TabOpen.
Opening a tab pane via the "+" button To open a tab pane via the "+" button in the Tab control: - In the Tab control description window, go to the "Details" tab and check "With 'New' button (+)", then select the internal window in "Internal window when (+) is clicked" and specify the default text of the new tab.
- The internal window opened by the "+" button can be:
- a specific internal window (e.g. a customer form).
When the user clicks the "+" button, the new tab panes will be identical. They will be based on the same internal window. Remark: If the internal window expects parameters, the tab pane must be opened with TabOpen. - no internal window.
In this case, the internal window to open must be specified programmatically. To do so, use TabOpen in the "Create a tab" event of the Tab control (see Opening a tab pane using TabOpen).
Remark: The "+" button of the dynamic tab automatically calls the "Create a tab" event of the Tab control. If this event uses TabOpen, this event will take priority over the internal window specified in the interface. Opening a tab pane using TabOpen You can also use TabOpen to open a tab pane. This function can for example: - be used in a button to open an additional tab pane in a Tab control.
- be used in the "Create a tab" event of the Tab control.
- Get the alias of the tab pane. This alias allows you to programmatically handle the tab pane. This alias is also returned by the Value and Alias properties.
- Specify the text of the tab pane.
- Specify the internal window to open.
- Pass parameters to the internal window to open.
Example:
Alias_Tab is string // New tab containing the form of the current customer Alias_Tab = TabOpen(TAB_Menu, "Customer "+ Customer.CustomerID, IW_CustomerForm, Customer.CustomerID) // Change the image of the tab pane TAB_Menu[Alias_Tab]..Image = "NewCust.png"
Tip: Creating a "Menu" tab to allow the user to choose the type of tab pane to create When the "+" button is clicked, a menu can appear to allow the user to choose the type of information to display. To create this type of interface: - Create a "Menu" internal window. This internal window contains the options for choosing the data to be displayed in the new tab pane. For example, this window can allow the user to display a customer form, an invoice or the list of orders.
- In the Tab control description window, go to the "Details" tab.
- In "Internal window when (+) is clicked", select the "Menu" internal window.
- Validate.
In this case: - The user clicks "+" to add a tab.
- A new tab pane is displayed, containing the menu (internal window created previously).
- In the menu, the user chooses the type of tab pane to display.
- The current tab pane (the one displaying the menu) is replaced by the selected pane.
Some modifications are required to develop this type of interface: - In the click code of the button used to choose the type of tab pane, use ChangeSourceWindow with the following syntax:
ChangeSourceWindow(<Selected Internal Window>, <Replacement Internal Window>) For example:
ChangeSourceWindow(IW_Choice, IW_Form)
- To handle the new tab, use the following syntax:
<Window>.<Tab control>[<Window>.<Tab control>] For example, to change the text of the active tab:
WIN_DYNHAND.TAB_MDI[WIN_DYNHAND.TAB_MDI].Caption = "Form " + SysTime()
Handling a dynamic tab pane To handle a dynamic tab pane, use the following syntax: TabControl[TabPaneAlias].PropertyName = PropertyValue For example: TAB_MyTab[TAB_MyTab].State = Grayed
Remarks: - ControlPane gets the name of the dynamic pane (alias) displaying a specific control.
// Click on "BTN_UPD" button MyPane is Control MyPane <- ControlPane(MySelf) MyPane.Caption = MyPane.Caption + " (Modified)"
- TabStatus gets the status of a dynamic tab pane: active, floating, not found.
- To get the aliases of the active dynamic tabs, simply call EnumControl on the Tab control:
// Populate a Combo Box control with the list of controls in the window i is int = 1 ResControl is string ResControl = EnumControl(TAB_MyTab, i) WHILE ResControl <> "" i++ Trace(ResControl) ResControl = EnumControl(TAB_MyTab, i) END
Changing the active dynamic tab pane The last created dynamic tab pane is enabled by default. The active tab can be changed programmatically. To activate a dynamic tab pane: - Assign the Tab control the alias of the dynamic tab pane to activate:
Tab control name = AliasOfTabPane - Use the Value property.
Reminder: To activate a static tab pane, simply specify the number of the tab pane to activate. Tab control name = Pane number Getting the text of the active dynamic tab pane To get the text of the active tab, simply use the Caption property on the tab pane (identified by its alias). For example:
AliasTab1 is string = TabOpen(TAB_Test, "My tab 1", "IW_InternalWindow") Trace(TAB_Test[AliasTab1].Caption)
The Caption property can also be used to change the text of the tab pane. Retrieving the name of the internal window displayed in a pane To retrieve the name of the internal window displayed in a dynamic pane, you can use the following code:
// Retrieves the displayed pane oInternalWin is Control <- TAB_Test[PaneAlias1] Â // Retrieves the internal window associated with the pane sInternalWindowName is string sInternalWindowName = EnumControl(oInternalWin, 1, byCreationOrder)
Access the content of the internal window displayed in a pane indirection operators can be used to access the value of a control or variable in the internal window displayed in a dynamic pane: // Retrieves the value of a control in the internal window Info({PaneAlias1 + ".ControlName", indControl})  // Retrieves the value of a variable in the internal window Info({PaneAlias1 + ".VariableName", indVariablel})  // Call a procedure of the internal window ExecuteProcess(PaneAlias1 + ".pProcédureName", trtProcedure)  // Equivalent to: MyProcedure is procedure = gsAlias_Tab + ".pProcedureName" MyProcedure()
It is preferable to use the locals procedures of a window to manipulate its controls, instead of directly accessing the controls and the variables by indirection. This keeps the internal window autonomous and facilitates maintenance. Properties specific to Tab controls The following properties are used to manage the characteristics of a Dynamic Tab control through programming.
| | CaptionIfNew | The CaptionIfNew property is used to get and change the caption of a pane opened by the end user in a dynamic Tab control. | DynamicTab | The DynamicTab property is used to:- Find out the type of a Tab control (static tab or dynamic tab).
- Modify the type of a Tab control (static tab or dynamic tab).
| StoreTheConfiguration | The StoreTheConfiguration property is used to: - Determine whether the configuration of the panes in a dynamic Tab control or Ribbon control is automatically saved and restored.
- Modify the configuration of the panes in a dynamic Tab control or Ribbon control so that it is automatically saved and restored (or not)
| UndockablePane | The UnlockablePane property is used to: - Determine if the end user can move the panes of a Ribbon or Dynamic Tab control outside the window.
- Allow or prevent the end user from moving the panes of a Ribbon or Dynamic Tab control outside the window.
| Undocked | The Undocked property is used to determine if a pane of a Tab or Ribbon control is undocked. | WindowIfNew | The WindowIfNew property is used to get and change the name of the internal window to be opened if the end user opens a new tab in a dynamic Tab control. | WithClosingButton | The WithClosingButton property is used to: - Determine whether all the tabs of a Dynamic Tab control have a Close button.
- Show a Close button in all the tabs of a Dynamic Tab control.
| WithNewButton | The WithNewButton property is used to: - Determine if a Dynamic Tab control has New tab button (+).
- Configure a Dynamic Tab control to show a New tab button.
|
Related Examples:
|
Training (WINDEV): WD Multi-Windowing
[ + ] This example presents the basic concepts for managing the multi-windowing and the dynamic tabs with WINDEV. This example includes a simple interface for managing the customer forms: - multi-windowing with MDI interface, - multi tabs with a dynamic tab control.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|