Beispiel #1
1
void CuDlgCacheTab::DisplayPage (CACHELINEINFO* pData)
{
	CString csButtonTitle;
	CWnd* pParent1 = GetParent ();              // View (CvDbmsCacheViewRight)
	ASSERT_VALID (pParent1);
	CWnd* pParent2 = pParent1->GetParent ();    // SplitterWnd
	ASSERT_VALID (pParent2);
	CWnd* pParent3 = pParent2->GetParent ();    // Frame (CfDbmsCacheFrame)
	ASSERT_VALID (pParent3);
	CWnd* pParent4 = pParent3->GetParent ();    // Modeless Dialog (CuDlgDbmsCache)
	ASSERT_VALID (pParent4);

	CWnd* pParent5 = pParent4->GetParent ();    // CTabCtrl
	ASSERT_VALID (pParent5);
	CWnd* pParent6 = pParent5->GetParent ();    // CConfRightDlg
	ASSERT_VALID (pParent6);

	CButton* pButton1 = (CButton*)((CConfRightDlg*)pParent6)->GetDlgItem (IDC_BUTTON1);
	CButton* pButton2 = (CButton*)((CConfRightDlg*)pParent6)->GetDlgItem (IDC_BUTTON2);

	CuCacheCheckListCtrl* pList = GetCacheListCtrl();
	CTabCtrl* pTab = (CTabCtrl*)GetDlgItem(IDC_TAB1);
	if (m_pCurrentPage)
	{
		//
		// Try to save (and validate) the data that has been changed
		// in the old page before displaying a new page.
		m_pCurrentPage->SendMessage(WMUSRMSG_CBF_PAGE_VALIDATE, (WPARAM)0, (LPARAM)0);
		m_pCurrentPage->ShowWindow (SW_HIDE);
		m_pCurrentPage = NULL;
	}
	if (!(pTab && IsWindow (pTab->m_hWnd)))
		return;

	UINT nState = 0;
	int i, nCurSel = -1, nCount = pList->GetItemCount();
	for (i=0; i<nCount; i++)
	{
		nState = pList->GetItemState (i, LVIS_SELECTED);
		if (nState & LVIS_SELECTED)
		{
			nCurSel = i;
			break;
		}
	}
	if (nCurSel == -1)
		return;
	if (!pData)
		return;
	try
	{
		if (!VCBFllInitCacheParms(pData))
			return;
		int nSel = pTab->GetCurSel();
		switch (nSel)
		{
		case 0:
			csButtonTitle.LoadString(IDS_BUTTON_EDIT_VALUE);
			pButton1->SetWindowText (csButtonTitle);

			csButtonTitle.LoadString(IDS_BUTTON_RESTORE);
			pButton2->SetWindowText (csButtonTitle);
			if (!m_pCacheParameter)
			{
				m_pCacheParameter = new CuDlgDbmsCacheParameter (pTab);
				m_pCacheParameter->Create (IDD_DBMS_PAGE_CACHE_PARAMETER, pTab);
			}
			m_pCurrentPage = m_pCacheParameter;
			break;
		case 1:
			csButtonTitle.LoadString(IDS_BUTTON_EDIT_VALUE);
			pButton1->SetWindowText (csButtonTitle);

			csButtonTitle.LoadString(IDS_BUTTON_RECALCULATE);
			pButton2->SetWindowText (csButtonTitle);

			if (!m_pCacheDerived)
			{
				m_pCacheDerived = new CuDlgDbmsCacheDerived (pTab);
				m_pCacheDerived->Create (IDD_DBMS_PAGE_CACHE_DERIVED, pTab);
			}
			m_pCurrentPage = m_pCacheDerived;
			break;
		default:
			break;
		}
		if (m_pCurrentPage) 
		{
			CRect r;
			pTab->GetClientRect (r);
			pTab->AdjustRect (FALSE, r);
			m_pCurrentPage->SendMessage (WMUSRMSG_CBF_PAGE_UPDATING, 0, 0);
			m_pCurrentPage->MoveWindow(r);
			m_pCurrentPage->ShowWindow(SW_SHOW);
		}
	}
	catch (CeVcbfException e)
	{
		//
		// Catch critical error 
		TRACE1 ("CuDlgCacheTab::DisplayPage has caught exception: %s\n", e.m_strReason);
		CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
		pMain->CloseApplication (FALSE);
	}
	catch (CMemoryException* e)
	{
		VCBF_OutOfMemoryMessage ();
		e->Delete();
	}
	catch (...)
	{
		TRACE0 ("Other error occured ...\n");
	}
}
Beispiel #2
1
BOOL CMainTabDlg::OnInitDialog() 
{
	CRect   r;
	TC_ITEM item;
	CString strTab;
	UINT nTabID[3]= {IDS_TAB_MAIN_CONFIGURE,IDS_TAB_MAIN_HISTORY,IDS_TAB_MAIN_PREFERENCES};
	CDialog::OnInitDialog();
	memset (&item, 0, sizeof (item));
	item.mask       = TCIF_TEXT|TCIF_IMAGE;
	item.cchTextMax = 32;
	item.iImage     = -1;
	CTabCtrl * ptab = (CTabCtrl * )GetDlgItem(IDC_TAB1);
	ASSERT(ptab);

	ptab->GetWindowRect (r);
	ScreenToClient (r);
	m_dlgPadding.cx = r.left;
	m_dlgPadding.cy = r.top;

	CButton* pButton1= (CButton*)GetDlgItem(IDC_BUTTON1);
	ASSERT (pButton1);
	pButton1->GetWindowRect (r);
	ScreenToClient (r);
	m_buttonPadding.cx = r.right;
	m_buttonPadding.cy = r.bottom;
	int nTab = 2;
#if defined (OIDSK)
	nTab = 2;
#endif
	for (int i=0; i<nTab; i++)  {
		strTab.LoadString (nTabID [i]);
		item.pszText = (LPTSTR)(LPCTSTR)strTab;
		ptab->InsertItem (i, &item);
	}
	if (m_pCurDlg)
		m_pCurDlg->ShowWindow (SW_HIDE);
	CTabCtrl* pTab = (CTabCtrl*) GetDlgItem(IDC_TAB1);
	int nsel = pTab->GetCurSel();
	switch (nsel) 
	{
	case PANE_CONFIG:
		if (!m_pConfigDlg)
		{
			m_pConfigDlg = new CConfigDlg(pTab);
			m_pConfigDlg->Create(IDD_CONFIG,pTab);
		}
		m_pCurDlg= m_pConfigDlg;
		break;
	case PANE_HISTORY:
		if (!m_pHistDlg)
		{
			m_pHistDlg = new CHistDlg(pTab);
			m_pHistDlg->Create(IDD_HISTORY,pTab);
		}
		m_pCurDlg= m_pHistDlg;
		break;
	case PANE_PREFERENCES:
		if (!m_pPrefDlg)
		{
			m_pPrefDlg = new CPrefDlg(pTab);
			m_pPrefDlg->Create(IDD_PREFERENCES,pTab);
		}
		m_pCurDlg= m_pPrefDlg;
		break;
	} 

	if (m_pCurDlg) 
	{
		CRect r;
		pTab->GetClientRect (r);
		pTab->AdjustRect (FALSE, r);
		m_pCurDlg->MoveWindow(r);
		m_pCurDlg->ShowWindow(SW_SHOW);
	}
	SHOSTINFO CurInfo;
	
	VCBFGetHostInfos(&CurInfo);
	CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_NAME_INSTALL);
	pStatic->SetWindowText((LPCTSTR)CurInfo.ii_installation_name);
	
	pStatic = (CStatic*)GetDlgItem(IDC_STATIC_INSTALL);
	pStatic->SetWindowText((LPCTSTR)CurInfo.ii_installation);
	
	
	pStatic = (CStatic*)GetDlgItem(IDC_STATIC_IISYSTEM_NAME);
	pStatic->SetWindowText((LPCTSTR)CurInfo.ii_system_name);
	
	pStatic = (CStatic*)GetDlgItem(IDC_STATIC_II_SYSTEM);
	pStatic->SetWindowText((LPCTSTR)CurInfo.ii_system);
	
	pStatic = (CStatic*)GetDlgItem(IDC_STATIC_HOST);
	pStatic->SetWindowText((LPCTSTR)CurInfo.host);


	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #3
0
void CResizableSheet::SaveWindowRect()
{
	CString data;
	WINDOWPLACEMENT wp;

	ZeroMemory(&wp, sizeof(WINDOWPLACEMENT));
	wp.length = sizeof(WINDOWPLACEMENT);
	GetWindowPlacement(&wp);
	
	RECT& rc = wp.rcNormalPosition;	// alias

	// also saves active page index, zero (the first) if problems
	// cannot use GetActivePage, because it always fails
	CTabCtrl *pTab = GetTabControl();
	int page = 0;

	if (pTab != NULL) 
		page = pTab->GetCurSel();
	if (page < 0)
		page = 0;

	// always save page
	data.Format(PROFILE_FMT, rc.left, rc.top,
		rc.right, rc.bottom, wp.showCmd, wp.flags, page);

	AfxGetApp()->WriteProfileString(m_sSection, m_sEntry, data);
}
void CXTPSkinObjectTab::DrawTab(CDC* pDC, int iItem)
{
	CXTPClientRect rc(this);
	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	// Get the current tab selection.
	int iCurSel = pTabCtrl->GetCurSel();

	// Get the tab item size.
	CRect rcItem;
	pTabCtrl->GetItemRect(iItem, &rcItem);

	if (!CRect().IntersectRect(rcItem, rc))
		return;

	CRect rcItemFocus(rcItem);

	// Draw the tab item.
	BOOL bSelected = (iItem == iCurSel);
	FillTabFace(pDC, rcItem, iItem, pTabCtrl->GetItemCount(), bSelected);
	DrawTabIcon(pDC, rcItem, iItem);
	DrawTabText(pDC, rcItem, iItem, iItem, bSelected);

	// draw the focus rect
	if (bSelected && ::GetFocus() == m_hWnd && (SendMessage(WM_QUERYUISTATE) & UISF_HIDEFOCUS) == 0)
	{
		rcItemFocus.DeflateRect(GetMetrics()->m_cxEdge / 2, GetMetrics()->m_cyEdge / 2);
		pDC->DrawFocusRect(&rcItemFocus);
	}
}
CRect CXTPSkinObjectTab::GetHeaderRect()
{
	CRect rcHeader;
	GetClientRect(&rcHeader);

	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	// get the selected tab item rect.
	CRect rcItem;
	pTabCtrl->GetItemRect(pTabCtrl->GetCurSel(), &rcItem);

	DWORD dwStyle = GetStyle();

	if (IsRight(dwStyle))
	{
		rcHeader.left = rcItem.left;
	}
	else if (IsLeft(dwStyle))
	{
		rcHeader.right = rcItem.right;
	}
	else if (IsBottom(dwStyle))
	{
		rcHeader.top = rcItem.top;
	}
	else
	{
		rcHeader.bottom = (rcHeader.top + rcItem.Height()) * pTabCtrl->GetRowCount() + GetMetrics()->m_cyEdge;
	}
	return rcHeader;
}
Beispiel #6
0
BOOL CTreePropSheet::SelectCurrentPageTreeItem()
{
	CTabCtrl	*pTab = GetTabControl();
	if (!IsWindow(pTab->GetSafeHwnd()))
		return FALSE;

	return SelectPageTreeItem(pTab->GetCurSel());
}
Beispiel #7
0
void CMainTabDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if (m_pCurDlg) 
	{
		//
		// Try to save (and validate) the data that has been changed
		// in the old page before displaying a new page.
		m_pCurDlg->SendMessage(WMUSRMSG_CBF_PAGE_VALIDATE, (WPARAM)0, (LPARAM)0);
		m_pCurDlg->ShowWindow(SW_HIDE);
		m_pCurDlg->SendMessage (WM_COMPONENT_EXIT, 0, 0);
		m_pCurDlg = NULL;
	}
	
	CTabCtrl* pTab = (CTabCtrl*) GetDlgItem(IDC_TAB1);
	int nsel = pTab->GetCurSel();
	
	switch (nsel) 
	{
	case  PANE_CONFIG:
		if (!m_pConfigDlg)
		{
			m_pConfigDlg = new CConfigDlg(pTab);
			m_pConfigDlg->Create(IDD_CONFIG,pTab);
		}
		m_pCurDlg= m_pConfigDlg;
		break;
	case PANE_HISTORY:
		if (!m_pHistDlg)
		{
			m_pHistDlg = new CHistDlg(pTab);
			m_pHistDlg->Create(IDD_HISTORY,pTab);
		}
		m_pCurDlg= m_pHistDlg;
		break;
	case PANE_PREFERENCES:
		if (!m_pPrefDlg)
		{
			m_pPrefDlg = new CPrefDlg(pTab);
			m_pPrefDlg->Create(IDD_PREFERENCES,pTab);
		}
		m_pCurDlg= m_pPrefDlg;
		break;
	} 
	
	if (m_pCurDlg) 
	{
		CRect r;
		pTab->GetClientRect (r);
		pTab->AdjustRect (FALSE, r);
		m_pCurDlg->MoveWindow(r);
		m_pCurDlg->ShowWindow(SW_SHOW);
		m_pCurDlg->SendMessage(WMUSRMSG_CBF_PAGE_UPDATING, 0, 0);
		m_pCurDlg->SendMessage(WM_COMPONENT_ENTER, 0, 0);
	}
}
Beispiel #8
0
void CxDlgPropertySheetSqlWizard::OnHelp()
{
	CTabCtrl* pTab = GetTabControl();
	ASSERT(pTab);
	if (pTab)
	{
		int nActivePage = pTab->GetCurSel();
		CPropertyPage* pPage = GetPage(nActivePage);
		if (pPage)
			pPage->SendMessage (WM_HELP);
	}
}
// @pymethod int|PyCTabCtrl|GetCurSel|Gets the current selection of a tab control.
PyObject *ui_tabctrl_get_cur_sel( PyObject *self, PyObject *args )
{
	CHECK_NO_ARGS(args);
	CTabCtrl *pTab;
	if ((pTab=PyGetTabCtrl(self))==NULL)
		return NULL;
	GUI_BGN_SAVE;
	int rc = pTab->GetCurSel();
	GUI_END_SAVE;
	return Py_BuildValue("i", rc);
	// @rdesc The zero-based index of the currently selected item, or -1 if no selection.

}
BOOL CTreePropSheetBase::SelectCurrentPageTreeItem()
{
	CTabCtrl	*pTab = GetTabControl();
	if (!IsWindow(pTab->GetSafeHwnd()))
		return FALSE;

  // TreePropSheetEx: Fix problem when removing last page from control.
  int nPage = pTab->GetCurSel();
  if( nPage >= 0 && nPage < pTab->GetItemCount() )
    return SelectPageTreeItem( nPage );
  // TreePropSheetEx: End fix problem when removing last page from control.

  return FALSE;
}
void CInstrumentEditDlg::OnTcnSelchangeInstTab(NMHDR *pNMHDR, LRESULT *pResult)
{
	CTabCtrl *pTabControl = static_cast<CTabCtrl*>(GetDlgItem(IDC_INST_TAB));
	int Selection = pTabControl->GetCurSel();

	for (int i = 0; i < PANEL_COUNT; i++) {
		if (m_pPanels[i] != NULL && i != Selection) {
			m_pPanels[i]->ShowWindow(SW_HIDE);
		}
	}

	m_pPanels[Selection]->ShowWindow(SW_SHOW);

	m_pFocusPanel = m_pPanels[Selection];

	*pResult = 0;
}
void CXTPSkinObjectTab::OnDraw(CDC* pDC)
{
	CRect rc = GetHeaderRect();
	DWORD dwStyle = GetStyle();

	if (IsRight(dwStyle))
	{
		rc.left -= 2;
	}
	else if (IsLeft(dwStyle))
	{
		rc.right += 2;
	}
	else if (IsBottom(dwStyle))
	{
		rc.top -= 2;
	}
	else
	{
		rc.bottom += 2;
	}

	CXTPBufferDC dcMem(*pDC, rc);
	FillClient(&dcMem, CXTPClientRect(this));

	if (m_bActiveX)
	{
		m_bPaint = TRUE;
		CXTPBufferDC dcMem2(*pDC, rc);
		DefWindowProc(WM_PAINT, (WPARAM)dcMem2.GetSafeHdc(), 0);
		dcMem2.Discard();
		m_bPaint = FALSE;
	}

	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	CXTPFontDC font(&dcMem, GetFont());
	dcMem.SetBkMode(TRANSPARENT);

	for (int iItem = 0; iItem < pTabCtrl->GetItemCount(); ++iItem)
	{
		DrawTab(&dcMem, iItem);
	}

	DrawTab(&dcMem, pTabCtrl->GetCurSel());
}
Beispiel #13
0
UINT CuDlgCacheTab::GetHelpID()
{
	if (!m_pCurrentPage)
		return 0;
	CTabCtrl* pTab = (CTabCtrl*)GetDlgItem(IDC_TAB1);
	int nSel = pTab->GetCurSel();
	switch (nSel)
	{
	case 0:
		return IDD_DBMS_PAGE_CACHE_PARAMETER;
	case 1:
		return IDD_DBMS_PAGE_CACHE_DERIVED;
	default:
		return 0;
	}

	return 0;
}
void CResizableSheet::SavePage()
{
	if (!m_bSavePage)
		return;

	// saves active page index, zero (the first) if problems
	// cannot use GetActivePage, because it always fails

	CTabCtrl *pTab = GetTabControl();
	int page = 0;

	if (pTab != NULL) 
		page = pTab->GetCurSel();
	if (page < 0)
		page = 0;

	AfxGetApp()->WriteProfileInt(m_sSection, ACTIVEPAGE, page);
}
/*!
 *  This function saves the current property sheet active page using the base
 *  class persist method.
 *  @sa CResizableState::WriteState
 *
 *  @param pszName String that identifies stored settings
 *
 *  @return Returns @a TRUE if successful, @a FALSE otherwise
 */
BOOL CResizableSheetState::SavePage(LPCTSTR pszName)
{
    // saves active page index, or the initial page if problems
    // cannot use GetActivePage, because it always fails

    CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, GetResizableWnd());
    if (pSheet == NULL)
        return FALSE;

    int page = pSheet->m_psh.nStartPage;
    CTabCtrl *pTab = pSheet->GetTabControl();
    if (pTab != NULL)
        page = pTab->GetCurSel();
    if (page < 0)
        page = pSheet->m_psh.nStartPage;

    CString data, id;
    _itot(page, data.GetBuffer(10), 10);
    id = CString(pszName) + ACTIVEPAGE_ENT;
    return WriteState(id, data);
}
Beispiel #16
0
UINT CMainTabDlg::GetHelpID()
{
	CTabCtrl* pTab = (CTabCtrl*) GetDlgItem(IDC_TAB1);
	int nsel = pTab->GetCurSel();
	UINT nHelpID = 0;
	
	switch (nsel) 
	{
	case  PANE_CONFIG:
		ASSERT (m_pConfigDlg != NULL);
		nHelpID = m_pConfigDlg? m_pConfigDlg->GetHelpID(): 0;
		return (nHelpID == 0)? (IDD_CONFIG_LEFT+VCBF_HELP_): (nHelpID+VCBF_HELP_);
	case PANE_HISTORY:
		ASSERT (m_pHistDlg != NULL);
		return (IDD_HISTORY + VCBF_HELP_);
	case PANE_PREFERENCES:
		ASSERT (m_pPrefDlg != NULL);
		return (IDD_PREFERENCES + VCBF_HELP_);
	default:
		return nHelpID;
	} 
}
Beispiel #17
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 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;
}