Beispiel #1
0
BOOL CCustomPropSheet::OnInitDialog(void)
{
	__super::OnInitDialog();

	// get the font for the first active page
	CPropertyPage* pCurPage = GetActivePage();
	ASSERT(pCurPage != NULL);

	// change the font for the sheet
	ChangeDialogFont(this, &m_fontPage, CDF_CENTER);

	// change the font for each page
	for (int i = 0, cPages = GetPageCount(); i < cPages; ++i)
	{
		CPropertyPage* pPage = GetPage(i);
		ASSERT(pPage != NULL);
#if !defined(_BUGFIX_)
		ChangeDialogFont(pPage, &m_fontPage, CDF_CENTER);
#else
		ChangeDialogFont(pPage, &m_fontPage, CDF_TOPLEFT);
#endif   // _BUGFIX_
	}

	// set and save the size of the page
	CTabCtrl* pTab = GetTabControl();
	ASSERT(pTab != NULL);

	if ((m_psh.dwFlags & PSH_WIZARD) != 0)
	{
		pTab->ShowWindow(SW_HIDE);
#if !defined(_BUGFIX_)
		GetClientRect(&m_rcPage);
		CWnd* pButton = GetDlgItem(ID_WIZBACK);
		ASSERT(pButton != NULL);
		CRect rectButton;
		pButton->GetWindowRect(rectButton);
		ScreenToClient(rectButton);
		m_rcPage.bottom = rectButton.top - 2;
#else
		CRect rectDivider;
		CWnd* pDivider = GetDlgItem(0x3026);
		ASSERT(pDivider != NULL);
		pDivider->GetWindowRect(rectDivider);
		ScreenToClient(rectDivider);
		m_rcPage.bottom = rectDivider.top - 2;
#endif   // _BUGFIX_
	}
	else
	{
		pTab->GetWindowRect(&m_rcPage);
		ScreenToClient(&m_rcPage);
		pTab->AdjustRect(FALSE, &m_rcPage);
	}

	// resize the page
	pCurPage->MoveWindow(&m_rcPage);

	return (TRUE);
}
Beispiel #2
0
BOOL CMyPropertySheet::OnInitDialog()
{
	
	BOOL bResult = CPropertySheet::OnInitDialog();	
 
	//计算属性页的矩形,扩大属性表并将属性页其移至右侧
	CRect rect, rectPage, rectTab;
	GetPage(0)->GetWindowRect(&rectPage);
	
	GetWindowRect(&rect);
	rect.right += 150;
	
    int nWidth = rectPage.Width();
	rectPage.right = rect.right - 20; 
	rectPage.left = rect.right - nWidth;
	ScreenToClient(&rectPage);
	m_rectPage = rectPage;
	MoveWindow(&rect);
	GetPage(0)->MoveWindow(&rectPage);
    
	//隐藏属性页原来的TabControl
	CTabCtrl *pTab = GetTabControl() ;
	pTab->GetWindowRect(&rectTab);
	ScreenToClient(&rectTab);
	if(!pTab->ShowWindow(SW_HIDE))
		return FALSE;

	
	
   
	//创建列表控件并用一个CImageList对象与之关联
	if(!m_wndList.Create(WS_CHILD | WS_VISIBLE |  LVS_REPORT | LVS_NOCOLUMNHEADER , CRect(10 ,rectTab.top,150,rectPage.bottom ),this,0xFFFF))
		return FALSE;
	m_wndList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	m_wndList.SetImageList(&m_imgList, LVSIL_SMALL);
	
	InitList();

	//这一步是为了扩大行高度
	CFont font;
	font.CreatePointFont(240,_T("宋体"));
	m_wndList.SetFont(&font);
	
	CString strCaption;
	GetPage(0)->GetWindowText(strCaption);	
	_tcscpy(m_szCaption, strCaption.GetBuffer(strCaption.GetLength()));	

	return bResult;
}
Beispiel #3
0
BOOL CTreePropSheet::OnInitDialog() 
{
	if (m_bTreeViewMode)
	{
		// be sure, there are no stacked tabs, because otherwise the
		// page caption will be to large in tree view mode
		EnableStackedTabs(FALSE);

		// Initialize image list.
		if (m_DefaultImages.GetSafeHandle())
		{
			IMAGEINFO	ii;
			m_DefaultImages.GetImageInfo(0, &ii);
			if (ii.hbmImage) DeleteObject(ii.hbmImage);
			if (ii.hbmMask) DeleteObject(ii.hbmMask);
			m_Images.Create(ii.rcImage.right-ii.rcImage.left, ii.rcImage.bottom-ii.rcImage.top, ILC_COLOR32|ILC_MASK, 0, 1);
		}
		else
			m_Images.Create(16, 16, ILC_COLOR32|ILC_MASK, 0, 1);
	}

	// perform default implementation
	BOOL bResult = CPropertySheet::OnInitDialog();

	if (!m_bTreeViewMode)
		// stop here, if we would like to use tabs
		return bResult;

	// Get tab control...
	CTabCtrl	*pTab = GetTabControl();
	if (!IsWindow(pTab->GetSafeHwnd()))
	{
		ASSERT(FALSE);
		return bResult;
	}

	// ... and hide it
	pTab->ShowWindow(SW_HIDE);
	pTab->EnableWindow(FALSE);

	// Place another (empty) tab ctrl, to get a frame instead
	CRect	rectFrame;
	pTab->GetWindowRect(rectFrame);
	ScreenToClient(rectFrame);

	m_pFrame = CreatePageFrame();
	if (!m_pFrame)
	{
		ASSERT(FALSE);
		AfxThrowMemoryException();
	}
	m_pFrame->Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0xFFFF);
	m_pFrame->ShowCaption(m_bPageCaption);

	// Lets make place for the tree ctrl
	const int	nTreeWidth = m_nPageTreeWidth;
	const int	nTreeSpace = 5;

	CRect	rectSheet;
	GetWindowRect(rectSheet);
	rectSheet.right+= nTreeWidth;
	SetWindowPos(NULL, -1, -1, rectSheet.Width(), rectSheet.Height(), SWP_NOZORDER|SWP_NOMOVE);
	CenterWindow();

	MoveChildWindows(nTreeWidth, 0);

	// Lets calculate the rectangle for the tree ctrl
	CRect	rectTree(rectFrame);
	rectTree.right = rectTree.left + nTreeWidth - nTreeSpace;

	// calculate caption height
	CTabCtrl	wndTabCtrl;
	wndTabCtrl.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0x1234);
	wndTabCtrl.InsertItem(0, _T(""));
	CRect	rectFrameCaption;
	wndTabCtrl.GetItemRect(0, rectFrameCaption);
	wndTabCtrl.DestroyWindow();
	m_pFrame->SetCaptionHeight(rectFrameCaption.Height());

	// if no caption should be displayed, make the window smaller in
	// height
	if (!m_bPageCaption)
	{
		// make frame smaller
		m_pFrame->GetWnd()->GetWindowRect(rectFrame);
		ScreenToClient(rectFrame);
		rectFrame.top+= rectFrameCaption.Height();
		m_pFrame->GetWnd()->MoveWindow(rectFrame);

		// move all child windows up
		MoveChildWindows(0, -rectFrameCaption.Height());

		// modify rectangle for the tree ctrl
		rectTree.bottom-= rectFrameCaption.Height();

		// make us smaller
		CRect	rect;
		GetWindowRect(rect);
		rect.top+= rectFrameCaption.Height()/2;
		rect.bottom-= rectFrameCaption.Height()-rectFrameCaption.Height()/2;
		if (GetParent())
			GetParent()->ScreenToClient(rect);
		MoveWindow(rect);
	}

	// finally create tht tree control
	const DWORD	dwTreeStyle = TVS_SHOWSELALWAYS|TVS_TRACKSELECT|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS;
	m_pwndPageTree = CreatePageTreeObject();
	if (!m_pwndPageTree)
	{
		ASSERT(FALSE);
		AfxThrowMemoryException();
	}
	

    ((CWnd*)m_pwndPageTree)->CreateEx(
    WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, 
    _T("SysTreeView32"), _T("PageTree"), 
    WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle, 
    rectTree, this, s_unPageTreeId);

	//// MFC7-support here (Thanks to Rainer Wollgarten)
	//#if _MFC_VER >= 0x0700
	//{
	//	m_pwndPageTree->CreateEx(
	//		WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, 
	//		WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle, 
	//		rectTree, this, s_unPageTreeId);
	//}
	//#else
	//{
	//	m_pwndPageTree->CreateEx(
	//		WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, 
	//		_T("SysTreeView32"), _T("PageTree"), 
	//		WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle, 
	//		rectTree, this, s_unPageTreeId);
	//}
	//#endif
	
	if (m_bTreeImages)
	{
		m_pwndPageTree->SetImageList(&m_Images, TVSIL_NORMAL);
		m_pwndPageTree->SetImageList(&m_Images, TVSIL_STATE);
	}

	// Fill the tree ctrl
	RefillPageTree();

	// Select item for the current page
	if (pTab->GetCurSel() > -1)
		SelectPageTreeItem(pTab->GetCurSel());


    // Expand all tree items
    HTREEITEM hCurrent = m_pwndPageTree->GetNextItem(NULL, TVGN_FIRSTVISIBLE);
    while (hCurrent != NULL)
    {
        m_pwndPageTree->Expand(hCurrent, TVE_EXPAND);
        hCurrent = m_pwndPageTree->GetNextItem(hCurrent, TVGN_NEXT);
    }
	return bResult;
}
BOOL CTreePropSheet::OnInitDialog() 
{
	if (m_bTreeViewMode)
	{

		// be sure, there are no stacked tabs, because otherwise the
		// page caption will be to large in tree view mode
		EnableStackedTabs(FALSE);

		// Initialize image list.
		if (m_DefaultImages.GetSafeHandle())
		{
			IMAGEINFO	ii;
			m_DefaultImages.GetImageInfo(0, &ii);
			m_Images.Create(ii.rcImage.right - ii.rcImage.left, ii.rcImage.bottom - ii.rcImage.top, ILC_COLOR32 | ILC_MASK, 0, 1);
		}
		else
			m_Images.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1);
	}

	// perform default implementation
	BOOL bResult = CPropertySheet::OnInitDialog();

	if (!m_bTreeViewMode)
		// stop here, if we would like to use tabs
		return bResult;

	// Get tab control...
	CTabCtrl* pTab = GetTabControl();
	if (!IsWindow(pTab->GetSafeHwnd()))
	{
		ASSERT(FALSE);
		return bResult;
	}

	HighColorTab::UpdateImageList(*this);

	// ... and hide it
	pTab->ShowWindow(SW_HIDE);
	pTab->EnableWindow(FALSE);

	// Place another (empty) tab ctrl, to get a frame instead
	CRect rectFrame;
	pTab->GetWindowRect(rectFrame);
	ScreenToClient(rectFrame);

	m_pFrame = CreatePageFrame();
	if (!m_pFrame)
	{
		ASSERT(FALSE);
		AfxThrowMemoryException();
	}
	m_pFrame->Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0xFFFF);
	m_pFrame->ShowCaption(m_bPageCaption);

	// Lets make place for the tree ctrl
	const int nTreeWidth = m_nPageTreeWidth;
	const int nTreeSpace = 5;

	CRect rectSheet;
	GetWindowRect(rectSheet);
	rectSheet.right += nTreeWidth;
	SetWindowPos(NULL, 0, 0, rectSheet.Width(), rectSheet.Height(), SWP_NOZORDER | SWP_NOMOVE);
	CenterWindow();

	MoveChildWindows(nTreeWidth, 0);

	// Lets calculate the rectangle for the tree ctrl
	CRect	rectTree(rectFrame);
	rectTree.right = rectTree.left + nTreeWidth - nTreeSpace;

	// calculate caption height
	CTabCtrl	wndTabCtrl;
	wndTabCtrl.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0x1234);
	wndTabCtrl.InsertItem(0, _T(""));
	CRect	rectFrameCaption;
	wndTabCtrl.GetItemRect(0, rectFrameCaption);
	wndTabCtrl.DestroyWindow();
	m_pFrame->SetCaptionHeight(rectFrameCaption.Height());

	// if no caption should be displayed, make the window smaller in
	// height
	if (!m_bPageCaption)
	{
		// make frame smaller
		m_pFrame->GetWnd()->GetWindowRect(rectFrame);
		ScreenToClient(rectFrame);
		rectFrame.top+= rectFrameCaption.Height();
		m_pFrame->GetWnd()->MoveWindow(rectFrame);

		// move all child windows up
		MoveChildWindows(0, -rectFrameCaption.Height());

		// modify rectangle for the tree ctrl
		rectTree.bottom-= rectFrameCaption.Height();

		// make us smaller
		CRect	rect;
		GetWindowRect(rect);
		rect.top+= rectFrameCaption.Height()/2;
		rect.bottom-= rectFrameCaption.Height()-rectFrameCaption.Height()/2;
		if (GetParent())
			GetParent()->ScreenToClient(rect);
		MoveWindow(rect);
		// Need to center window again to reflect the missing caption bar (noticeable on 640x480 resolutions)
		CenterWindow();
	}

	// finally create the tree control
	//const DWORD	dwTreeStyle = TVS_SHOWSELALWAYS/*|TVS_TRACKSELECT*/|TVS_HASLINES/*|TVS_LINESATROOT*/|TVS_HASBUTTONS;
	// As long as we don't use sub pages we apply the 'TVS_FULLROWSELECT' style for a little more user convinience.
	const DWORD	dwTreeStyle = TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | TVS_NOHSCROLL;
	m_pwndPageTree = CreatePageTreeObject();
	if (!m_pwndPageTree)
	{
		ASSERT(FALSE);
		AfxThrowMemoryException();
	}

	// MFC7-support here (Thanks to Rainer Wollgarten)
	#if _MFC_VER >= 0x0700
	{
		// Using 'CTreeCtrl::CreateEx' (and it's indeed a good idea to call this one), results in
		// flawed window styles (border is missing) when running under WinXP themed.. ???
		//m_pwndPageTree->CreateEx(
		//	WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, 
		//	WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle, 
		//	rectTree, this, s_unPageTreeId);

		// Feel free to explain to me why we need to call CWnd::CreateEx to get the proper window style
		// for the tree view control when running under WinXP. Look at CTreeCtrl::CreateEx and CWnd::CreateEx to
		// see the (minor) difference. However, this could create problems in future MFC versions..
		m_pwndPageTree->CWnd::CreateEx(
			WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY,
			WC_TREEVIEW, _T("PageTree"),
			WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle,
			rectTree, this, s_unPageTreeId);
	}
	#else
	{
		m_pwndPageTree->CreateEx(
			WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, 
			_T("SysTreeView32"), _T("PageTree"), 
			WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle, 
			rectTree, this, s_unPageTreeId);
	}
	#endif

	// This treeview control was created dynamically, thus it does not derive the font
	// settings from the parent dialog. Need to set the font explicitly so that it fits
	// to the font which is used for the property pages.
	m_pwndPageTree->SendMessage(WM_SETFONT, (WPARAM)AfxGetMainWnd()->GetFont()->m_hObject, TRUE);
	
	m_pwndPageTree->SetItemHeight(m_pwndPageTree->GetItemHeight() + 6);

	if (m_bTreeImages)
	{
		m_pwndPageTree->SetImageList(&m_Images, TVSIL_NORMAL);
		m_pwndPageTree->SetImageList(&m_Images, TVSIL_STATE);
	}

	// Fill the tree ctrl
	RefillPageTree();

	// Select item for the current page
	if (pTab->GetCurSel() > -1)
		SelectPageTreeItem(pTab->GetCurSel());

	return bResult;
}
//****************************************************************************************
BOOL CBCGPropertySheet::OnInitDialog() 
{
	BOOL bResult = CPropertySheet::OnInitDialog();
	BOOL bReposButtons = FALSE;

	const int nVertMargin = 5;
	const int nHorzMargin = 5;

	CWnd* pWndNavigator = InitNavigationControl ();

	CRect rectClient;
	GetClientRect (rectClient);

	if (m_wndTab.GetSafeHwnd () != NULL)
	{
		CTabCtrl* pTab = GetTabControl ();
		ASSERT_VALID (pTab);

		CRect rectTab;
		pTab->GetWindowRect (rectTab);
		ScreenToClient (rectTab);

		rectTab.InflateRect (2, 0);

		if (pTab->GetItemCount () > 0)
		{
			CRect rectTabsNew;
			m_wndTab.GetTabsRect (rectTabsNew);

			CRect rectTabsOld;
			pTab->GetItemRect (0, rectTabsOld);

			const int nOldHeight = rectTabsOld.Height ();
			const int nNewHeight = rectTabsNew.Height ();

			if (nNewHeight > nOldHeight)
			{
				rectClient.bottom += nNewHeight - nOldHeight + nVertMargin;
				rectTab.bottom += nNewHeight - nOldHeight;

				SetWindowPos (NULL, -1, -1,
					rectClient.Width (), rectClient.Height (),
					SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
			}
		}

		m_wndTab.MoveWindow (rectTab);

		pTab->ModifyStyle (WS_TABSTOP, 0);
		pTab->ShowWindow (SW_HIDE);

		if (pTab->GetItemCount () > 0)
		{
			m_wndTab.SetActiveTab (0);
		}

		bReposButtons = TRUE;
	}
	else if (pWndNavigator != NULL)
	{
		CTabCtrl* pTab = GetTabControl ();
		ASSERT_VALID (pTab);

		pTab->ModifyStyle (WS_TABSTOP, 0);

		CRect rectTabItem;
		pTab->GetItemRect (0, rectTabItem);
		pTab->MapWindowPoints (this, &rectTabItem);

		const int nTabsHeight = rectTabItem.Height () + nVertMargin;

		SetWindowPos (NULL, -1, -1, rectClient.Width () + m_nBarWidth,
			rectClient.Height () - nTabsHeight + 4 * nVertMargin,
			SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
		
		GetClientRect (rectClient);
		pTab->MoveWindow (m_nBarWidth, -nTabsHeight, rectClient.right, rectClient.bottom - 2 * nVertMargin);

		CRect rectTab;
		pTab->GetWindowRect (rectTab);
		ScreenToClient (rectTab);

		CRect rectNavigator = rectClient;
		rectNavigator.right = rectNavigator.left + m_nBarWidth;
		rectNavigator.bottom = rectTab.bottom;
		rectNavigator.DeflateRect (1, 1);

		pWndNavigator->SetWindowPos (&wndTop, 
							rectNavigator.left, rectNavigator.top,
							rectNavigator.Width (), 
							rectNavigator.Height (),
							SWP_NOACTIVATE);

		SetActivePage (GetActivePage ());

		bReposButtons = TRUE;
	}

	if (bReposButtons)
	{
		int ids[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP	};

		int nTotalButtonsWidth = 0;

		for (int iStep = 0; iStep < 2; iStep++)
		{
			for (int i = 0; i < sizeof (ids) / sizeof (ids [0]); i++)
			{
				CWnd* pButton = GetDlgItem (ids[i]);

				if (pButton != NULL)
				{
					if (ids [i] == IDHELP && (m_psh.dwFlags & PSH_HASHELP) == 0)
					{
						continue;
					}

					if (ids [i] == ID_APPLY_NOW && (m_psh.dwFlags & PSH_NOAPPLYNOW))
					{
						continue;
					}

					CRect rectButton;
					pButton->GetWindowRect (rectButton);
					ScreenToClient (rectButton);

					if (iStep == 0)
					{
						// Align buttons at the bottom
						pButton->SetWindowPos (&wndTop, rectButton.left, 
							rectClient.bottom - rectButton.Height () - nVertMargin, 
							-1, -1, SWP_NOSIZE | SWP_NOACTIVATE);

						nTotalButtonsWidth = rectButton.right;
					}
					else
					{
						// Right align the buttons
						pButton->SetWindowPos (&wndTop, 
							rectButton.left + rectClient.right - nTotalButtonsWidth - nHorzMargin,
							rectButton.top,
							-1, -1, SWP_NOSIZE | SWP_NOACTIVATE);
					}
				}
			}
		}
	}

	return bResult;
}
BOOL CTreePropSheetBase::OnInitDialog() 
{
	if (m_bTreeViewMode && !IsWizardMode() )
	{
	  // Fix suggested by Przemek Miszczuk 
	  // http://www.codeproject.com/property/TreePropSheetEx.asp?msg=1024928#xx1024928xx
    TreePropSheet::CIncrementScope RefillingPageTreeContentGuard(m_nRefillingPageTreeContent );

		// be sure, there are no stacked tabs, because otherwise the
		// page caption will be to large in tree view mode
		EnableStackedTabs(FALSE);

		// Initialize image list.
		if (m_DefaultImages.GetSafeHandle())
		{
			IMAGEINFO	ii;
			m_DefaultImages.GetImageInfo(0, &ii);
			if (ii.hbmImage) DeleteObject(ii.hbmImage);
			if (ii.hbmMask) DeleteObject(ii.hbmMask);
			m_Images.Create(ii.rcImage.right-ii.rcImage.left, ii.rcImage.bottom-ii.rcImage.top, ILC_COLOR32|ILC_MASK, 0, 1);
		}
		else
			m_Images.Create(16, 16, ILC_COLOR32|ILC_MASK, 0, 1);
	}

	// perform default implementation
	BOOL bResult = CPropertySheet::OnInitDialog();

  // If in wizard mode, stop here.
  if( IsWizardMode() )
    return bResult;

	// Get tab control...
	CTabCtrl	*pTab = GetTabControl();
	if (!IsWindow(pTab->GetSafeHwnd()))
	{
		ASSERT(FALSE);
		return bResult;
	}

  // HighColorTab::UpdateImageList to change the internal image list to 24 bits colors)
  HighColorTab::UpdateImageList( *this );

	// If not in tree mode, stop here.
  if (!m_bTreeViewMode)
		// stop here, if we would like to use tabs
		return bResult;

	// ... and hide it
	pTab->ShowWindow(SW_HIDE);
	pTab->EnableWindow(FALSE);

	// Place another (empty) tab ctrl, to get a frame instead
	CRect	rectFrame;
	pTab->GetWindowRect(rectFrame);
	ScreenToClient(rectFrame);

	m_pFrame = CreatePageFrame();
	if (!m_pFrame)
	{
		ASSERT(FALSE);
		AfxThrowMemoryException();
	}
	m_pFrame->Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0xFFFF);
	m_pFrame->ShowCaption(m_bPageCaption);

	// Lets make place for the tree ctrl
	const int	nTreeWidth = m_nPageTreeWidth;

	CRect	rectSheet;
	GetWindowRect(rectSheet);
	rectSheet.right+= nTreeWidth;
	SetWindowPos(NULL, -1, -1, rectSheet.Width(), rectSheet.Height(), SWP_NOZORDER|SWP_NOMOVE);
	CenterWindow();

	MoveChildWindows(nTreeWidth, 0);

	// Lets calculate the rectangle for the tree ctrl
	CRect	rectTree(rectFrame);
	rectTree.right = rectTree.left + nTreeWidth - m_nSeparatorWidth;

	// calculate caption height
	CTabCtrl	wndTabCtrl;
	wndTabCtrl.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0x1234);
	wndTabCtrl.InsertItem(0, _T(""));
	CRect	rectFrameCaption;
	wndTabCtrl.GetItemRect(0, rectFrameCaption);
	wndTabCtrl.DestroyWindow();
	m_pFrame->SetCaptionHeight(rectFrameCaption.Height());

	// if no caption should be displayed, make the window smaller in
	// height
	if (!m_bPageCaption)
	{
		// make frame smaller
		m_pFrame->GetWnd()->GetWindowRect(rectFrame);
		ScreenToClient(rectFrame);
		rectFrame.top+= rectFrameCaption.Height();
		m_pFrame->GetWnd()->MoveWindow(rectFrame);

		// move all child windows up
		MoveChildWindows(0, -rectFrameCaption.Height());

		// modify rectangle for the tree ctrl
		rectTree.bottom-= rectFrameCaption.Height();

		// make us smaller
		CRect	rect;
		GetWindowRect(rect);
		rect.top+= rectFrameCaption.Height()/2;
		rect.bottom-= rectFrameCaption.Height()-rectFrameCaption.Height()/2;
		if (GetParent())
			GetParent()->ScreenToClient(rect);
		MoveWindow(rect);
    CenterWindow();
	}

	// finally create the tree control
	const DWORD	dwTreeStyle = TVS_SHOWSELALWAYS|TVS_TRACKSELECT|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS;
	m_pwndPageTree = CreatePageTreeObject();
	if (!m_pwndPageTree)
	{
		ASSERT(FALSE);
		AfxThrowMemoryException();
	}
	
	// MFC7-support here (Thanks to Rainer Wollgarten)
  // YT: Cast tree control to CWnd and calls CWnd::CreateEx in all cases (VC 6 and7).
  ((CWnd*)m_pwndPageTree)->CreateEx(
    WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, 
    _T("SysTreeView32"), _T("PageTree"), 
    WS_TABSTOP|WS_CHILD|WS_VISIBLE|dwTreeStyle, 
    rectTree, this, s_unPageTreeId);
	
	if (m_bTreeImages)
	{
		m_pwndPageTree->SetImageList(&m_Images, TVSIL_NORMAL);
		m_pwndPageTree->SetImageList(&m_Images, TVSIL_STATE);
	}

  // TreePropSheetEx: Fix refresh problem.
	// Fill the tree ctrl
  {
    TreePropSheet::CWindowRedrawScope WindowRedrawScope( m_pwndPageTree, true );
    // Populate the tree control.
    RefillPageTree();
    // Expand the tree if necessary.
    if( IsAutoExpandTree() )
    {
      ExpandTreeItem( m_pwndPageTree, m_pwndPageTree->GetRootItem(), TVE_EXPAND );
    }
    // Select item for the current page
	  if (pTab->GetCurSel() > -1)
		  SelectPageTreeItem(pTab->GetCurSel());
  }
	return bResult;
}