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); }
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::ActivateNextPage(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 hNextItem = m_pwndPageTree->GetChildItem(hItem); if ( hNextItem ) { // Have a child, skip rest of search. } else if (hNextItem=m_pwndPageTree->GetNextSiblingItem(hItem)) { // Had not child but has a sibling, skip rest of search. } else if (m_pwndPageTree->GetParentItem(hItem)) { // No child, no sibling, get the next sibling from the parent. while (!hNextItem) { hItem = m_pwndPageTree->GetParentItem(hItem); if (!hItem) break; hNextItem = m_pwndPageTree->GetNextSiblingItem(hItem); } } if (!hNextItem) // no next item -- so cycle to the first item hNextItem = m_pwndPageTree->GetRootItem(); if (!hNextItem) 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( hNextItem ) ) m_pwndPageTree->SelectItem( hNextItem ); else ActivateNextPage( hNextItem ); }
bool CTreePropSheetBase::EnablePage(const CPropertyPage* const pPage,const bool bEnable) { /* - Based on flag value: - If disabling, if the current page is the page that is being disabled, activate the next page. If the new page is the initial page, the call fails as there is no available new page. If the current is not the page being disabled, just disable it. Act accordingly and set flag, return previous status. - If enabling, just switch the flag. - Refresh tree. */ CPageInformation& pageInformation = m_mapPageInformation[pPage]; bool bPreviousStatus = pageInformation.IsEnabled(); if( bEnable ) { pageInformation.SetIsEnabled( true ); } else { // Active next page if disabling the current page. if( GetActivePage() == pPage ) { ActivateNextPage(); // This is the only active page left, it cannot be disabled. if( GetActivePage() == pPage ) { return bPreviousStatus; } } // We are now sure that the active page is not the page being disabled, // we can proceed. pageInformation.SetIsEnabled( false ); } // Enable/disable the page if it exists. if( pPage->GetSafeHwnd() ) { ::EnableWindow( pPage->GetSafeHwnd(), bEnable?TRUE:FALSE ); } // Refresh the tree control. RefreshPageTree(); return bPreviousStatus; }
void CTreePropSheetBase::ActivateNextPage() { // Window must be defined and a least one property page. 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 nNextIndex = (nPageIndex==GetPageCount()-1)? 0 : nPageIndex+1; SetActivePage(nNextIndex); } else { HTREEITEM hItem = m_pwndPageTree->GetSelectedItem(); ActivateNextPage( 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); }