Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SSW_8_11.doc
Скачиваний:
2
Добавлен:
01.05.2025
Размер:
5 Мб
Скачать
☆

8.5 The standard id’s, used in Document / View concept

For each command ID, there is a standard message line prompt string that can be found in the file PROMPTS.RC. The string ID for that menu prompt must be the same as for the command ID.

  1. ID_FILE_NEW:   Creates a new/empty document.

CWinApp::OnFileNew implements this command differently depending on the number of document templates in the application.

  1. ID_FILE_OPEN:   Opens an existing document.

CWinApp::OnFileOpen has a very simple implementation of calling CWinApp::DoPromptFileName followed by CWinApp::OpenDocumentFile with the file or path name of the file to open.

  1. ID_FILE_CLOSE:   Closes the currently open document.

CDocument::OnFileClose calls CDocument::SaveModified to prompt the user to save the document if it has been modified and then calls OnCloseDocument.

  1. ID_FILE_SAVE:   Saves the current document.

The implementation uses a helper routine CDocument::DoSave which is used for both OnFileSave and OnFileSaveAs.

  1. ID_FILE_SAVE_AS:   Saves the current document under a different file name.

The CDocument::OnFileSaveAs implementation uses the same CDocument::DoSave helper routine as OnFileSave.

  1. ID_FILE_SAVE_COPY_AS:   Saves a copy current document under a new name.

The COleServerDoc::OnFileSaveCopyAs implementation is very similar to CDocument::OnFileSaveAs, except that the document object is not "attached" to the underlying file after the save. ID_FILE_UPDATE:   Notifies the container to save an embedded document.

  1. ID_FILE_PAGE_SETUP:   Invokes an application-specific page setup/layout dialog.

Currently there is no standard for this dialog, and the framework has no default implementation of this command.

If you choose to implement this command, we recommend you use this command ID.

  1. ID_FILE_PRINT_SETUP:   Invoke the standard Print Setup dialog.

CWinApp::OnFilePrintSetup has a very simple implementation creating a CPrintDialog object and calling the CWinApp::DoPrintDialog implementation function. This sets the application default printer setup.

  1. ID_FILE_PRINT:   Standard printing of the current document

This command prints the current document, or more correctly, starts the printing process, which involves invoking the standard print dialog and running the print engine.

CView::OnFilePrint implements this command and the main print loop.

  1. ID_FILE_PRINT_PREVIEW:   Enter print-preview mode for the current document.

CView::OnFilePrintPreview starts the print preview mode by calling the documented helper function CView::DoPrintPreview.

  1. ID_EDIT_CLEAR:   Clears the current selection

CEditView provides an implementation of this command using CEdit::Clear. The command is disabled if there is no current selection.

  1. ID_EDIT_CLEAR_ALL:   Clears the entire document.

Currently there is no standard implementation for this command. You must implement this for each CView-derived class.

  1. ID_EDIT_COPY:   Copies the current selection to the Clipboard.

CEditView provides an implementation of this command, which copies the currently selected text to the Clipboard as CF_TEXT using CEdit::Copy. The command is disabled if there is no current selection.

If you choose to implement this command, we recommend you use this command ID.

  1. ID_EDIT_CUT:   Cuts the current selection to the Clipboard.

CEditView provides an implementation of this command, which cuts the currently selected text to the Clipboard as CF_TEXT using CEdit::Cut. The command is disabled if there is no current selection.

  1. ID_EDIT_FIND:   Begin the find operation, bring up the modeless find dialog.

CEditView provides an implementation of this command, which calls the implementation helper function OnEditFindReplace to use and store the previous find/replace settings in private implementation variables. The CFindReplaceDialog class is used to manage the modeless dialog for prompting the user.

  1. ID_EDIT_PASTE:   Insert the current Clipboard contents.

CEditView provides an implementation of this command, which copies the current Clipboard data replacing the selected text using CEdit::Paste. The command is disabled if there is no CF_TEXT in the Clipboard.

  1. ID_EDIT_REPEAT:   Repeat the last operation.

CEditView provides an implementation of this command to repeat the last find operation.

  1. ID_EDIT_REPLACE:   Begin the replace operation, bring up the modeless replace dialog.

CEditView provides an implementation of this command, which calls the implementation helper function OnEditFindReplace to use and store the previous find/replace settings in private implementation variables.

  1. ID_EDIT_SELECT_ALL:   Select the entire document.

CEditView provides an implementation of this command, which selects all the text in the document. The command is disabled if there is no text to select.

  1. ID_EDIT_UNDO:   Undo the last operation.

CEditView provides an implementation of this command, using CEdit::Undo. The command is disabled if CEdit::CanUndo returns FALSE.

  1. ID_EDIT_REDO:   Redo the last operation.

Currently there is no standard implementation for this command. You must implement this for each CView-derived class.

  1. ID_WINDOW_NEW:   Open another window on the active document.

CMDIFrameWnd::OnWindowNew implements this powerful feature by using the document template of the current document to create another frame containing another view of the current document.

Like most multiple document interface (MDI) Window menu commands, the command is disabled if there is no active MDI child window.

  1. ID_WINDOW_ARRANGE:   Arrange icons at the bottom of an MDI window.

CMDIFrameWnd implements this standard MDI command in an implementation helper function OnMDIWindowCmd. This helper maps command IDs to MDI Windows messages and can therefore share a lot of code.

  1. ID_APP_ABOUT:   Invoke the About dialog box.

There is no standard implementation for an application's About box. The default AppWizard-created application will create a custom dialog class for your application and use it as your About box. AppWizard will also write the trivial command handler which handles this command and invokes the dialog.

You will almost always implement this command.

  1. ID_APP_EXIT:   Exit the application.

CWinApp::OnAppExit handles this command by sending a WM_CLOSE message to the application's main window. The standard shutting down of the application (prompting for dirty files and so on) is handled by the CFrameWnd implementation.

  1. ID_HELP_INDEX:   List Help topics from .HLP file.

CWinApp::OnHelpIndex handles this command by trivially calling CWinApp::WinHelp.

  1. ID_HELP_USING:   Display help on how to use Help.

CWinApp::OnHelpUsing handles this command by trivially calling CWinApp::WinHelp.

  1. ID_HELP:   Give help on the current context

CWinApp::OnHelp handles this command by getting the right help context for the current application context. This handles simple F1 help, help on message boxes and so on.

  1. ID_DEFAULT_HELP:   Display default help for context

This command is usually mapped to CWinApp::OnHelpIndex.

  1. ID_VIEW_TOOLBAR:   Toggle the toolbar on and off

CFrameWnd handles this command and the update-command UI handler to toggle the visible state of the toolbar.

  1. ID_VIEW_STATUS_BAR:   Toggle the status bar on and off

This command is implemented in CFrameWnd just like ID_VIEW_TOOLBAR, except a different child window ID (AFX_IDW_STATUS_BAR) is used.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]