Exemplo n.º 1
0
void COptionSheet::UpdateAllButtonsState()
{
	// If in wizard mode, process the next/back buttons
	if(TRUE == IsWizardMode()) {
		CWnd *wnd;

		BOOL bNextState;
		BOOL bBackState;

		if(NULL == m_CurrentPage) {
			bNextState = FALSE;
			bBackState = FALSE;
		} else if(0 == m_PageIndex) {
			bNextState = TRUE;
			bBackState = FALSE;
		} else if(m_PageIndex == (GetPageCount() - 1)) {
			bNextState = FALSE;
			bBackState = TRUE;
		} else {
			bNextState = TRUE;
			bBackState = TRUE;
		}

		// Update the "Next" button
		wnd = GetDlgItem(ID_WIZNEXT);
		if(NULL != wnd) {
			wnd->EnableWindow(bNextState);
		}

		// Update the "Back" button
		wnd = GetDlgItem(ID_WIZBACK);
		if(NULL != wnd) {
			wnd->EnableWindow(bBackState);
		}

		// Update the "Finish" button
		wnd = GetDlgItem(ID_WIZFINISH);
		if(NULL != wnd) {
			wnd->EnableWindow((0 == (m_WizButFlags & OSWIZB_DISABLEDFINISH)) ? TRUE : FALSE);
		}
	}

	if(FALSE == IsWizardMode()) {
		CWnd *wnd = GetDlgItem(ID_APPLY_NOW);
		if(NULL != wnd) {
			wnd->EnableWindow(m_Modified);
		}
	}

}
Exemplo n.º 2
0
int COptionSheet::GetButtonWidth(UINT id)
{
	int retval = 0;

	switch(id) {
	case IDOK:
	case IDCANCEL:
		retval = m_ButtonWidth;
		break;
	case IDHELP:
		if(m_psh.dwFlags & OSH_HASHELP) {
			retval = m_ButtonWidth;
		}
		break;
	default:
		if(TRUE == IsWizardMode()) {
			switch(id) {
			case ID_WIZBACK:
			case ID_WIZNEXT:
				retval = m_ButtonWidth;
			case ID_WIZFINISH:
				if(m_psh.dwFlags & OSH_WIZARDHASFINISH) {
					retval = m_ButtonWidth;
				}
				break;
			}
		} else {
			ASSERT(0);
		}
		break;
	}

	return 0;
}
Exemplo n.º 3
0
//////////////////////////////////////////////////////////////////////////////
//
//	Operations
//
//////////////////////////////////////////////////////////////////////////////
BOOL COptionSheet::DoModal()
{
	BOOL result;
	int oldWidth;

	// Save the old list control width;
	oldWidth = m_ListWidth;
	if(TRUE == IsWizardMode()) {
		m_ListWidth = 0;
	}

	// Create the template
	m_DlgTemplate = CreateDlgTemplate(-1, 0);


	// Initialize the modal dialog template
	CDialog::InitModalIndirect(m_DlgTemplate, m_pParentWnd);

	// Enter the modal loop
	result = CDialog::DoModal();

	// Retore!
	m_hDialogTemplate = NULL;
	m_pParentWnd = NULL;

	// Restore the old list control width
	m_ListWidth = oldWidth;

	return result;
}
Exemplo n.º 4
0
void COptionSheet::SetFinishText(LPCWSTR lpszText)
{
	ASSERT(NULL != lpszText);

	if(TRUE == IsWizardMode()) {
		CWnd *wnd;

		wnd = GetDlgItem(ID_WIZFINISH);
		if(NULL != wnd) {
			wnd->SetWindowText(lpszText);
			wnd->ShowWindow(SW_SHOW);
		}

		wnd = GetDlgItem(ID_WIZBACK);
		if(NULL != wnd) {
			wnd->ShowWindow(SW_HIDE);
		}

		wnd = GetDlgItem(ID_WIZNEXT);
		if(NULL != wnd) {
			wnd->ShowWindow(SW_HIDE);
		}
	}

}
Exemplo n.º 5
0
BOOL COptionSheet::PressButton(int nButton)
{

	BOOL result = FALSE;

	switch(nButton) {
	case OSBTN_BACK:
		if(TRUE == IsWizardMode()) {
			result = SendMessage(WM_COMMAND, ID_WIZBACK, 0);
		}
		break;

	case OSBTN_NEXT:
		if(TRUE == IsWizardMode()) {
			result = SendMessage(WM_COMMAND, ID_WIZNEXT, 0);
		}
		break;

	case OSBTN_FINISH:
		if(TRUE == IsWizardMode()) {
			result = SendMessage(WM_COMMAND, ID_WIZFINISH, 0);
		}
		break;

	case OSBTN_OK:
		result = SendMessage(WM_COMMAND, IDOK, 0);
		break;

	case OSBTN_APPLYNOW:
		result = SendMessage(WM_COMMAND, ID_APPLY_NOW, 0);
		break;

	case OSBTN_CANCEL:
		result = SendMessage(WM_COMMAND, IDCANCEL, 0);
		break;

	case OSBTN_HELP:
		result = SendMessage(WM_COMMAND, IDHELP, 0);
		break;

	default:
		ASSERT(0);
	}

	return result;
}
Exemplo n.º 6
0
BOOL COptionSheet::Create(CWnd* pParentWnd, DWORD dwStyle, DWORD dwExStyle)
{
	BOOL result;

	// We do not go into wizard mode here since we cannot statically save the 
	// list control width
	ASSERT(TRUE != IsWizardMode());

	// Make sure we are a popup
	dwStyle |= WS_POPUP;

	m_DlgTemplate = CreateDlgTemplate(dwStyle, dwExStyle);
	
	result = CDialog::CreateIndirect(m_DlgTemplate, pParentWnd);

	m_hDialogTemplate = NULL;
	m_pParentWnd = NULL;

	return result;
}
Exemplo n.º 7
0
BOOL COptionSheet::OnInitDialog() 
{
	BOOL		result;
	CRect		rcClient;
	int			width;
	int			height;

	// Call the default behaviour
	CDialog::OnInitDialog();

	m_CurrentPage = NULL;

	// Create out button font
	if(NULL != m_Font.GetSafeHandle()) {
		m_Font.DeleteObject();
	}

	m_Font.Attach(GetStockObject(DEFAULT_GUI_FONT));

	// Set the icon
	if(m_psh.dwFlags & OSH_USEHICON && NULL != m_psh.hIcon) {
		SetIcon(m_psh.hIcon, FALSE);
	}

	// Calculate spacing needed by all items
	result = CalcSpacing(m_Font);
	if(FALSE == result) {
		ASSERT(0);
		DestroyWindow();
		return TRUE;
	}

	// Adjust our X position to compensate for the biggest child dialog
	width = m_MaxChildSize.cx;
	if(m_psh.dwFlags & OSH_WIZARDFULL) {
		width += (FULLPAGE_SPACING * 2);
	} else {
		width += (PAGE_SPACING * 2);
	}
	if(0 != m_ListWidth) {
		width += m_ListWidth + PAGE_SPACING;
	}

	if(width < m_AllButtonsWidth) {
		width = m_AllButtonsWidth;
	}

	width += m_XBorder;


	// Adjust our X position to compensate for the biggest child dialog
	height = m_YBorder + m_MaxChildSize.cy + m_ButtonSpacing;
	if(!(m_psh.dwFlags & OSH_WIZARDFULL)) {
		height += (PAGE_SPACING * 2);
	}
	
	// Set the new window position
	SetWindowPos(&wndTop,
				 0,
				 0,
				 width, 
				 height,
				 SWP_NOMOVE | SWP_NOZORDER);

	// Set the title
	if(0 != m_strCaption.GetLength()) {
		SetWindowText(m_strCaption);
	}


	// Add the buttons
	AddButtons();

	// IF we are not in wizard mode, select the first root tree item
	// otherwise, display the first page in the list.
	if(FALSE == IsWizardMode()) {
		CRect rect;
		// Select the default item
		BuildList();
		CalcTreeRect(rect);
		GetListControlWnd()->MoveWindow(rect);
	}

	SetActivePage(m_StartPageIndex);

	SetModified(FALSE);

	// We are done!
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 8
0
int COptionSheet::AddButtons(BOOL addBut)
{
	int		x;
	CRect	rcClient;

	// Add the standard buttons
	GetClientRect(rcClient);

	if(TRUE == addBut) {
		x = rcClient.Width() - (PAGE_SPACING2 + m_AllButtonsWidth);
	} else {
		x = 0;
	}

	if(TRUE == IsWizardMode()) {

		// Add the back button
		if(TRUE == addBut) {
			AddButton(L"< Back", x, m_ButtonWidth, ID_WIZBACK);
		}
		x += m_ButtonWidth;

		// Add the next button
		if(TRUE == addBut) {
			AddButton(L"Next >", x, m_ButtonWidth, ID_WIZNEXT);
		}

		// Add in the finish button
		if(m_psh.dwFlags & OSH_WIZARDHASFINISH) {
			x += (m_ButtonWidth + BUTTON_SPACING);
			if(TRUE == addBut) {
				AddButton(L"Finish", x, m_ButtonWidth, ID_WIZFINISH);
			}
		} else {
			if(TRUE == addBut) {
				AddButton(L"Finish", x, m_ButtonWidth, ID_WIZFINISH, FALSE);
			}
		}

		// Add the finish button
		x += m_ButtonWidth;

	} else {

		// Add the OK button
		if(TRUE == addBut) {
			AddButton(L"OK", x, m_ButtonWidth, IDOK);
		}
		x += m_ButtonWidth;

		// Add the Apply button
		if(!(m_psh.dwFlags & OSH_NOAPPLYNOW)) {
			if(TRUE == addBut) {
				AddButton(L"Apply", x, m_ButtonWidth, ID_APPLY_NOW);
			}
			x += m_ButtonWidth;
		}

	}

	// Add the cancel button
	x += BUTTON_SPACING;
	if(TRUE == addBut) {
		AddButton(L"Cancel", x, m_ButtonWidth, IDCANCEL);
	}
	x += m_ButtonWidth;

	// Add the help button
	if(m_psh.dwFlags & OSH_HASHELP) {
		x += BUTTON_SPACING;
		if(TRUE == addBut) {
			AddButton(L"Help", x, m_ButtonWidth, IDHELP);
		}
		x += m_ButtonWidth;
	}
	return x;
}
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;
}