Esempio n. 1
0
/*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  Method:   CMainWindow::DoMenu

  Summary:  Dispatch and handle the main menu commands.

  Args:     WPARAM wParam,
              First message parameter (word sized).
            LPARAM lParam)
              Second message parameter (long sized).

  Modifies: m_ofnFile, ...

  Returns:  LRESULT
              Standard Windows WindowProc return value.
M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
LRESULT CMainWindow::DoMenu(
    WPARAM wParam,
    LPARAM lParam)
{
    LRESULT lResult = FALSE;

    switch (LOWORD(wParam))
    {
    //----------------------------------------------------------------------
    // Handle File Menu Commands.
    //----------------------------------------------------------------------
    case IDM_FILE_EXIT:
        // The user commands us to exit this application so we tell the
        // Main window to close itself.
        ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
        break;

    //----------------------------------------------------------------------
    // Handle Help Menu Commands.
    //----------------------------------------------------------------------
    case IDM_HELP_CONTENTS:
        // We have some stubbed support here for bringing up the online
        //   Help for this application.
        if (::FileExist(m_szHelpFile))
            ::WinHelp(m_hWnd, m_szHelpFile, HELP_CONTEXT, IDH_CONTENTS);
        else
            m_pMsgBox->ErrorID(IDS_NOHELPFILE);
        break;
    case IDM_HELP_README:
        // Call the APPUTIL utility function ReadMe to read the FRECLIEN.TXT
        // "readme" file associated with this tutorial code sample.
        ReadMeFile(m_hWnd, TEXT(READMEDLL_CLIENT_FILE_STR));
        break;
    case IDM_HELP_READMEDLL:
        // Call the APPUTIL utility function ReadMe to read the FRESERVE.TXT
        // "readme" file associated with the companion FRESERVE DLL.
        ReadMeFile(m_hWnd, TEXT(READMEDLL_SERVER_FILE_STR));
        break;
    case IDM_HELP_READSOURCE:
        // Call the APPUTIL utility function ReadSource to allow the
        // user to open and read any of the source files of FRECLIEN.
        ReadSource(m_hWnd, &m_ofnFile);
        break;
    case IDM_HELP_ABOUT:
    {
        CAboutBox dlgAboutBox;

        // Show the standard About Box dialog for this EXE by telling the
        // dialog C++ object to show itself by invoking its ShowDialog
        // method.  Pass it this EXE instance and the parent window handle.
        // Use a dialog resource ID for the dialog template stored in
        // this EXE module's resources.
        dlgAboutBox.ShowDialog(
            m_hInst,
            MAKEINTRESOURCE(IDM_HELP_ABOUT),
            m_hWnd);
    }
    break;

    default:
        // Defer all messages NOT handled here to the Default Window Proc.
        lResult = ::DefWindowProc(m_hWnd, WM_COMMAND, wParam, lParam);
        break;
    }

    return(lResult);
}