|
-
April 12th, 1999, 07:09 PM
#1
Tab Control
How do use a tab control? Do I just have to show/hide the controls when the user clicks on of the tabs, or is there a better way - kinda like the way property sheets work?
MSDN wasn't much help, can somebody point me to a website that has a good example of how to use them?
-
April 12th, 1999, 08:01 PM
#2
I use modeless dialogs for each page.
You have to use modeless dialog for each tab page. Show/Hide can turn out to be very difficult to manage if there are too many controls.
Use modeless dialog for each tab page instead. that is how i do. here is some outline for you.
On the current dialog have only two controls:
1) tab control say IDC_TAB1
2) a dummy static control which will be on top of tab contol. This should be of the size of tabs viewable portion. name it ID_TAB_STATIC.
3) when setting the tab order tab control should be after the static contrl.
each tab page is a child of ID_TAB_STATIC window.
In the resources for each dialog that corresponds to a tab page:
1) set style as child
2) border as none
Override the OnOK() / OnCancel() so that default OnOk() / OnCancel() are not handled.
-
April 13th, 1999, 12:56 AM
#3
Re: I use modeless dialogs for each page.
I do it a bit differently, although I still use modeless dialogs: (If anyone knows a better way, I'd love to know about it)
When the dialogs are contructed, I simply pass a pointer to the tab control as the parent window. By fiddling with the dialog offsets in the resource editor, you can center the child dialogs as you like. Here's the function I use to change dialogs:
void CParentDlg::OnSelchangeMaintab(NMHDR* pNMHDR, LRESULT* pResult)
{
int nTab = m_mainTab.GetCurSel();
m_pCurTabDlg->ShowWindow(SW_HIDE);
switch(nTab)
{
case 0:
m_pIncludeDlg->ShowWindow(SW_SHOW);
m_pCurTabDlg = (CDialog*)m_pIncludeDlg;
break;
case 1:
m_pExcludeDlg->ShowWindow(SW_SHOW);
m_pCurTabDlg = (CDialog*)m_pExcludeDlg;
break;
case 2:
m_pDestDlg->ShowWindow(SW_SHOW);
m_pCurTabDlg = (CDialog*)m_pDestDlg;
break;
}
*pResult = 0;
}
The variable types should be fairly obvious. Also, I found it necessary to override OnCommand, otherwise the user would be able to close the modeless dialogs by pressing enter when focus was on a control:
BOOL CIncludeDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (wParam & 0xff00)
return CDialog::OnCommand(wParam, lParam);
else
return(TRUE);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|