I think you're mixing up the concepts of tab controls and property sheets.
With a tab control by itself you have a tab control within a dialog box that doesn't affect any other controls. So having an "edit control" per tab doesn't make sense, unless you write special code that hides and shows the edit controls when you click on each tab.
With a property sheet (and property pages), you have a tab control and separate dialog boxes for each "page" that the tabs on the tab control represent. This would be closer to what you want. You can use the CPropertySheet and CPropertyPage classes, and use AddPage to add the property pages to the property sheets. The tab control will use the title of each property page.
How do I resize the edit control box in my tab. When I maximize the window, I want the edit box to be resized. I am able to resize the tab with no problem.
In the initialization of the form view, you have to actually add the tabs to the tab control, i.e. using the InsertItem command of tab control (with TC_ITEM structure)
The best thing to do would be to set a breakpoint in the debugger and see whether it's called twice. I'm sure it is.
In fact I've heard sporadic reports of this happening in the past (OnIntialUpdate called twice for CFormView). One way around this is to use some kind of class member "flag" e.g. bool m_bHasBeenInitialized and set to true at the end of the first OnInitialUpdate)
I thought I was putting it in a function that was called once. I put it in OnInitialUpdate(). I looked for InitDialog() or something similiar, but it wasn't found in the class wizard. I have a dialog of type CFormView.
"With a tab control by itself you have a tab control within a dialog box that doesn't affect any other controls. So having an "edit control" per tab doesn't make sense, unless you write special code that hides and shows the edit controls when you click on each tab. "
Create a dialog box, add a tab control to it, add tabs to the tab control, and then add several edit controls to the dialog box, one for each tab you require. On response to the tab control click, you can do a ShowWindow(SW_SHOW) of the edit control you wish to show, and ShowWindow(SW_HIDE) to all the other edit controls e.g.
Thanks Ted, I didn't even think about creating a flag. I am still trying to get use to using MFC and visual C++. Anyway, I declared it to be TRUE in my constructor and created an If statement to look for the TRUE in the OnInitialUpdate() function. Once it detects that its true, then it creates the tab and sets the flag to FALSE. It works fine now. Thanks!
I am trying to use your idea, but I am having a few problems. I created a dialog box of type CFormView(needed it for splitter windows) and I placed a tab there. when I execute there are no tabs. Can you lead me in the right direction.
Embedding an edit control into a tab control
Ray..G
I think you're mixing up the concepts of tab controls and property sheets.
With a tab control by itself you have a tab control within a dialog box that doesn't affect any other controls. So having an "edit control" per tab doesn't make sense, unless you write special code that hides and shows the edit controls when you click on each tab.
With a property sheet (and property pages), you have a tab control and separate dialog boxes for each "page" that the tabs on the tab control represent. This would be closer to what you want. You can use the CPropertySheet and CPropertyPage classes, and use AddPage to add the property pages to the property sheets. The tab control will use the title of each property page.
SweatCoder
Ted,
How do I resize the edit control box in my tab. When I maximize the window, I want the edit box to be resized. I am able to resize the tab with no problem.
Thanks,
BrentM2
In the initialization of the form view, you have to actually add the tabs to the tab control, i.e. using the InsertItem command of tab control (with TC_ITEM structure)
tdpro
Please include more details What technology are you using What have you tried so far yourself
Thanks, Ayman Shoukry VC++ TeamKris2006
The best thing to do would be to set a breakpoint in the debugger and see whether it's called twice. I'm sure it is.
In fact I've heard sporadic reports of this happening in the past (OnIntialUpdate called twice for CFormView). One way around this is to use some kind of class member "flag" e.g. bool m_bHasBeenInitialized and set to true at the end of the first OnInitialUpdate)
Kent Liu
Richard Sayad
I thought I was putting it in a function that was called once. I put it in OnInitialUpdate(). I looked for InitDialog() or something similiar, but it wasn't found in the class wizard. I have a dialog of type CFormView.
tcItem.mask = TCIF_TEXT;
tcItem.pszText = _T("Display");
m_tabCtrl.InsertItem(0, &tcItem);
tcItem.pszText = _T("Sub");
m_tabCtrl.InsertItem(1, &tcItem);
tcItem.pszText = _T("Main");
m_tabCtrl.InsertItem(2, &tcItem);
tcItem.pszText = _T("1700 Series");
m_tabCtrl.InsertItem(3, &tcItem);
tcItem.pszText = _T("1800 Series");
m_tabCtrl.InsertItem(4, &tcItem);
ggentile
"With a tab control by itself you have a tab control within a dialog box that doesn't affect any other controls. So having an "edit control" per tab doesn't make sense, unless you write special code that hides and shows the edit controls when you click on each tab. "
How do I do that
ricky816
Ted,
I got it to work, but the thing is that when I open a file it doubles my tabs. Why does it do that and how do I get rid of that
c_jensen
Create a dialog box, add a tab control to it, add tabs to the tab control, and then add several edit controls to the dialog box, one for each tab you require. On response to the tab control click, you can do a ShowWindow(SW_SHOW) of the edit control you wish to show, and ShowWindow(SW_HIDE) to all the other edit controls e.g.
void CMyDialog::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult) {
if (TabControl->GetCurSel() == 0) {
EditControl1->ShowWindow(SW_SHOW);
EditControl2->ShowWindow(SW_HIDE);
EditControl3->ShowWindow(SW_HIDE);
} else // do the rest.
Walt-the-IT-Guy
When you say "doubles your tabs" do you mean that it has two sets of the same tabs, i.e.
tab1/tab2/tab3/tab1/tab2/tab3
or do you mean that you see two rows of tabs
If the first, then it must mean that your code it getting called twice, put it in a place that only gets called once on initialization.
mavrick
Patrick14
Antonio de Souza
Ted,
I am trying to use your idea, but I am having a few problems. I created a dialog box of type CFormView(needed it for splitter windows) and I placed a tab there. when I execute there are no tabs. Can you lead me in the right direction.
Thanks!