LRESULT CPpcMainWnd::OnCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDM_TOOL_TOGGLEDISPLAY: ToggleDisplay(); OnTimer(ID_TIMER_DISPSTATE); return 0; case IDM_FILE_UP: OnFileUp(); return 0; case IDM_FILE_DOWN: OnFileDown(); return 0; case IDM_FILE_DELETE: OnFileDelete(); return 0; case IDM_FILE_DELETEALL: OnFileDeleteAll(); return 0; case IDM_PLAY_SELECTED: OnPlaySelected(); return 0; case IDM_FILE_SORT_BYNAME: case IDM_FILE_SORT_BYPATH: OnFileSort(LOWORD(wParam)); return 0; case IDOK: PostMessage(m_hWnd, WM_CLOSE, 0, 0); return 0; case IDM_TOOL_HOLD: OnToolHold(); return 0; case IDM_TOOL_HOLDDISP: OnToolHoldDisp(); return 0; case IDM_PLAY_PLAYSTOP: OnPlayPlayStop(); return 0; case IDM_TOOL_KEYCTRL: OnToolKeyCtrl(); return 0; } return CMainWnd::OnCommand(wParam, lParam); }
BOOL CTreeFileCtrl::PreTranslateMessage(MSG* pMsg) { // When an item is being edited make sure the edit control // receives certain important key strokes if (GetEditControl()) { ::TranslateMessage(pMsg); ::DispatchMessage(pMsg); return TRUE; // DO NOT process further } //Context menu via the keyboard if ((((pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) && // If we hit a key and (pMsg->wParam == VK_F10) && (GetKeyState(VK_SHIFT) & ~1)) != 0) || // it's Shift+F10 OR (pMsg->message == WM_CONTEXTMENU)) // Natural keyboard key { CRect rect; GetItemRect(GetSelectedItem(), rect, TRUE); ClientToScreen(rect); OnContextMenu(NULL, rect.CenterPoint()); return TRUE; } //Hitting the Escape key, Cancelling drag & drop else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE && IsDragging()) { EndDragging(TRUE); return TRUE; } //Hitting the Alt-Enter key combination, show the properties sheet else if (pMsg->message == WM_SYSKEYDOWN && pMsg->wParam == VK_RETURN) { OnFileProperties(); return TRUE; } //Hitting the Enter key, open the item else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) { OnFileOpen(); return TRUE; } //Hitting the delete key, delete the item else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DELETE) { OnFileDelete(); return TRUE; } //hitting the backspace key, go to the parent folder else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_BACK) { UpOneLevel(); return TRUE; } //hitting the F2 key, being in-place editing of an item else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F2) { OnFileRename(); return TRUE; } //hitting the F5 key, force a refresh of the whole tree else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F5) { OnViewRefresh(); return TRUE; } //Let the parent class do its thing return CTreeCtrl::PreTranslateMessage(pMsg); }