Esempio n. 1
0
LRESULT CTreePropSheet::OnIsDialogMessage(WPARAM wParam, LPARAM lParam)
{
	MSG	*pMsg = reinterpret_cast<MSG*>(lParam);
	if (pMsg->message == WM_KEYDOWN && (GetKeyState(VK_CONTROL) & 0x8000))
	{
		// Handle default Windows Common Controls short cuts
		if (pMsg->wParam == VK_TAB)
		{
			if (GetKeyState(VK_SHIFT) & 0x8000)
				ActivatePreviousPage();			// Ctrl+Shift+Tab
			else
				ActivateNextPage();				// Ctrl+Tab
			return TRUE;
		}
		else if (pMsg->wParam == VK_PRIOR)
		{
			ActivatePreviousPage();				// Ctrl+PageUp
			return TRUE;
		}
		else if (pMsg->wParam == VK_NEXT)
		{
			ActivateNextPage();					// Ctrl+PageDown
			return TRUE;
		}
	}

	return CPropertySheet::DefWindowProc(PSM_ISDIALOGMESSAGE, wParam, lParam);
}
void CTreePropSheetBase::ActivatePreviousPage(HTREEITEM hItem)
{
		// property sheet with page tree.
		// we need a more sophisticated handling here, than simply using
		// the page index, because we won't skip empty pages.
		// so we have to walk the page tree
		ASSERT(hItem);
		if (!hItem)
			return;

		HTREEITEM	hPrevItem = m_pwndPageTree->GetPrevSiblingItem(hItem);
		if( hPrevItem )
		{
			while (m_pwndPageTree->ItemHasChildren(hPrevItem))
			{
				hPrevItem = m_pwndPageTree->GetChildItem(hPrevItem);
				while (m_pwndPageTree->GetNextSiblingItem(hPrevItem))
					hPrevItem = m_pwndPageTree->GetNextSiblingItem(hPrevItem);
			}
		}
		else 
			hPrevItem=m_pwndPageTree->GetParentItem(hItem);

		if (!hPrevItem)
		{
			// no prev item, so cycle to the last item
			hPrevItem = m_pwndPageTree->GetRootItem();

			while (TRUE)
			{
				while (m_pwndPageTree->GetNextSiblingItem(hPrevItem))
					hPrevItem = m_pwndPageTree->GetNextSiblingItem(hPrevItem);

				if (m_pwndPageTree->ItemHasChildren(hPrevItem))
					hPrevItem = m_pwndPageTree->GetChildItem(hPrevItem);
				else
					break;
			}
		}

    if (!hPrevItem)
      return;

    // If we skip the empty pages and the tree item does not point to 
    // a property page, call ActivateNextPage again. This is fine since
    // we know there is at least one valid property page in the sheet.
    if( IsTreeItemDisplayable( hPrevItem ) )
			m_pwndPageTree->SelectItem( hPrevItem );
    else
      ActivatePreviousPage( hPrevItem );
}
Esempio n. 3
0
LRESULT CTreePropSheet::OnIsDialogMessage(WPARAM wParam, LPARAM lParam)
{
    MSG	*pMsg = reinterpret_cast<MSG*>(lParam);
    if (pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_TAB && GetKeyState(VK_CONTROL)&0x8000)
    {
        if (GetKeyState(VK_SHIFT)&0x8000)
            ActivatePreviousPage();
        else
            ActivateNextPage();
        return TRUE;
    }

    if (pMsg->message == WM_KEYDOWN && GetKeyState(VK_CONTROL) & 0x8000 && ((pMsg->wParam == VK_PRIOR) || pMsg->wParam == VK_NEXT))
    {
        if (pMsg->wParam == VK_PRIOR)
            ActivatePreviousPage();
        else
            ActivateNextPage();
        return TRUE;
    }

    return CPropertySheet::DefWindowProc(PSM_ISDIALOGMESSAGE, wParam, lParam);
}
LRESULT CTreePropSheetBase::OnIsDialogMessage(WPARAM wParam, LPARAM lParam)
{
  MSG *pMsg = reinterpret_cast<MSG*>(lParam);
  ASSERT( pMsg );

  if (pMsg->message==WM_KEYDOWN && GetKeyState(VK_CONTROL)&0x8000)
  {
    if( pMsg->wParam==VK_TAB )
    {
      if (GetKeyState(VK_SHIFT)&0x8000)
      {
        ActivatePreviousPage(); 
      }
      else    
      {
        ActivateNextPage(); 
      }
    }
    else
    {
      if( pMsg->wParam==VK_PRIOR )      /*PageUp*/
      {
        ActivatePreviousPage();
      }
      else
      {
        if( pMsg->wParam==VK_NEXT )     /*PageDown*/
        {
          ActivateNextPage();
        }
      }
    }
    return TRUE; 
  }

	return CPropertySheet::DefWindowProc(PSM_ISDIALOGMESSAGE, wParam, lParam);
}
void CTreePropSheetBase::ActivatePreviousPage()
{
	if( !IsWindow(m_hWnd) || 0 == GetPageCount() )
		return;

	if (!IsWindow(m_pwndPageTree->GetSafeHwnd()))
	{
		// normal tab property sheet. Simply use page index
		int	nPageIndex = GetActiveIndex();
		if (nPageIndex<0 || nPageIndex>=GetPageCount())
			return;

		int	nPrevIndex = (nPageIndex==0)? GetPageCount()-1 : nPageIndex-1;
		SetActivePage(nPrevIndex);
	}
	else
	{
		HTREEITEM	hItem = m_pwndPageTree->GetSelectedItem();
    ActivatePreviousPage( hItem );
	}
}
BOOL CTreePropSheetBase::PreTranslateMessage(MSG* pMsg) 
{
  if( pMsg->hwnd == GetPageTreeControl()->GetSafeHwnd() )
  {
    // If not in skipping empty page mode, keep the standard behavior.
    if( !m_bSkipEmptyPages )
      return CPropertySheet::PreTranslateMessage(pMsg);

    if( pMsg->message == WM_KEYDOWN )
    {
      // Get the current tree item.
      HTREEITEM hCurrentItem = m_pwndPageTree->GetSelectedItem();
      if( NULL == hCurrentItem )
        return TRUE;

      if( pMsg->wParam == VK_UP )
      {
        // Active the previous page according to tree ordering - 
        // skipping empty pages on the way.
        ActivatePreviousPage( hCurrentItem );
   	    return TRUE;
      }
      else if ( pMsg->wParam == VK_DOWN )
      {
        // Active the next page according to tree ordering -
        // skipping empty pages on the way.
        ActivateNextPage( hCurrentItem );
  	    return TRUE;
      }
      else if( pMsg->wParam == VK_LEFT )
      {
        /* Here, we try to mimic the tree keyboard handling by doing 
           one of the two things:the following
           - If the tree item is expanded, collapse it
           - If the tree item is collapse, find a parent item that has a page
             associated with it and select it, collapsing all items along the 
             way. */
        if( IsItemExpanded( hCurrentItem ) )
        {
          // Collapse the item since it is expanded.
          m_pwndPageTree->Expand( hCurrentItem, TVE_COLLAPSE );
        }
        else
        {
          // Already collapsed, search for a candidate for selection.
          HTREEITEM hItem = m_pwndPageTree->GetParentItem( hCurrentItem );
          while( NULL != hItem && !HasValidPropertyPageAssociated( hItem ) )
          {
            // Add item to the stack.
            hItem = m_pwndPageTree->GetParentItem( hItem );
          }
          // If the item points to a valid page, select it and collapse 
          if( NULL != hItem && HasValidPropertyPageAssociated( hItem ) )
          {
            m_pwndPageTree->SelectItem( hItem );
          }
        }
        return TRUE;
      }
      else if( pMsg->wParam == VK_RIGHT )
      {
        /* Here, we try to mimic the tree keyboard handling by doing 
           one of the two things:the following
           - If the tree item is collapsed, expand it
           - If the tree item is expanded, find a child item that has a page
             associated with it and select it, expanding all items along the 
             way. The child has to be a first child in the hierarchy. */
        if( IsItemExpanded( hCurrentItem ) )
        {
          // Already expanded, search for a candidate for selection.
          HTREEITEM hItem = m_pwndPageTree->GetChildItem( hCurrentItem );
          while( NULL != hItem && !HasValidPropertyPageAssociated( hItem ) )
          {
            // Add item to the stack.
            hItem = m_pwndPageTree->GetChildItem( hItem );
          }
          // If the item points to a valid page, select it and collapse 
          if( NULL != hItem && HasValidPropertyPageAssociated( hItem ) )
          {
            m_pwndPageTree->SelectItem( hItem );
          }
        }
        else
        {
          // Expand the item since it is collapsed.
          m_pwndPageTree->Expand( hCurrentItem, TVE_EXPAND );
        }
        return TRUE;
      }
    }
  }
  else if( WM_ENABLE == pMsg->message)
  {
    // Handle WM_ENABLE messages for property pages: Update the property page
    // information map.
    TRACE("");

  }

	return CPropertySheet::PreTranslateMessage(pMsg);
}