Thread: Tab Help

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    4

    Tab Help

    Hi, I have created my tabs, but how would i add controls to each of the tabs?

    Code:
        HWND hWndTab = CreateWindowEx(0, "SysTabControl32", "",
    									WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
    									0, 20, 500, 250,
    									hWndDiag, NULL, hDiagInst, NULL);
    
        TCITEM tie;
        tie.mask = TCIF_TEXT;
        tie.pszText = "STUFF 1";
        TabCtrl_InsertItem(hWndTab, 0, &tie);
    
        tie.mask = TCIF_TEXT;
        tie.pszText = "STUFF 2";
        TabCtrl_InsertItem(hWndTab, 1, &tie);

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Windows specific question moved.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    The tabs are not really tabs as such, you could capture the change tab event and change a child-window (with controls which contents reflects the name of the tab).

    In other words, you'll need a child window (or several) which you juggle the displays of with ShowWindow or such. Research into the tab control and child windows is required.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    If you use the CHILD style you must set the HMENU param to the childs ID. This can then be used in the callback or GetDlgItem() macro ect.

    ie
    //in resource.h is the best place for all these
    //look at resoruce.h and how it keeps a running total and edit yours in
    #define IDC_MYTAB 40001//for example

    //in the createwindow HMENU param
    (HMENU)IDC_MYTAB

    To add a control just create another window with the right controls name. I would use the dialog as the parent and set the Z order with SetWindowPos() (top or bottom of the layers, main screen->dialog->TAB->control) and ShowWindow() to show/hide it as required.

    You can 'paste' a whole dialog on top of the TAB control. Reflect (move, size ect) messages from the TABs parent to the 'pasted' dialogs callback.
    Last edited by novacain; 08-03-2007 at 06:24 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    word of the wise, I used a similar process in my application: instead of using "tabs" I just cleared the window of all controls (hid them) then displayed another set of controls. Needless to say this is VERY inefficient as not only will you need to go through a great deal of ShowWindow/EnableWindow combinations, sometimes it takes so long you can even just make out the window re-drawing. I'm curious to see if anyone comes up with a better solution.

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Quote Originally Posted by @nthony View Post
    word of the wise, I used a similar process in my application: instead of using "tabs" I just cleared the window of all controls (hid them) then displayed another set of controls. Needless to say this is VERY inefficient as not only will you need to go through a great deal of ShowWindow/EnableWindow combinations, sometimes it takes so long you can even just make out the window re-drawing. I'm curious to see if anyone comes up with a better solution.
    Child windows with controls in them and show/hide the child windows.

  7. #7
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Thanks, after reading through Child Windows I see what you mean now. I was mistakingly thinking "child windows = controls", and completely missed their other role as dividors of parent client areas.

  8. #8
    A.I Programmer
    Join Date
    Mar 2007
    Location
    Teresina - Brazil
    Posts
    47
    It looks at this example in the section “Arquivos” ("Files") of this group:

    http://br.groups.yahoo.com/group/win32api/

    To have access to the group it is necessary to have a ID of yahoo, the project calls “TabControl.zip” and meets in the sub-folder “Windows Controls”.

    After that it will be connected to the group, makes download here.

    bye

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tab Ordering of GUI Controls
    By cloudy in forum Windows Programming
    Replies: 2
    Last Post: 04-22-2006, 09:13 AM
  2. Tab order in Tab Control
    By Halloko in forum Windows Programming
    Replies: 2
    Last Post: 05-08-2005, 11:08 PM
  3. Visual C++
    By Golffor1 in forum C++ Programming
    Replies: 1
    Last Post: 08-04-2003, 04:30 PM
  4. Replies: 5
    Last Post: 06-30-2003, 12:52 PM
  5. Tab controls - MFC (revived)
    By Robert602 in forum Windows Programming
    Replies: 1
    Last Post: 01-22-2002, 12:32 PM