• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 400
  • Last Modified:

More about Tab Controls

I have a Tab Control. All the pages of the Tab Control display the same buttons and fields. My idea was:
OK, it's easy: I don't have to hide anything. I just make a TRANSPARENT tabcontrol. Then I add all my controls, which will be always visible, since they don't have to change.
So, the controls don't have to change, but the content will be changing according to the selected tab. That's easy, I only have to use an if-sentence and the .GetCurSel() method.
Something like:
          if (m_CTab.GetCurSel()=3)
             {m_NameInput="three"}

(All that within the OnSelchangeTab method).
OK, it works fine. Now comes the problem:
One of the fields is a text-input field, with the following code:

void CFhgDlg::OnChangeNameInput()
{
        UpdateData(TRUE);
        TC_ITEM tcItem;
        int tab = m_CTab.GetCurSel();
        if (tab >= 0)
        {
            PSTR text=(PSTR)(LPCTSTR)m_Name;
            TC_ITEM tcItem;
            ::ZeroMemory((PVOID)&tcItem, sizeof(tcItem));
            tcItem.mask = TCIF_TEXT;
            tcItem.pszText=text;
            m_CTab.SetItem(tab,&tcItem);
            UpdateData(TRUE);
         }

This code comes from a last week question: it just changes the name of the tab, displaying what the user is typing in the text-input field.
That works, the name of the tab is changed, but all the controls in the
tabcontrol dissapear (with the m_CTab.SetItem(tab,&tcItem) command). The tab-control is no longer transparent!! What can I do??
And something more:
How does the property "transparent" of the tab-control work?(in the ressource editor: right click on a tab-control -> Properties -> Extended Styles -> Transparent). I mean, when I mark this property, the tabcontrol isn't transparent at all. I have to left it unmarked if I want to use it as transparent.
0
javigil1
Asked:
javigil1
  • 2
1 Solution
 
vachoohoCommented:
when you add child controls - which window is the parent of those childs?
tab?
Try to refresh tab:
Invalidate();
UpdateWindow();

or refresh each child window
0
 
javigil1Author Commented:
Right! The question was sooo easy, but I'm really new  in the MFC world.
The second part of the question is still unsolved: If I want the tabcontrol to be transparent, I have to leave the property "transparent" unmarked. So, when I work with the ressource editor it isn't transparent, but when I run the programm it is.
0
 
vachoohoCommented:
Here is the excerpt from MSDN

WS_EX_TRANSPARENT   Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated.

I am not sure what is happening in your case - I need more information about child controls - their parents, styles and extended styles to be sure in answer.

Anyway, you can always adjust you tab styles using
m_Tab.ModifyStyleEx(WS_EX_TRANSPARENT, 0);

try this before updateing your tab ctrl.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now