creating_20a_20tab_20control
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
creating_20a_20tab_20control [2018/03/31 13:19] – external edit 127.0.0.1 | creating_20a_20tab_20control [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 4: | Line 4: | ||
==== Initialisation ==== | ==== Initialisation ==== | ||
\\ Firstly the necessary initialisation: | \\ Firstly the necessary initialisation: | ||
+ | <code bb4w> | ||
INSTALL @lib$+" | INSTALL @lib$+" | ||
INSTALL @lib$+" | INSTALL @lib$+" | ||
Line 24: | Line 25: | ||
icex.dwICC% = ICC_TAB_CLASSES | icex.dwICC% = ICC_TAB_CLASSES | ||
SYS " | SYS " | ||
+ | </ | ||
Although not essential, trapping errors is desirable; otherwise an error message may be hidden behind the tab control:\\ \\ | Although not essential, trapping errors is desirable; otherwise an error message may be hidden behind the tab control:\\ \\ | ||
+ | <code bb4w> | ||
ON ERROR SYS " | ON ERROR SYS " | ||
+ | </ | ||
\\ | \\ | ||
==== Creating the tab control ==== | ==== Creating the tab control ==== | ||
\\ You create an ' | \\ You create an ' | ||
+ | <code bb4w> | ||
Width% = 500 | Width% = 500 | ||
Height% = 500 | Height% = 500 | ||
Line 34: | Line 39: | ||
\ WS_CLIPSIBLINGS + WS_CLIPCHILDREN, | \ WS_CLIPSIBLINGS + WS_CLIPCHILDREN, | ||
IF hTC% = 0 ERROR 100, " | IF hTC% = 0 ERROR 100, " | ||
+ | </ | ||
The width and height values are in pixels.\\ \\ At this stage the control doesn' | The width and height values are in pixels.\\ \\ At this stage the control doesn' | ||
+ | <code bb4w> | ||
PROCadd_tab(hTC%, | PROCadd_tab(hTC%, | ||
PROCadd_tab(hTC%, | PROCadd_tab(hTC%, | ||
PROCadd_tab(hTC%, | PROCadd_tab(hTC%, | ||
+ | </ | ||
Here the second parameter of each call is the text string that appears on the tab, and the third parameter is an ID value for each tab. The **PROCadd_tab** routine is listed later.\\ \\ | Here the second parameter of each call is the text string that appears on the tab, and the third parameter is an ID value for each tab. The **PROCadd_tab** routine is listed later.\\ \\ | ||
==== Resizing your main window ==== | ==== Resizing your main window ==== | ||
\\ You may, optionally, want to resize your main output window so that it is the same size as the tab control. If you do you can use the following code:\\ \\ | \\ You may, optionally, want to resize your main output window so that it is the same size as the tab control. If you do you can use the following code:\\ \\ | ||
+ | <code bb4w> | ||
DIM rc{l%, | DIM rc{l%, | ||
SYS " | SYS " | ||
Line 47: | Line 56: | ||
SYS " | SYS " | ||
SYS " | SYS " | ||
+ | </ | ||
This code also disables the ability to resize or maximise the window.\\ \\ | This code also disables the ability to resize or maximise the window.\\ \\ | ||
==== Handling page changes ==== | ==== Handling page changes ==== | ||
\\ This is where it gets interesting! Unlike a Property Sheet, changing what is displayed on each page as the tabs are clicked by the user is your responsibility. You must monitor the page changes, and automatically hide the contents of the previous page and show the contents of the new page as required. The basic code to monitor changes is as follows:\\ \\ | \\ This is where it gets interesting! Unlike a Property Sheet, changing what is displayed on each page as the tabs are clicked by the user is your responsibility. You must monitor the page changes, and automatically hide the contents of the previous page and show the contents of the new page as required. The basic code to monitor changes is as follows:\\ \\ | ||
+ | <code bb4w> | ||
prevsel% = -1 | prevsel% = -1 | ||
REPEAT | REPEAT | ||
Line 60: | Line 71: | ||
UNTIL INKEY(1) = 0 | UNTIL INKEY(1) = 0 | ||
END | END | ||
+ | </ | ||
Here two variables **prevsel%** and **currsel%** keep track of the previous and current selections respectively.\\ \\ There are two main approaches to drawing on the pages. One is to draw individual controls (buttons, boxes etc.) and the other is to display a dialogue box on each page, where the dialogue boxes contain the controls. Using dialogue boxes has the advantage of providing the standard navigation controls (e.g. using Tab) but is complicated by the DPI issue (see later).\\ \\ To start off with here is a simple example of displaying an individual button on the second tab (currsel% = 1):\\ \\ | Here two variables **prevsel%** and **currsel%** keep track of the previous and current selections respectively.\\ \\ There are two main approaches to drawing on the pages. One is to draw individual controls (buttons, boxes etc.) and the other is to display a dialogue box on each page, where the dialogue boxes contain the controls. Using dialogue boxes has the advantage of providing the standard navigation controls (e.g. using Tab) but is complicated by the DPI issue (see later).\\ \\ To start off with here is a simple example of displaying an individual button on the second tab (currsel% = 1):\\ \\ | ||
+ | <code bb4w> | ||
hbutton% = FN_button(hTC%," | hbutton% = FN_button(hTC%," | ||
SYS " | SYS " | ||
Line 74: | Line 87: | ||
UNTIL INKEY(1) = 0 | UNTIL INKEY(1) = 0 | ||
END | END | ||
+ | </ | ||
Here the button is hidden when the // | Here the button is hidden when the // | ||
+ | <code bb4w> | ||
FOR index% = 0 TO DIM(dlg%(), 1) | FOR index% = 0 TO DIM(dlg%(), 1) | ||
!(dlg%(index%)!4+8) = hTC% | !(dlg%(index%)!4+8) = hTC% | ||
Line 91: | Line 106: | ||
UNTIL INKEY(1) = 0 | UNTIL INKEY(1) = 0 | ||
END | END | ||
+ | </ | ||
Here **dlg%()** is an array containing the values returned from [[http:// | Here **dlg%()** is an array containing the values returned from [[http:// | ||
==== Procedures ==== | ==== Procedures ==== | ||
\\ Finally, the **PROCadd_tab** procedure: | \\ Finally, the **PROCadd_tab** procedure: | ||
+ | <code bb4w> | ||
DEF PROCadd_tab(htc%, | DEF PROCadd_tab(htc%, | ||
LOCAL cti{}, res% | LOCAL cti{}, res% | ||
Line 103: | Line 120: | ||
IF res% = -1 ERROR 100, " | IF res% = -1 ERROR 100, " | ||
ENDPROC | ENDPROC | ||
+ | </ |
creating_20a_20tab_20control.1522502353.txt.gz · Last modified: 2024/01/05 00:18 (external edit)