/****************************************************************************** * void MenuOnCommand(HMENU hmenu, HWND hwnd) * * frame window WM_COMMAND handler * * parameters: * wCmd - menu item id (WM_COMMAND wParam) * * returns: * TRUE if the menu item id is recognized * * notes: * The following code needs to change if there are more than 10 mru files * more than 100 default options, more than 100 tools or more than 100 transforms ******************************************************************************/ BOOL MenuOnCommand(WPARAM wCmd) { HWND hwnd = ChildGetActive(); CHILDINSTANCEDATA PICFAR* pInstance = ChildGetInstanceData(hwnd); if ( pInstance == 0 || pInstance->nWaitCursor != 0 ) hwnd = NULL; switch ( wCmd ) { case IDM_FILE_OPEN: OpenOnFileOpen(); break; case IDM_FILE_CLOSE: OnFileClose(hwnd); break; case IDM_FILE_SAVE: SaveOnFileSave(hwnd); break; case IDM_FILE_SAVEAS: SaveOnFileSaveAs(hwnd); break; case IDM_FILE_PROPERTIES: OnFileProperties(hwnd); break; case IDM_FILE_IMAGEOPTIONS: OnFileImageOptions(hwnd); break; case IDM_FILE_EXIT: SendMessage(hwndFrame, WM_CLOSE, 0, 0); break; case IDM_FILE_MRUFILE1: case IDM_FILE_MRUFILE2: case IDM_FILE_MRUFILE3: case IDM_FILE_MRUFILE4: case IDM_FILE_MRUFILE5: case IDM_FILE_MRUFILE6: case IDM_FILE_MRUFILE7: case IDM_FILE_MRUFILE8: case IDM_FILE_MRUFILE9: OpenOnFileMruOpen(wCmd - IDM_FILE_MRUFILE1 + 1); break; case IDM_WINDOW_NEWWINDOW: OnNewWindow(hwnd); break; case IDM_WINDOW_CASCADE: SendMessage(hwndMDIClient, WM_MDICASCADE, 0, 0); break; case IDM_WINDOW_TILEHORIZONTAL: SendMessage(hwndMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0); break; case IDM_WINDOW_TILEVERTICAL: SendMessage(hwndMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0); break; case IDM_WINDOW_ARRANGEICONS: SendMessage(hwndMDIClient, WM_MDIICONARRANGE, 0, 0); break; case IDM_WINDOW_CLOSEALL: OnWindowCloseAll(); break; case IDM_HELP_CONTENTS: WinHelp(hwndFrame, APPLICATION_HELPFILENAME, HELP_CONTENTS, 0); break; case IDM_HELP_ABOUT: AboutOnHelpAbout(); break; default: if ( wCmd >= IDM_FILE_DEFAULTOPTIONS && wCmd < IDM_FILE_DEFAULTOPTIONS + 100 ) OnFileDefaultOptions(wCmd); else if ( wCmd >= IDM_TRANSFORM && wCmd < IDM_TRANSFORM + 100 ) OnTransform(hwnd, wCmd); else if ( wCmd >= IDM_TOOLS && wCmd < IDM_TOOLS + 100 ) OnTools(wCmd); else return ( FALSE ); } return ( TRUE ); }
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); }