BBC BASIC for Windows
« Tab control in a dialogue box »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:19pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Tab control in a dialogue box  (Read 941 times)
JB91
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 47
xx Tab control in a dialogue box
« Thread started on: Jul 9th, 2014, 4:14pm »

Hello,

I want to add a tab control to a dialogue box, but I am not quite sure how to do it. I have tried adapting the code found in the "Creating a tab control" in the BB4W wiki, but that doesn't seem to work. sad
User IP Logged

rtr
Guest
xx Re: Tab control in a dialogue box
« Reply #1 on: Jul 9th, 2014, 8:42pm »

on Jul 9th, 2014, 4:14pm, JB91 wrote:
I want to add a tab control to a dialogue box, but I am not quite sure how to do it.

You will need to specify it in the dialogue template using PROC_dlgctrl() with the class name "SysTabControl32", something like this:

Code:
      PROC_dlgctrl(dlg%, "", id%, x%, y%, cx%, cy%, 0, "SysTabControl32") 

After the dialogue box has been shown you can retrieve the handle of the tab control in the usual way using GetDlgItem. Thereafter you should be able to react to tab changes using code very similar to that in the Wiki.

Richard.
User IP Logged

JB91
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 47
xx Re: Tab control in a dialogue box
« Reply #2 on: Jul 20th, 2014, 12:31pm »

I've managed to create the tab control, although the procedure for creating the tabs in the wiki doesn't work.
User IP Logged

rtr
Guest
xx 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.
User IP Logged

rtr
Guest
xx 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.
User IP Logged

JB91
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 47
xx 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! smiley
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls