MFC 函数收集

CWnd::GetDlgItem 
CWnd* GetDlgItem( int nID ) const;

void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;

返回值

A pointer to the given control or child window. If no control with the integer ID given by the nID parameter exists, the value is NULL.

The returned pointer may be temporary and should not be stored for later use.

参数

nID:Specifies the identifier of the control or child window to be retrieved.

phWnd:A pointer to a child window.

说明

Retrieves a pointer to the specified control or child window in a dialog box or other window. The pointer returned is usually cast to the type of control identified by nID.


*****************************************
CFrameWnd::GetActiveView
CView* GetActiveView( ) const;

返回值
A pointer to the current CView. If there is no current view, returns NULL.

说明

Call this member function to obtain a pointer to the active view (if any) attached to a frame window (CFrameWnd).
This function returns NULL when called for an MDI main frame window (CMDIFrameWnd). In an MDI application, the MDI main frame window does not have a view associated with it. Instead, each individual child window (CMDIChildWnd) has one or more associated views. The active view in an MDI application can be obtained by first finding the active MDI child window and then finding the active view for that child window. The active MDI child window can be found by calling the function MDIGetActive or GetActiveFrame as demonstrated in the following:

CMDIFrameWnd *pFrame =
             (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;

// Get the active MDI child window.
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
// or CMDIChildWnd *pChild = pFrame->MDIGetActive();
// Get the active view attached to the active MDI child
// window.
CMyView *pView = (CMyView *) pChild->GetActiveView();

******************************************************

CCreateContext
CCreateContext does not have a base class.

The framework uses the CCreateContext structure when it creates the frame windows and views associated with a document. When creating a window, the values in this structure provide information used to connect the components that make up a document and the view of its data. You will only need to use CCreateContext if you are overriding parts of the creation process.

A CCreateContext structure contains pointers to the document, the frame window, the view, and the document template. It also contains a pointer to a CRuntimeClass that identifies the type of view to create. The run-time class information and the current document pointer are used to create a new view dynamically. The following table suggests how and when each CCreateContext member might be used:

Member What it is for
m_pNewViewClass: CRuntimeClass of the new view to create.
m_pCurrentDoc: The existing document to be associated with the new view.
m_pNewDocTemplate: The document template associated with the creation of a new MDI frame window.
m_pLastView: The original view upon which additional views are modeled, as in the creation of a splitter window’s views or the creation of a second view on a document.
m_pCurrentFrame: The frame window upon which additional frame windows are modeled, as in the creation of a second frame window on a document.


When a document template creates a document and its associated components, it validates the information stored in the CCreateContext structure. For example, a view should not be created for a nonexistent document.

Note   All of the pointers in CCreateContext are optional and can be NULL if unspecified or unknown.

CCreateContext is used by the member functions listed under “See Also.” Consult the descriptions of these functions for specific information if you plan to override them.

Here are a few general guidelines:

When passed as an argument for window creation, as in CWnd::Create, CFrameWnd::Create, and CFrameWnd::LoadFrame, the create context specifies what the new window should be connected to. For most windows, the entire structure is optional and a NULL pointer can be passed.


For overridable member functions, such as CFrameWnd::OnCreateClient, the CCreateContext argument is optional.


For member functions involved in view creation, you must provide enough information to create the view. For example, for the first view in a splitter window, you must supply the view class information and the current document.
In general, if you use the framework defaults, you can ignore CCreateContext. If you attempt more advanced modifications, the Microsoft Foundation Class Library source code or the sample programs, such as VIEWEX, will guide you. If you do forget a required parameter, a framework assertion will tell you what you forgot.

For more information on CCreateContext, see the MFC sampleVIEWEX.

#include <afxext.h>

**************************************************************************

CView::GetDocument
CDocument* GetDocument( ) const;

Return Value

A pointer to the CDocument object associated with the view. NULL if the view is not attached to a document.

Remarks

Call this function to get a pointer to the view’s document. This allows you to call the document’s member functions.

**************************************************************************
CWnd::ShowWindow
BOOL ShowWindow( int nCmdShow );

Return Value

Nonzero if the window was previously visible; 0 if the CWnd was previously hidden.

Parameters

nCmdShow

Specifies how the CWnd is to be shown. It must be one of the following values:

SW_HIDE   Hides this window and passes activation to another window.


SW_MINIMIZE   Minimizes the window and activates the top-level window in the system’s list.


SW_RESTORE   Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position.


SW_SHOW   Activates the window and displays it in its current size and position.


SW_SHOWMAXIMIZED   Activates the window and displays it as a maximized window.


SW_SHOWMINIMIZED   Activates the window and displays it as an icon.


SW_SHOWMINNOACTIVE   Displays the window as an icon. The window that is currently active remains active.


SW_SHOWNA   Displays the window in its current state. The window that is currently active remains active.


SW_SHOWNOACTIVATE   Displays the window in its most recent size and position. The window that is currently active remains active.


SW_SHOWNORMAL   Activates and displays the window. If the window  is minimized or maximized, Windows restores it to its original size and position.
Remarks

Sets the visibility state of the window.

ShowWindow must be called only once per application for the main window with CWinApp::m_nCmdShow. Subsequent calls to ShowWindow must use one of the values listed above instead of the one specified by CWinApp::m_nCmdShow.

**********************************************************

CWnd::SetDlgCtrlID
int SetDlgCtrlID( int nID );

Return Value

The previous identifier of the window, if successful; otherwise 0.

Parameters

nID

The new value to set for the control’s identifier.

Remarks

Sets the window ID or control ID for the window to a new value. The window can be any child window, not only a control in a dialog box. The window cannot be a top-level window.

posted @ 2005-05-23 00:12  流水不腐-户枢不蠹  阅读(417)  评论(0)    收藏  举报