现在的位置: 首页 > 综合 > 正文

CFrameWnd – MSDN6翻译交流

2013年01月22日 ⁄ 综合 ⁄ 共 4895字 ⁄ 字号 评论关闭

BUG和建议请提出,谢谢!

CFrameWnd

The CFrameWnd class provides the functionality of a Windows single document interface (SDI) overlapped or pop-up frame window, along with members for managing the window.

CFrameWnd 类提供视窗单文档界面(SDI)(……)能力,(……),和管理窗口的成员一起。

To create a useful frame window for your application, derive a class from CFrameWnd. Add member variables to the derived class to store data specific to your application. Implement message-handler member functions and a message map in the derived class to specify what happens when messages are directed to the window.

要给你的应用创建一个适用的框架窗口,(请)从CFrameWnd派生一个类。向此派生类添加成员变量用以存放你的应用特有的数据。在派生类中实现消息处理(者)成员函数和消息映射,用于制定当消息(传)到此窗口上时该发生什么。

There are three ways to construct a frame window:

有三种方式来构建一个框架窗口:

  • Directly construct it using Create.
  • 使用Create直接构建。
  • Directly construct it using LoadFrame.
  • 使用LoadFrame直接构建。
  • Indirectly construct it using a document template.
  • 使用文档模板间接地构建。

Before you call either Create or LoadFrame, you must construct the frame-window object on the heap using the C++ new operator. Before calling Create, you can also register a window class with the AfxRegisterWndClass global function to set the icon and class styles for the frame.

在你调用CreateLoadFrame之前,你必须使用C++的new 操作符在堆(内存)上构造(这个)框架窗口物件。在调用Create 之前,你也能使用AfxRegisterWndClass全局函数注册一个窗口类来设置此框架的图标和类风格。

Use the Create member function to pass the frame’s creation parameters as immediate arguments.

使用Create 成员函数传递框架的(……)。

LoadFrame requires fewer arguments than Create, and instead retrieves most of its default values from resources, including the frame’s caption, icon, accelerator table, and menu. To be accessible by LoadFrame, all these resources must have the same resource ID (for example, IDR_MAINFRAME).

LoadFrame需要的参数比Create少,(……)。

When a CFrameWnd object contains views and documents, they are created indirectly by the framework instead of directly by the programmer. The CDocTemplate object orchestrates the creation of the frame, the creation of the containing views, and the connection of the views to the appropriate document. The parameters of the CDocTemplate constructor specify the CRuntimeClass of the three classes involved (document, frame, and view). A CRuntimeClass object is used by the framework to dynamically create new frames when specified by the user (for example, by using the File New command or the multiple document interface (MDI) Window New command).

A frame-window class derived from CFrameWnd must be declared with DECLARE_DYNCREATE in order for the above RUNTIME_CLASS mechanism to work correctly.

A CFrameWnd contains default implementations to perform the following functions of a main window in a typical application for Windows:

  • A CFrameWnd frame window keeps track of a currently active view that is independent of the Windows active window or the current input focus. When the frame is reactivated, the active view is notified by calling CView::OnActivateView.

  • Command messages and many common frame-notification messages, including those handled by the OnSetFocus, OnHScroll, and OnVScroll functions of CWnd, are delegated by a CFrameWnd frame window to the currently active view.
  • The currently active view (or currently active MDI child frame window in the case of an MDI frame) can determine the caption of the frame window. This feature can be disabled by turning off the FWS_ADDTOTITLE style bit of the frame window.
  • A CFrameWnd frame window manages the positioning of the control bars, views, and other child windows inside the frame window’s client area. A frame window also does idle-time updating of toolbar and other control-bar buttons. A CFrameWnd frame window also has default implementations of commands for toggling on and off the toolbar and status bar.
  • A CFrameWnd frame window manages the main menu bar. When a pop-up menu is displayed, the frame window uses the UPDATE_COMMAND_UI mechanism to determine which menu items should be enabled, disabled, or checked. When the user selects a menu item, the frame window updates the status bar with the message string for that command.
  • A CFrameWnd frame window has an optional accelerator table that automatically translates keyboard accelerators.
  • A CFrameWnd frame window has an optional help ID set with LoadFrame that is used for context-sensitive help. A frame window is the main orchestrator of semimodal states such as context-sensitive help (SHIFT+F1) and print-preview modes.
  • A CFrameWnd frame window will open a file dragged from the File Manager and dropped on the frame window. If a file extension is registered and associated with the application, the frame window responds to the dynamic data exchange (DDE) open request that occurs when the user opens a data file in the File Manager or when the ShellExecute Windows function is called.
  • If the frame window is the main application window (that is, CWinThread::m_pMainWnd), when the user closes the application, the frame window prompts the user to save any modified documents (for OnClose and OnQueryEndSession).
  • If the frame window is the main application window, the frame window is the context for running WinHelp. Closing the frame window will shut down WINHELP.EXE if it was launched for help for this application.

Do not use the C++ delete operator to destroy a frame window. Use CWnd::DestroyWindow instead. The CFrameWnd implementation of PostNcDestroy will delete the C++ object when the window is destroyed. When the user closes the frame window, the default OnClose handler will call DestroyWindow.

For more information on CFrameWnd, seeFrame Window Topics in Visual C++ Programmer's Guide.

#include <afxwin.h>

Class MembersBase ClassHierarchy Chart

See Also   CWnd, CMDIFrameWnd, CMDIChildWnd, CView, CDocTemplate, CRuntimeClass

抱歉!评论已关闭.