Author |
Topic: Tab control in a dialogue box (Read 944 times) |
|
rtr
Guest
|
 |
Re: Tab control in a dialogue box
« Reply #3 on: Jul 20th, 2014, 2:02pm » |
|
on Jul 20th, 2014, 12:31pm, JB91 wrote:| I've managed to create the tab control, although the procedure for creating the tabs in the wiki doesn't work. |
|
Do you mean the TCM_INSERTITEMA message isn't working? I find that surprising; how would the Tab Control 'know' that it's in a dialogue box and therefore behave differently from normal? I would suggest that perhaps the explanation is that you have an error in your code.
Richard.
|
|
Logged
|
|
|
|
rtr
Guest
|
 |
Re: Tab control in a dialogue box
« Reply #4 on: Jul 20th, 2014, 3:55pm » |
|
on Jul 20th, 2014, 2:02pm, Richard Russell wrote:| Do you mean the TCM_INSERTITEMA message isn't working? I find that surprising |
|
And indeed, when I try it, it seems to work fine. I took the code on the Wiki for creating a tab control, made the bare minimum of changes to create it in a dialogue box (using PROC_dlgctrl as described earlier), and the three tabs appear just as one would expect:
Code: INSTALL @lib$+"WINLIB2"
REM!WC
ICC_TAB_CLASSES = 8
TCIF_TEXT = 1
TCM_INSERTITEMA = 4871
WS_CHILD = &40000000
WS_VISIBLE = &10000000
DIM icex{dwSize%, dwICC%}
icex.dwSize% = DIM(icex{})
icex.dwICC% = ICC_TAB_CLASSES
SYS "InitCommonControlsEx", icex{}
REM Trapping errors is desirable; otherwise an error
REM message may be hidden behind the tab control:
ON ERROR SYS "MessageBox", @hwnd%, REPORT$, 0, 48 : QUIT
REM You create an 'empty' tab control as follows:
tcid% = 101
dlg% = FN_newdialog("Tab Control in Dialogue Box", 0, 0, 300, 250, 8, 1000)
PROC_dlgctrl(dlg%, "", tcid%, 10, 10, 280, 230, WS_VISIBLE OR WS_CHILD, "SysTabControl32")
PROC_showdialog(dlg%)
SYS "GetDlgItem", !dlg%, tcid% TO hTC%
IF hTC% = 0 ERROR 100, "Couldn't create tab control"
REM At this stage the control doesn't have any tabs;
REM to add them use code similar to the following:
PROCadd_tab(hTC%, "First", 1)
PROCadd_tab(hTC%, "Second", 2)
PROCadd_tab(hTC%, "Third", 3)
REPEAT WAIT 1 : UNTIL FALSE
END
DEF PROCadd_tab(htc%, text$, id%)
LOCAL cti{}, res%
DIM cti{mask%, dwState%, dwStateMask%, pszText%, cchTextMax%, iImage%, lparam%}
text$ += CHR$0
cti.mask% = TCIF_TEXT
cti.pszText% = !^text$
SYS "SendMessage", htc%, TCM_INSERTITEMA, id%, cti{} TO res%
IF res% = -1 ERROR 100, "Couldn't send Tab Control info"
ENDPROC This is so straightforward it's hard to know what might be the problem with your version.
Richard.
|
|
Logged
|
|
|
|
JB91
New Member
member is offline


Gender: 
Posts: 47
|
 |
Re: Tab control in a dialogue box
« Reply #5 on: Jul 21st, 2014, 11:22am » |
|
Thanks for your help, Richard. It works now and I've realised what my mistake was!
|
|
Logged
|
|
|
|
|