javigil1
asked on
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)&tcIte m, 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.
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)&tcIte
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
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.
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
tab?
Try to refresh tab:
Invalidate();
UpdateWindow();
or refresh each child window