LRESULT CDasherWindow::OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { const int wmId = LOWORD(wParam); const int wmEvent = HIWORD(wParam); // Tell edit box if it has changed. It should know itself really, but this is easier // This shouldn't be here - it should be in the edit box class if( m_pEdit && ((HWND) lParam == m_pEdit->GetHwnd()) && (HIWORD(wParam) == EN_CHANGE)) { m_pEdit->SetDirty(); return 0; } // Parse the menu selections: // TODO: Put these into separate functions switch (wmId) { case IDM_ABOUT: { CAboutBox Aboutbox; Aboutbox.DoModal(m_hWnd); return 0; } #ifndef _WIN32_WCE case ID_OPTIONS_PREFS: { CPrefs Prefs(m_hWnd, m_pDasher, m_pAppSettings); return 0; } #endif #ifndef _WIN32_WCE case ID_HELP_CONTENTS: HtmlHelp(m_hWnd, L"Dasher.chm", HH_DISPLAY_INDEX, NULL); return 0; #endif case ID_HELP_DASHERTUTORIAL: m_pGameModeHelper = new CGameModeHelper(m_pDasher); return 0; case ID_GAMEMODE: m_pDasher->GameMessageIn(m_pGameGroup->IsWindowVisible()? (GameMode::GAME_MESSAGE_GAME_OFF) : (GameMode::GAME_MESSAGE_GAME_ON), NULL); m_pGameGroup->ShowWindow(m_pGameGroup->IsWindowVisible()?SW_HIDE:SW_SHOW); m_pEdit->Clear(); Layout(); return 0; case IDM_EXIT: DestroyWindow(); return 0; case ID_EDIT_SELECTALL: if(m_pEdit) m_pEdit->SelectAll(); return 0; case ID_EDIT_CUT: if(m_pEdit) m_pEdit->Cut(); return 0; case ID_EDIT_COPY: if(m_pEdit) m_pEdit->Copy(); return 0; case ID_EDIT_COPY_ALL: if(m_pEdit) m_pEdit->CopyAll(); return 0; case ID_EDIT_PASTE: if(m_pEdit) m_pEdit->Paste(); return 0; case ID_FILE_NEW: if(m_pEdit) m_pEdit->New(); // Selecting file->new indicates a new trial to our user logging object if (m_pDasher != NULL) { CUserLogBase* pUserLog = m_pDasher->GetUserLogPtr(); if (pUserLog != NULL) pUserLog->NewTrial(); m_pDasher->SetBuffer(0); } return 0; case ID_FILE_OPEN: if(m_pEdit) m_pEdit->Open(); return 0; case ID_FILE_SAVE: if(m_pEdit) if(!m_pEdit->Save()) m_pEdit->SaveAs(); return 0; case ID_FILE_SAVE_AS: if(m_pEdit) m_pEdit->SaveAs(); return 0; case ID_IMPORT_TRAINFILE: m_pDasher->ImportTrainingText(m_pEdit->Import()); return 0; default: return DefWindowProc(message, wParam, lParam); } Layout(); return 0; }
LRESULT CDasherWindow::OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (!m_bFullyCreated) { bHandled = FALSE; return 0; } const int wmId = LOWORD(wParam); //command id const int wmEvent = HIWORD(wParam); //notification code: 1=from accelerator, 0=from menu //lParam is the HWND (window handle) of control sending message, 0 if not from control // Tell edit box if it has changed. It should know itself really, but this is easier // This shouldn't be here - it should be in the edit box class if (((HWND)lParam == *m_pEdit) && (HIWORD(wParam) == EN_CHANGE)) { m_pEdit->SetDirty(); return 0; } // Parse the menu selections: // TODO: Put these into separate functions switch (wmId) { case IDM_ABOUT: { CAboutBox Aboutbox; Aboutbox.DoModal(m_hWnd); return 0; } case ID_OPTIONS_PREFS: { CPrefs Prefs(m_hWnd, m_pDasher, m_pAppSettings); return 0; } case ID_HELP_CONTENTS: HtmlHelp(m_hWnd, L"Dasher.chm", HH_DISPLAY_INDEX, NULL); return 0; // XXXPW #if 0 case ID_GAMEMODE: { unsigned int checkState(GetMenuState(m_hMenu, ID_GAMEMODE, MF_BYCOMMAND)); DASHER_ASSERT(checkState == -1); //"specified item does not exist" - presumably, params to above aren't right... m_pDasher->SetBoolParameter(BP_GAME_MODE, (checkState & MF_CHECKED) ? false : true); return 0; } #endif case IDM_EXIT: DestroyWindow(); return 0; case ID_EDIT_SELECTALL: m_pEdit->SelectAll(); return 0; case ID_EDIT_CUT: m_pEdit->Cut(); return 0; case ID_EDIT_COPY: m_pEdit->Copy(); return 0; case ID_EDIT_COPY_ALL: m_pDasher->CopyToClipboard(m_pDasher->GetAllContext()); return 0; case ID_EDIT_PASTE: m_pEdit->Paste(); return 0; case ID_FILE_NEW:{ m_pEdit->New(); // Selecting file->new indicates a new trial to our user logging object CUserLogBase* pUserLog = m_pDasher->GetUserLogPtr(); if (pUserLog != NULL) pUserLog->NewTrial(); m_pDasher->SetBuffer(0); return 0; } case ID_FILE_OPEN: m_pEdit->Open(); return 0; case ID_FILE_SAVE: if (!m_pEdit->Save()) m_pEdit->SaveAs(); return 0; case ID_FILE_SAVE_AS: m_pEdit->SaveAs(); return 0; case ID_IMPORT_TRAINFILE: m_pDasher->ImportTrainingText(m_pEdit->Import()); return 0; default: bHandled = FALSE; return 0; } }