// // Mouse click handler for target tree. // void CPageDisk::OnClickTTargets(NMHDR * pNMHDR, LRESULT * pResult) { CPoint point; TV_HITTESTINFO test_info; TargetSelType state; // Get the cursor position. GetCursorPos(&point); test_info.pt = point; m_TTargets.ScreenToClient(&(test_info.pt)); // Check to see whether the cursor is on an item. m_TTargets.HitTest(&test_info); // Check that we have an disk item. if (!test_info.hItem) return; // A new target assignment is being made. Clear the results since they are // for a configuration we no longer have. theApp.pView->ResetDisplayforNewTest(); // Toggle the selection if the control key is pressed. if (GetKeyState(VK_CONTROL) & 0x8000 && GetSelectionCheck(test_info.hItem) == TargetChecked) { state = TargetUnChecked; } else { state = TargetChecked; } switch (theApp.pView->m_pWorkerView->GetSelectedType()) { case WORKER: case MANAGER: // A shift click extends the selection from the last selected item // to the currently focused item. When the control key is also // pressed, any previous selection is not cleared. if ((GetKeyState(VK_SHIFT) & 0x8000) && selected) { // We have a previous item (not the first click) and the shift // key is down. SelectRange(selected, test_info.hItem, !(GetKeyState(VK_CONTROL) & 0x8000)); } else if (GetKeyState(VK_CONTROL) & 0x8000) { // The control key is down. SelectRange(test_info.hItem, test_info.hItem, FALSE, state); } else { SelectRange(test_info.hItem, test_info.hItem, TRUE, state); } break; default: ErrorMessage("Unexpected selection type in CPageNetwork::" "OnClickTTargets()."); return; } // immediately refresh the display (create/delete NetClients as needed) StoreTargetSelection(); *pResult = 0; }
// // Multi selection keyboard handler for the tree control. // void CPageDisk::KeyMultiSel( WORD wVKey ) { BOOL shift = GetKeyState( VK_SHIFT ) & 0x8000; BOOL control = GetKeyState( VK_CONTROL ) & 0x8000; // Make sure there are disks. if ( !highlighted ) return; switch ( wVKey ) { case VK_UP: if ( !selected && shift ) selected = highlighted; SetFocusUp(); // Only select items if the shift key is pressed. if ( shift ) { SelectRange( selected, highlighted, !control, TargetChecked ); StoreTargetSelection(); } break; case VK_DOWN: if ( !selected && shift ) selected = highlighted; SetFocusDown(); // Only select items if the shift key is pressed. if ( shift ) { SelectRange( selected, highlighted, !control, TargetChecked ); StoreTargetSelection(); } break; case VK_HOME: if ( !selected && shift ) selected = highlighted; SetFocusHome(); // Only select items if the shift key is pressed. if ( shift ) { SelectRange( selected, highlighted, !control, TargetChecked ); StoreTargetSelection(); } break; case VK_END: if ( !selected && shift ) selected = highlighted; SetFocusEnd(); // Only select items if the shift key is pressed. if ( shift ) { SelectRange( selected, highlighted, !control, TargetChecked ); StoreTargetSelection(); } break; case VK_SPACE: if ( shift ) { // Extend the selection. Clear any other items if the control // key is not pressed. SelectRange( selected, highlighted, !control, TargetChecked ); } else if ( control ) // toggle. { // Toggle the selection, but do not clear any other items. if ( GetSelectionCheck( highlighted ) == TargetChecked ) { SelectRange( highlighted, highlighted, FALSE, TargetUnChecked ); } else { SelectRange( highlighted, highlighted, FALSE, TargetChecked ); } } else // normal { // Select only the highlighted item and clear any other. SelectRange( highlighted, highlighted, TRUE, TargetChecked ); } ShowFocus(); StoreTargetSelection(); break; case 'A': if ( control ) { SetAllCheck( TargetChecked ); StoreTargetSelection(); } } }
// // Single selection keyboard handler for the tree control. // void CPageNetwork::KeySingleSel(WORD wVKey) { BOOL shift = GetKeyState(VK_SHIFT) & 0x8000; BOOL control = GetKeyState(VK_CONTROL) & 0x8000; // Make sure there are interfaces. if (!highlighted) return; switch (wVKey) { case VK_UP: SetFocusUp(); // Only select items if the shift key is pressed. if (shift) { SelectRange(highlighted, highlighted, TRUE, TargetChecked); StoreTargetSelection(); } break; case VK_DOWN: SetFocusDown(); // Only select items if the shift key is pressed. if (shift) { SelectRange(highlighted, highlighted, TRUE, TargetChecked); StoreTargetSelection(); } break; case VK_HOME: SetFocusHome(); // Only select items if the shift key is pressed. if (shift) { SelectRange(highlighted, highlighted, TRUE, TargetChecked); StoreTargetSelection(); } break; case VK_END: SetFocusEnd(); // Only select items if the shift key is pressed. if (shift) { SelectRange(highlighted, highlighted, TRUE, TargetChecked); StoreTargetSelection(); } break; case VK_SPACE: if (control) // toggle. { // Toggle the selection, but do not clear any other items. if (GetSelectionCheck(highlighted) == TargetChecked) { SelectRange(highlighted, highlighted, FALSE, TargetUnChecked); } else { SelectRange(highlighted, highlighted, FALSE, TargetChecked); } } else // normal selection. { // Extend the selection and clear any other items. SelectRange(highlighted, highlighted, TRUE, TargetChecked); } ShowFocus(); StoreTargetSelection(); break; } ShowSettings(); EnableWindow(); }