CPropertySheet is a nice thing but if you want to change its appearance e.g. you dialog should have not only a TabCtrl, but a Static and CEdit over the TabCtrl - you cannot do it.
CTabCtrl is pretty ugly, but with this code snippet life can be beautiful!
So first create the main dialog (e.g. [tt]COurDlg[/tt]) with TabCtrl in it. The size of TabCtrl is important - the pages will get it's size.
Then create template dialogs - our future pages - with following styles :
[ul]
[li]
Style = child[/li]
[li]
Border = none[/li]
[li]
Titlebar = no[/li]
[/ul]
The size of the dialogs doesn't matter - they'll be adapted to the size of the Tab.
Then add a member variable to our class [tt]COurDlg[/tt]
Code:
HWND m_TabPages[_d_TabPagesNum];
In the header of [tt]COurDlg[/tt] class define the number of the pages you want to have.
In the constructor of [tt]COurDlg[/tt] class add
Code:
ZeroMemory(m_TabPages, sizeof(m_TabPages));
In [tt]COurDlg::OnInitDialog()[/tt]
Code:
//.........................
//.........................
//Loops iterator
int i;
//Create the pages if they're not created yet
//(!!!) it is assumed that dialog ressources ID's are IDD_DIALOG1, IDD_DIALOG1 + 1 and so on.
if (!m_TabPages[0])
{
for (i = 0; i < _d_TabPagesNum; i++)
{
m_TabPages[i] = CreateDialog(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDD_DIALOG1 + i), m_TabCtrl, NULL);
}
}
//Give to pages correct size and position on TabCtrl
CRect l_Rect;
m_TabCtrl.GetClientRect(l_Rect);
l_Rect.top += 25;
l_Rect.left += 2;
l_Rect.right -= 2;
l_Rect.bottom -= 2;
for (i = 0; i < _d_TabPagesNum; i++)
{
::MoveWindow(m_TabPages[i], l_Rect.left, l_Rect.top, l_Rect.Width(), l_Rect.Height(), true);
}
//Make tabs on the control
for (i = 0; i < _d_TabPagesNum; i++)
{
CString c_Caption;
c_Caption.Format("%d", i);
m_TabCtrl.InsertItem(i, c_Caption /*Here you can type you names for tabs*/);
}
//Activate first page
m_TabCtrl.SetCurSel(0);
ActivateTabPage(0);
Next create a member function of the [tt]COurDlg[/tt] class (this function will show the clicked page and hide the rest)
Code:
void COurDlg::ActivateTabPage(int p_NumPageToActivate)
{
for (int i = 0; i < _d_TabPagesNum; i++)
{
::ShowWindow(m_TabPages[i], ((i == p_NumPageToActivate) ? SW_SHOW : SW_HIDE));
}
}
Add a message handler for our TabCtrl for the message [tt]TCN_SELCHANGE[/tt]
Code:
void COurDlg::OnSelchange***(NMHDR* pNMHDR, LRESULT* pResult)
{
ActivateTabPage(m_TabCtrl.GetCurSel());
*pResult = 0;
}
And at least if you want to control the change of the page i.e. change the page depending on some conditions:
Add a message handler for our TabCtrl for the message [tt]TCN_SELCHANGING[/tt]
Code:
void COurDlg::OnSelchanging***(NMHDR* pNMHDR, LRESULT* pResult)
{
int l_OldPageNum = m_TabCtrl.GetCurSel();
//change the page
*pResult = 0;
//permit to change the page
*pResult = 1;
}
<- here life begins to be beautiful

))))))))))))