CWnd Class Members
- 格式:pdf
- 大小:177.48 KB
- 文档页数:16
CFrameWnd类CFrameWnd类往往用于创建应用程序的主窗口,因为它能很好地支持系统菜单和控制条(工具条、状态条等),为此定义了大量的成员函数和变量。
在编写文档/视图结构的应用程序时,CFrameWnd作为主窗口管理视图和文档对象。
视图对象和控制条都成为CFrameWnd的子窗口,它们分享客户区,其位置被CFrameWnd有效地排列。
CFrameWnd直接支持单文档界面(SDI),对于多文档界面(MDI),使用其派生类CMDIFrameWnd和CMDIChildWnd。
CFrameWnd的创建该类定义了两个成员函数用于创建主窗口,即Create()和LoadFrame()。
前者主要通过CWnd::CreateEx()创建窗口;而后者首先组织参数,再调用前者。
它们的定义如下:BOOL CFrameWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, LPCTSTR lpszMenuName, DWORD dwExStyle, CCreateContext* pContext) {/*可见,参数列表与CWnd::Create()稍有不同。
因为目的是创建主窗口,所以第6个参数要求菜单资源名*/HMENU hMenu = NULL;if (lpszMenuName != NULL){//搜索包含该菜单资源的实例(当前进程或者按进行装入的DLL)HINSTANCE hInst = AfxFindResourceHandl(lpszMenuName, RT_MENU);//装入菜单资源if ((hMenu = ::LoadMenu(hInst, lpszMenuName)) == NULL){TRACE0(“Warning: failed to load menu for CFrameWnd.\n”);PostNcDestroy(); //perhaps delete to C++ objectreturn FALSE;}}m_strTitle = lpszWindowName; //存储窗口标题,以备后用(如刷新显示)// 调用CWnd::CreateEx()if (!CreateEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle, rect.left, rect.top, rect.right –rect.left, rect,bottom –rect.top, pParentWnd->GetSafeHwnd(), hMenu, (LPVOID)pContext)){if (hMenu != NULL)DestroyMenu(hMenu); //如果创建失败,释放菜单资源return FALSE;}return TRUE;}BOOL CFrameWnd::LoadFrame(UNIT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext){/*主窗口的菜单、图标、加速键、及标题都以nIDResource标识。
静态分割窗口与多视图实例所谓多视,是指在同一个框架窗口下同时显示多个视图。
通过运用这种技术,可以在框架的有限的空间内同时提供给用户更大的信息量,并且使得用户界面更加的友好,增强了软件的可操作性。
窗口分割的基本概念按照分割的时机的不同,窗口分割可以分为两类:动态分割和静态分割。
动态分割是指用户可以动态的分割和合并窗口。
动态分割最多可以有2行2列个窗口,并且所有的窗格只能使用同一种视图类。
静态分割是指窗口在创建时,分割窗格窗口的窗格已经创建好了,且窗格的数量和顺序不会改变了,窗格为一个分隔条所分割,用户可以拖动分割条调整相应的窗格的大小。
静态分割窗口最多可以有16行16列的窗格,但是各个窗格可以使用不同的视图类。
无论创建那一种分割,都必须在创建时指定最大的行数和列数,这些值是有CSplitterWnd 对象进行管理。
对于静态分割,必须创建指定数目的所有窗格以填满行和列。
而对于动态分割,第一个窗格将在框架创建CSplitterWnd对象时自动创建。
窗口分割支持类CSplitterWndCSplitterWnd类主要为窗口的风格提供了封装,窗口被分厂各个窗格后,又该类的对象负责管理。
对于windows而言,CSplitterWnd是一个真正的窗口,它完全占据了框架窗口的用户区域,而视图则占据了分割窗口的床片区域。
CSplitterWnd窗口不参与命令传递机制。
使用时,CSplitterWnd对象通常为其父框架窗口CFrameWnd或CMDIChildWnd(MID应用中)对象的内嵌成员。
CSplitterWnd对象创建过程如下。
在父框架窗口中嵌入CSplitterWnd类的对象成员;重载父框架窗口的CFrameWnd::OnCreateClient成员函数;从上一步重载的函数内部调用Create创建动态分割窗口或者调用CreateStatic创建静态的分割窗口。
下面介绍CsplitterWnd类的几个常用的函数创建动态分割窗口函数Create该函数用于动态创建分割窗口,同时将该窗口与类CSplitterWnd相关联,其生声明如下:BOOL Create(CWnd* pParentWnd, int nMaxRows, int MaxCol, SIZE sizeMin, CcreateContext* pContext, DOWRD dwStyle = WS_CHILD |WS_VISIBLE | WS_HSCROLL | WSVSCROLL | SPLS_DYNAMIC_SPLIT,UINT nID=AFX_IDW_PANE_FIRST);各主要参数的含义如下:pParentWnd:分割窗口的父框架窗口的指针nMaxRows和你MaxCols:行与列的最大值,二者均不大于二sizeMin:指定窗格被显示时的最小值。
附录:英文技术资料翻译英文原文:Microsoft Visual C++ 6.0 and MFC Brief IntroductionThe Visual C 6.0, referred to as VC or VC6.0, Microsoft introduced a C compiler, high-level language the program translated into machine language (low-level language). Visual C is a powerful visualization software development tools. , With its new version come out since 1993, Microsoft introduced the Visual C 1.0, Visual C has become the tool of choice for professional programmers to develop software. Microsoft Visual C NET (Visual C 7.0), but its application has great limitations, applies only to Windows 2000, Windows XP and Windows NT 4.0. Practice, are based more on the Visual C 6.0 as a platform.Features and shortcomingsCharacteristicVisual C, 6.0, developed by Microsoft, it is not only a C compiler, and a Windows operating system, a visual integrated development environment (integrated development environment, IDE). Visual C 6.0 is composed of many components, including editor, debugger, and AppWizard AppWizard, ClassWizard Class Wizard and other development tools. These components are integrated through a component called Developer Studio for the harmonious development environment. Microsoft's main software products. Visual C is a powerful visualization software development tools. , With its new version come out since 1993, Microsoft introduced the Visual C 1.0, Visual C has become the tool of choice for professional programmers to develop software. Microsoft Visual C NET (Visual C 7.0), but the limitations of its application only applies to Windows 2000, Windows XP and Windows NT 4.0. Practice, are based more on the Visual C 6.0 as a platform.Visual C, 6.0 to have syntax highlighting, automatic compiler functions and advanced debugging features known. For example, it allows users to remotely debug a single step. As well as allow the user during debugging to recompile the modified code, without having to restart the program being debugged. Compile and create the precompiled header file (the stdafx.h), the minimum reconstruction function and the cumulative link (link). These features significantly shorten the procedure edit, compile and link time to spend, particularly notable in thelarge-scale software projects.ShortcomingC is developed by C language, and also supports the C language compiler. Version 6.0 is the most used version of the classic. The biggest shortcoming is its relatively poor support for templates. The latest patch for SP6, the recommended installation, or prone to compile-time state of suspended animation. Supports only the Windows operating system. Currently found with windows 7 compatibility is not good, can not open the cpp file of the phenomenon may occur after a successful installation.MFCmfc is the abbreviation of the Microsoft Foundation Class Library, Microsoft implemented a c class library encapsulates most of the Windows API function, vc is the integrated development environment developed byMicrosoft Corporation c / c, the so-called integrated development environment, that is use it you can edit, co mpile, debug, instead of using the rotation operation of a variety of tools, greater flexibility. Sometimes people say vc it also refers to its internal compiler, integrated development environment must have a compiler, kernel, or what, such as DevC which the kernel of a compiler is the gcc. MFC is a class library, outside, or a framework, you should be tried, to create a new MFC project in vc, the development environment will help you automatically generate a lot of files at the same time it uses mfcxx.dll. xx is the version of mfc kernel, so you see less than the original SDK programming in the message loop, and things in your code, because the MFC framework to help you better package, so you can concentrate on consideration of your application logic, and what not each programming must be repeated, but is a common framework, not the best targeted, of course, they also lose some flexibility and efficiency of the MFC package is very shallow, so little loss of efficiency flexibility, although there are many defects, but still a good thing.MFC and Win32The MFC the Object and the Windows the Object of the relationship between MFC package yes encapsulation of the Win32 API, therefore, understand the Windows Object and the MFC the Object (C, + + object, a C, + + class's instance) between the understanding of MFC's key one. The so-called the Windows the Object (the Windows object) is under Win32 use handle, said of the Windows operating system object; so-called the MFC the Object (the MFC object) is C, + + object, is a C + + class's instance, here (within the scope of this book) the MFC the Object is to have a specific meaning, refers to the package of Windows Object C + + Object does not refer to any C + + the Object. MFC Object and Windows Object is not the same, but the two closely linked. Window object, for example: an MFC window object is a C + + CWnd class (or derived class) instance, is a program created directly. Program execution with the window class constructor call generation, disappear with the call to t he destructor. Windows window is an instance of an internal data structure of the Windows system from a window handle identifies the Windows system to create it and give it to allocate system resources. Windows window after the MFC window object is created by the Create member function of CWnd class to create a window handle is stored in the window object's m_hWnd member variable. Windows window can be destroyed, a program can also be destroyed by the actions of users. MFC window objects and Windows window object relationship shown in Figure 2-1. the other Windows Object and the corresponding MFC Object also has a similar relationship.MFC window class CWndOn Windows systems, the attributes of a window in two places to store: one part on the inside of the window class ", as described above is specified in the login window; another part on the Windows Object, such as: the size of the window, the window position (X, Y axis), the window Z-order of the state of the window (ACTIVE, MINIMIZED, MAXMIZED, RESTORED ...), and other window (parent window, child window ...), the window can receive keyboard or mouse message and so on.In order to express the commonality of all these windows, the MFC design a window base class of the CWnd. It is very important, CWnd to provide a standard generic MFC window procedure, all windows in MFC use this window. As for the common window procedure was able to achieve different operation for each window, that the mysteries of the MFC message mapping mechanism and role of theCreate a window object in MFCMFC to create a window object in two steps, first create an MFC window object, and then create a corresponding Windows window. Memory use, the MFC window object on the stack or heap (new creation) to create. The specific formulation is as follows:Create an MFC window object. By the definition of a CWnd or its derived class instance variables or dynamically create an MFC window instance, the former stack space to create an MFC window objects, which create an MFC window objects in the heap space.Calls the appropriate window to create a function to create a Windows window object.The use of the MFC windowMFC provides a window class, its function and purpose vary. The programmer should choose which classes to use, and how to use them?Direct use of the MFC provides a window class, or start with the MFC window class derived a new C + + class and then use it under normal circumstances, these do not require the programmer to provide the registration code of the window. Need to derive the new C + + class, as the MFC window class is already able to meet the requirements. Derived C + + class inherits the characteristics of the base class and to change or extend its functionality, such as increasing or change the news, events, special processing.The main use or inherit the following MFC window class (the hierarchy shown in Figure 1-1):Framework class CFrameWnd, CMdiFrameWnd;Document framework CMdiChildWnd;View CView, and CView derived view of the special features such as: list CListView edit CEditView tree list CTreeView, RTF CRichEditView the dialog-based CFormView and so on.Dialog box, the CDialog.Typically, the window must be from the framework of the application of these classes are derived and depending on the window or dialog box.Toolbar CToolBarStatus bar CStatusBarOther types of control window, such as CList of the list box, the CEdit of the edit box, combo box the CComboBox button Cbutton.Typically, the direct use of these classes.The destruction of the window in MFCThe window object after use, should be destroyed. MFC, a window object is the destruction of the destruction including the destruction of the HWND of the window object and MFC window object. Under normal circumstances, MFC programming framework automatically handle these.(1) of CFrameWnd and CView derived classThe closure of these windows lead to the destruction of the window function DestroyWindow is called. Windows window is destroyed, the last member function is called by the MFC framework the OnNcDestroy function, which is responsible for the Windows clean-up work, and the last call virtual member function of the PostNcDestroy. CFrameWnd and CView, PostNcDestroy call delete this delete their own MFC window object.Therefore, these windows, as mentioned above, should be in the heap (Heap) is allocated, but, do not use the delete operations on these objects.(2) for Windows Control windowIn their destructor will be called DestroyWidnow to destroy the window. If such a window object allocated on the stack beyond the scope of the destructor call, the MFC window object and its Windows window object is destroyed. If the heap (Heap) is allocated, then explicitly call delete operator, resulting in the destruction of the destructor calls and window.Therefore, this type of window should be allocated on the stack, to avoid the extra code to destroy the window. As mentioned earlier the CMainFrame member variables m_wndStatusBar and m_wndToolBar is one such example.(3) For programmers directly derived from CWnd windowProgrammers can be implemented in a derived class to one of these two mechanisms, and then, in the corresponding specification.Device descriptor table summarizes theWhen an application uses GDI functions, you must first load a specific device driver, and then draw the window device context, such as the specified line width and color, brush styles and colors, fonts, clipping region. Unlike other Win32 structure, equipment description table can not be accessed directly, only indirectly through a series of Win32 function operation.中文译文:Microsoft Visual C++ 6.0 和MFC简要介绍Visual C ++ 6.0,简称VC或者VC6.0,是微软推出的一款C 编译器,将“高级语言”翻译为“机器语言(低级语言)”的程序。
A T L消息处理机制ATL消息机制的探究作者:后知后觉(307817387)任何的框架,包括MFC或者ATL,创建并显示窗口,处理窗口消息都逃不过RegisterClass、CreateWindow和Message Loop。
对于ATL也是一样的道理,下面就来细说一下ATL的消息处理机制。
重要的部分我会用红色标识出来。
1,注册窗口类CWindowImpl类使用一个DECLARE_WND_CLASS(NULL)的宏来定义WNDCLASS的信息#define DECLARE_WND_CLASS(WndClassName) \static ATL::CWndClassInfo& GetWndClassInfo() \{ \static ATL::CWndClassInfo wc = \{ \{ sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, StartWindowProc, \0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, WndClassName, NULL }, \NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \}; \return wc; \}这里有一个很重要的信息,那就是StartWindowProc,这个是定义的默认的窗口处理函数。
先提醒一下,后面有具体说明。
CWndClassInfo的定义如下:struct _ATL_WNDCLASSINFOW{WNDCLASSEXW m_wc;LPCWSTR m_lpszOrigName;WNDPROC pWndProc;LPCWSTR m_lpszCursorID;BOOL m_bSystemCursor;ATOM m_atom;WCHAR m_szAutoName[5+sizeof(void*)*CHAR_BIT];ATOM Register(WNDPROC* p){return AtlWinModuleRegisterWndClassInfoW(&_AtlWinModule, &_AtlBaseModule, this, p);}};其中的Register方法会注册一个窗口类。
M F C消息映射机制如何运用C l a s s W i z a r d The Standardization Office was revised on the afternoon of December 13, 2020画图的基本应用:Point的应用,在mfc中的很多的位置都要用到。
只是当前点的信息,xy坐标,MoveToEx 移动位置函数The MoveToEx function updates the current position to the specified point and optionally returns the previous position.LineTo 画直线的函数CDC类,作图相关的操作GetDC,cwnd::getdc 以及cdc的释放(区别hdc),两者的范围不同,调用方式不同CClientDC 不需要显示地调用getdc和releasedc,只需要声明类的定义和类的调用。
Cliendc对象里利用view指针构造,但是调用的时候用的是对象的点调用方式。
Cwnd::getparent 获得父窗口的指针,view的父窗口是frame。
注意区别view 和framework的客户区域。
Cwindowdc类和clientdc一样自动调用getdc和releasedc。
了解他的访问客户区的范围。
Getdesktopwindow 获得桌面窗口。
创建画笔:CPen 类,设置画笔的属性,包括一些类型宽度,颜色。
CDC::SelectObject 用的过程中要保存原来的画笔指针。
创建一个阴影线的笔只能是1或更小。
(其他的注意情况看msdn)。
创建画刷:CBrush 类的方法FillRect填充矩形的区域。
CRect类,几种不同的方法。
用位图填充画刷。
CBitmap 的构造函数,没有参数。
调用之前必需初始化。
透明画刷的创建:(); 画出矩形。
空画刷:GetStockObjectCBrush::FromeHandle空画刷的实现方法:CBrush *brush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));CBrush *oldbrush=(brush);(CRect(org,point));(oldbrush);理解消息响应的知识:MouseMove。
第一部分 - ATL 中的 GUI 类•下载示例工程 - 45.5 KB本章内容•README.TXT•本系列介绍•第一部分介绍•ATL 背景知识o ATL 和 WTL 的历史o ATL 风格的模板•ATL 窗口类•定义窗口实现o填充消息映射•高级消息映射链和嵌入(Mix-in)类•ATL EXE 的结构o VC 6 的情形o VC 7 的情形•ATL 中的对话框•就要到 WTL 了,我保证!•修订历史README.TXT在继续或者在本文的讨论板块中发布帖子之前,我希望你能先阅读以下内容。
本系列原来是为 VC 6 用户写的,介绍 WTL 7.0 的内容。
现在 VC 8 已经出来了,我觉得也到了更新本系列来介绍VC 7.1 的时候了。
;)(不过,VC 7.1 的从 6 到 7 的自动转换工作并不是总能平滑地完成,所以 VC 7.1 的用户在试着使用示例源代码的时候可能会遭遇失败)因而,我将继续下去,持续更新本系列。
文章将更新到可以反映 WTL 7.1 的特性,并会在下载的源代码中包括 VC 7.1 的工程。
针对 VC 2005 用户的重要提示:VC 2005 的 Express 版本并不附带 ATL 或者 MFC,因此不能使用此版本编译ATL 或者 WTL 工程。
如果你在使用 VC 6,那你就需要有 Platform SDK。
没有它你将不能使用 WTL。
你可以使用Web 安装版本或者下载 CAB 文件或者是ISO 映像,然后在本地运行安装程序。
请使用工具把 SDK 的 include 以及 lib 目录加入到 VC 的搜索路径中,该工具可以在 Platform SDK 程序组中的Visual Studio Registration文件夹下找到。
即使你在用 VC 7,使用最新的 Platform SDK 仍然是一个好主意,因为你可以得到最新的头文件和库。
你需要有 WTL。
可以从微软下载版本 7。
在文章"Introduction to WTL - Part 1"以及"Easy installation of WTL"中有一些关于安装的提示。
mfc2019 类库参考手册MFC 2019 类库参考手册一、概述MFC(Microsoft Foundation Class)是微软公司为了简化Windows 应用程序开发而开发的类库。
本手册将详细介绍MFC 2019类库的各个模块,包括类的定义、成员函数、属性和示例等内容,为开发人员提供全面且准确的参考。
二、基础类1. CObject类CObject类是MFC类库的基类,所有MFC类都从该类派生。
本节将介绍CObject类的成员函数、构造函数和析构函数。
2. CWnd类CWnd类封装了Windows窗口的操作。
本节将介绍CWnd类的常用成员函数,如Create、ShowWindow和SendMessage等。
3. CWinApp类CWinApp类是一个应用程序对象类,每个MFC应用程序都必须拥有一个CWinApp类的派生类。
本节将介绍CWinApp类的初始化、消息循环和资源管理等功能。
三、窗口和控件类1. CFrameWnd类CFrameWnd类是MFC应用程序的主框架窗口类,它提供了标题栏、菜单、工具栏和状态栏等功能。
本节将介绍CFrameWnd类的创建和布局等操作。
2. CDialog类CDialog类是MFC应用程序中常用的对话框类,用于创建模态或非模态对话框。
本节将介绍CDialog类的创建和消息处理等方法。
3. CButton类CButton类封装了Windows中的按钮控件,提供了按钮的创建、属性设置和消息处理等功能。
本节将介绍CButton类的常用成员函数,如Create、SetCheck和EnableWindow等。
4. CEdit类CEdit类封装了Windows中的编辑框控件,可用于接受用户的输入和显示文本内容。
本节将介绍CEdit类的创建、文本操作和消息处理等方法。
四、绘图和界面类1. CDC类CDC类提供了对设备上下文的封装,用于进行绘图和界面操作。
本节将介绍CDC类的绘图函数,如LineTo、Rectangle和TextOut等。
滑动控件是Windows中最常用的控件之一。
一般而言它是由一个滑动条,一个滑块和可选的刻度组成,用户可以通过移动滑块在相应的控件中显示对应的值。
通常,在滑动控件附近一定有标签控件或编辑框控件,用于显示相应的值。
滑动控件在应用程序中用途级为广泛,如在桌面的属性中就可以看到。
为此,让我们一起来看一下它的实现方法。
(1)在VC++ 6.0中新建一个对话框文档的工程。
(2)打开资源管理器,在对话框中放置一个EDIT控件,然后在它旁边放上一个Slider控件。
基本的框架已经完成了。
(3)对Slider控件右击,选择“建立类向导”,对刚才的Slider控件定义一个变量m_Slider,类型为CSliderCtrl。
(4)在对话框初始化的代码BOOL CMy601Dlg::OnInitDialog(),后添加相应的属性。
以下是常用的属性设置函数:* GetRange,SetRange函数用于查询和设置滑动条的取值范围,默认为0~100。
函数定义形式如下:void GetRange(int &nMin,int &nMax) const;void SetRange(int nMin,int nMax,BOOL bRedrGETaw=FALSE);* GetPos,SetPos函数用于查询和设置滑动条的当前值。
函数定义形式如下:int GetPos() const;int SetPos(int nPos);* GetLineSize,SetLineSize函数用于查询和设置在按一下右或左箭头时滑块的移动量,默认为1个单位。
函数定义形式如下:int GetLineSize() const;int SetLineSize(int nSize);* GetPageSize,SetPageSize函数用于查询和设置函滑块和块移动量,块移动量是指当按下PgUp或PgDown时滑块的移动量。
函数定义形式如下:int GetPageSize() const;int SetPageSize(int nSize);* SetTicFreq函数用于设置滑动条刻度的频度。
CWnd Class MembersData MembersConstruction/DestructionInitialization Initialization Dialog-Box Item Functions Initialization Message Handlers Window State Functions Data-Binding Functions System Message Handlers Window Size and Position Menu Functions General Message Handlers Window Access FunctionsTool Tip Functions Control Message Handlers Update/Painting Functions Timer Functions Input Message Handlers Coordinate Mapping Functions Alert Functions Nonclient-Area Message Handlers Window Text Functions Window Message Functions MDI Message Handlers Scrolling FunctionsClipboard Functions Clipboard Message Handlers Drag-Drop FunctionsActiveX Controls Menu Loop NotificationCaret FunctionsOverridables m_hWndIndicates the HWND attached to this CWnd .CWndConstructs a CWnd object.DestroyWindowDestroys the attached Windows window.CreateCreates and initializes the child window associated with the CWnd object.PreCreateWindowCalled before the creation of the Windows window attached to this CWnd object.CalcWindowRectCalled to calculate the window rectangle from the client rectangle.GetStyleReturns the current window style.GetExStyleReturns the window’s extended style.AttachAttaches a Windows handle to a CWnd object.DetachDetaches a Windows handle from a CWnd object and returns the handle.PreSubclassWindow Allows other necessary subclassing to occur before SubclassWindow is called.Window State Functions SubclassWindowAttaches a window to a CWnd object and makes it route messages through the CWnd ’s message map.UnsubclassWindowDetaches a window from a CWnd object FromHandle Returns a pointer to a CWnd object when given a handle to a window. If a CWnd object is not attached to thehandle, a temporary CWnd object is created and attached.FromHandlePermanent Returns a pointer to a CWnd object when given a handleto a window. If a CWnd object is not attached to thehandle, NULL is returned.DeleteTempMap Called automatically by the CWinApp idle-time handler and deletes any temporary CWnd objects created byFromHandle .GetSafeHwnd Returns m_hWnd , or NULL if the this pointer is NULL .CreateEx Creates a Windows overlapped, pop-up, or child window and attaches it to a CWnd object.CreateControlCreate an OLE control that will be represented in an MFCprogram by a CWnd object.IsWindowEnabledDetermines whether the window is enabled for mouse and keyboard input.EnableWindow Enables or disables mouse and keyboard input.GetActiveWindowRetrieves the active window.SetActiveWindowActivates the window.GetCaptureRetrieves the CWnd that has the mouse capture.SetCaptureCauses all subsequent mouse input to be sent to the CWnd .GetFocusRetrieves the CWnd that currently has the input focus.SetFocusClaims the input focus.GetDesktopWindowRetrieves the Windows desktop window.GetForegroundWindowReturns a pointer to the foreground window (the top-level window with which the user is currently working).SetForegroundWindowPuts the thread that created the window into the foreground and activates the window.GetIconRetrieves the handle to an icon.SetIconSets the handle to a specific icon.GetWindowContextHelpId Retrieves the help context identifier.Window Size and PositionWindow Access Functions SetWindowContextHelpIdSets the help context identifier.ModifyStyleModifies the current window style.ModifyStyleEx Modifies the window’s extended style.GetWindowPlacementRetrieves the show state and the normal (restored), minimized, and maximized positions of a window.SetWindowPlacementSets the show state and the normal (restored), minimized, and maximized positions for a window.GetWindowRgnRetrieves a copy of the window region of a window.SetWindowRgnSets the region of a window.IsIconicDetermines whether CWnd is minimized (iconic).IsZoomedDetermines whether CWnd is maximized.MoveWindowChanges the position and dimensions of CWnd .SetWindowPosChanges the size, position, and ordering of child, pop-up, and top-level windows.ArrangeIconicWindows Arranges all the minimized (iconic) child windows.BringWindowToTop Brings CWnd to the top of a stack of overlapping windows.GetWindowRectGets the screen coordinates of CWnd .GetClientRectGets the dimensions of the CWnd client area.ChildWindowFromPointDetermines which, if any, of the child windows contains the specified point.FindWindowReturns the handle of the window, which is identified by its window name and window class.GetNextWindowReturns the next (or previous) window in the window manager’s list.GetOwnerRetrieves a pointer to the owner of a CWnd .SetOwnerChanges the owner of a CWnd .GetTopWindowReturns the first child window that belongs to the CWnd .GetWindowReturns the window with the specified relationship to this window.GetLastActivePopup Determines which pop-up window owned by CWnd was most recently active.Update/Painting Functions IsChildIndicates whether CWnd is a child window or other direct descendant of the specified window.GetParent Retrieves the parent window of CWnd (if any).GetSafeOwnerRetrieves the safe owner for the given window.SetParent Changes the parent window.WindowFromPoint Identifies the window that contains the given point.GetDlgItemRetrieves the control with the specified ID from the specified dialog box.GetDlgCtrlIDIf the CWnd is a child window, calling this function returns its ID value.SetDlgCtrlID Sets the window or control ID for the window (whichcan be any child window, not only a control in a dialog box).GetDescendantWindow Searches all descendant windows and returns the window with the specified ID.GetParentFrame Retrieves the CWnd object’s parent frame window.SendMessageToDescendants Sends a message to all descendant windows of the window.GetTopLevelParent Retrieves the window’s top-level parent.GetTopLevelOwner Retrieves the top-level window.GetParentOwner Returns a pointer to a child window’s parent window.GetTopLevelFrame Retrieves the window’s top-level frame window.UpdateDialogControls Call to update the state of dialog buttons and othercontrols.UpdateData Initializes or retrieves data from a dialog box.CenterWindowCenters a window relative to its parent.BeginPaintPrepares CWnd for painting.EndPaintMarks the end of painting.PrintDraws the current window in the specified device context.PrintClientDraws any window in the specified device context (usually a printer device context).LockWindowUpdateDisables or reenables drawing in the given window.UnlockWindowUpdate Unlocks a window that was locked with CWnd::LockWindowUpdate .Coordinate Mapping Functions Window Text FunctionsGetDCRetrieves a display context for the client area.GetDCExRetrieves a display context for the client area, and enables clipping while drawing.RedrawWindowUpdates the specified rectangle or region in the client area.GetWindowDCRetrieves the display context for the whole window, including the caption bar, menus, and scroll bars.ReleaseDCReleases client and window device contexts, freeing them for use by other applications.UpdateWindowUpdates the client area.SetRedrawAllows changes in CWnd to be redrawn or prevents changes from being redrawn.GetUpdateRectRetrieves the coordinates of the smallest rectangle that completely encloses the CWnd update region.GetUpdateRgnRetrieves the CWnd update region.InvalidateInvalidates the entire client area.InvalidateRectInvalidates the client area within the given rectangle by adding that rectangle to the current update region.InvalidateRgnInvalidates the client area within the given region by adding that region to the current update region.ValidateRectValidates the client area within the given rectangle by removing the rectangle from the current update region.ValidateRgnValidates the client area within the given region by removing the region from the current update region.ShowWindowShows or hides the window.IsWindowVisibleDetermines whether the window is visible.ShowOwnedPopupsShows or hides all pop-up windows owned by the window.EnableScrollBarEnables or disables one or both arrows of a scroll bar.MapWindowPoints Converts (maps) a set of points from the coordinatespace of the CWnd to the coordinate space of another window.ClientToScreen Converts the client coordinates of a given point or rectangle on the display to screen coordinates.ScreenToClientConverts the screen coordinates of a given point or rectangle on the display to client coordinates.Scrolling FunctionsDrag-Drop FunctionsCaret Functions SetWindowTextSets the window text or caption title (if it has one) to the specified text.GetWindowTextReturns the window text or caption title (if it has one).GetWindowTextLength Returns the length of the window’s text or caption title.SetFontSets the current font.GetFontRetrieves the current font.GetScrollPosRetrieves the current position of a scroll box.GetScrollRangeCopies the current minimum and maximum scroll-bar positions for the given scroll bar.ScrollWindowScrolls the contents of the client area.ScrollWindowExScrolls the contents of the client area. Similar to ScrollWindow , with additional features.GetScrollInfoRetrieves the information that the SCROLLINFO structure maintains about a scroll bar.GetScrollLimitRetrieves the limit of the scroll bar.SetScrollInfoSets information about the scroll bar.SetScrollPos Sets the current position of a scroll box and, ifspecified, redraws the scroll bar to reflect the new position.SetScrollRange Sets minimum and maximum position values for the given scroll bar.ShowScrollBar Displays or hides a scroll bar.EnableScrollBarCtrl Enables or disables a sibling scroll-bar control.GetScrollBarCtrl Returns a sibling scroll-bar control.RepositionBarsRepositions control bars in the client area.DragAcceptFilesIndicates the window will accept dragged files.CreateCaretCreates a new shape for the system caret and gets ownership of the caret.CreateSolidCaret Creates a solid block for the system caret and getsownership of the caret.Dialog-Box Item Functions CreateGrayCaretCreates a gray block for the system caret and gets ownership of the caret.GetCaretPosRetrieves the client coordinates of the caret’s current position.SetCaretPosMoves the caret to a specified position.HideCaretHides the caret by removing it from the display screen.ShowCaret Shows the caret on the display at the caret’s current position. Once shown, the caret begins flashing automatically.CheckDlgButtonPlaces a check mark next to or removes a check mark from a button control.CheckRadioButton Checks the specified radio button and removes thecheck mark from all other radio buttons in the specified group of buttons.GetCheckedRadioButton Returns the ID of the currently checked radio button in a group of buttons.DlgDirList Fills a list box with a file or directory listing.DlgDirListComboBox Fills the list box of a combo box with a file or directory listing.DlgDirSelect Retrieves the current selection from a list box.DlgDirSelectComboBox Retrieves the current selection from the list box of a combo box.GetDlgItemInt Translates the text of a control in the given dialog box to an integer value.GetDlgItemText Retrieves the caption or text associated with a control.GetNextDlgGroupItem Searches for the next (or previous) control within a group of controls.GetNextDlgTabItem Retrieves the first control with the WS_TABSTOP style that follows (or precedes) the specified control.IsDlgButtonChecked Determines whether a button control is checked.IsDialogMessage Determines whether the given message is intended for the modeless dialog box and, if so, processes it.SendDlgItemMessage Sends a message to the specified control.SetDlgItemInt Sets the text of a control to the string that representsan integer value.SetDlgItemTextSets the caption or text of a control in the specified dialog box.Data-Binding FunctionsMenu FunctionsToolTip Functions Timer FunctionsSubclassDlgItem Attaches a Windows control to a CWnd object andmakes it route messages through the CWnd ’s message map.ExecuteDlgInit Initiates a dialog resource.RunModalLoop Retrieves, translates, or dispatches messages for awindow that is in modal status.ContinueModal Continues a window’s modal status.EndModalLoopEnds a window’s modal status.BindDefaultProperty Binds the calling object’s default simple bound property, as marked in the type library, to a cursorassociated with a data-source control.BindProperty Binds a cursour-bound property on a data-boundcontrol to a data-source control and registers that relationship with the MFC binding manager.GetDSCCursorRetrieves a pointer to the underlying cursor that isdefined by the DataSource, UserName, Password, and SQL properties of a data-source control.GetMenuRetrieves a pointer to the specified menu.SetMenuSets the menu to the specified menu.DrawMenuBarRedraws the menu bar.GetSystemMenuAllows the application to access the Control menu for copying and modification.HiliteMenuItemHighlights or removes the highlighting from a top-level (menu-bar) menu item.EnableToolTipsEnables the tooltip control.CancelToolTipsDisables the tooltip control.FilterToolTipMessageRetrieves the title or text associated with a control in a dialog box.OnToolHitTest Detemines whether a point is in the boundingrectangle of the specified tool and retrieves information about the tool.Alert FunctionsWindow Message FunctionsClipboard Functions SetTimerInstalls a system timer that sends a WM_TIMER message when triggered.KillTimerKills a system timer.FlashWindowFlashes the window once.MessageBoxCreates and displays a window that contains an application-supplied message and caption.GetCurrentMessage Returns a pointer to the message this window iscurrently processing. Should only be called when in an On Message message-handler member function.Default Calls the default window procedure, which provides default processing for any window messages that anapplication does not process.PreTranslateMessage Used by CWinApp to filter window messages beforethey are dispatched to the TranslateMessage and DispatchMessage Windows functions.SendMessage Sends a message to the CWnd object and does not return until it has processed the message.PostMessage Places a message in the application queue, thenreturns without waiting for the window to process the message.SendNotifyMessageSends the specified message to the window and returns as soon as possible, depending on whether thecalling thread created the window.ChangeClipboardChainRemoves CWnd from the chain of Clipboard viewers.SetClipboardViewerAdds CWnd to the chain of windows that are notified whenever the contents of the Clipboard are changed.OpenClipboard Opens the Clipboard. Other applications will not beable to modify the Clipboard until the Windows CloseClipboard function is called.GetClipboardOwner Retrieves a pointer to the current owner of the Clipboard.GetOpenClipboardWindow Retrieves a pointer to the window that currently has the Clipboard open.GetClipboardViewerRetrieves a pointer to the first window in the chain of Clipboard viewers.ActiveX ControlsOverridablesInitialization Message HandlersSystem Message Handlers SetPropertySets an ActiveX control property.OnAmbientPropertyImplement ambient property values.GetControlUnknown Retrieves a pointer to an unknown ActiveX control.GetPropertyRetrieves an ActiveX control property.InvokeHelper Invokes an ActiveX control method or property.WindowProcProvides a window procedure for a CWnd . The default dispatches messages through the message map.DefWindowProc Calls the default window procedure, which providesdefault processing for any window messages that an application does not process.PostNcDestroy This virtual function is called by the default OnNcDestroy function after the window has been destroyed.OnNotify Called by the framework to inform a parent window an event has occurred in one of its controls or that the control needs information.OnChildNotify Called by a parent window to give a notifying control a chance to respond to a control notification.DoDataExchangeFor dialog data exchange and validation. Called by UpdateData .OnInitMenuCalled when a menu is about to become active.OnInitMenuPopupCalled when a pop-up menu is about to become active.OnSysCharCalled when a keystroke translates to a system character.OnSysCommand Called when the user selects a command from theControl menu, or when the user selects the Maximize or Minimize button.OnSysDeadChar Called when a keystroke translates to a system dead character (such as accent characters).OnSysKeyDownCalled when the user holds down the ALT key and then presses another key.General Message Handlers OnSysKeyUpCalled when the user releases a key that was pressed while the ALT key was held down.OnCompactingCalled when Windows detects that system memory is low.OnDevModeChangeCalled for all top-level windows when the user changes device-mode settings.OnFontChangeCalled when the pool of font resources changes.OnPaletteIsChanging Informs other applications when an application is going to realize its logical palette.OnPaletteChanged Called to allow windows that use a color palette torealize their logical palettes and update their client areas.OnSysColorChange Called for all top-level windows when a change is made in the system color setting.OnWindowPosChanging Called when the size, position, or Z-order is about tochange as a result of a call to SetWindowPos or another window-management function.OnWindowPosChanged Called when the size, position, or Z-order has changed as a result of a call to SetWindowPos oranother window-management function.OnDropFiles Called when the user releases the left mouse button over a window that has registered itself as the recipient of dropped files.OnSpoolerStatus Called from Print Manager whenever a job is added to or removed from the Print Manager queue.OnTimeChange Called for all top-level windows after the system timechanges.OnWinIniChangeCalled for all top-level windows after the Windowsinitialization file, WIN.INI, is changed.OnCommandCalled when the user selects a command.OnActivateCalled when CWnd is being activated or deactivated.OnActivateAppCalled when the application is about to be activated or deactivated.OnCancelModeCalled to allow CWnd to cancel any internal modes, such as mouse capture.OnChildActivate Called for multiple document interface (MDI) child windows whenever the size or position of CWndchanges or CWnd is activated.OnCloseCalled as a signal that CWnd should be closed.OnCopyData Copies data from one application to another. OnCreate Called as a part of window creation.OnCtlColor Called if CWnd is the parent of a control when thecontrol is about to be drawn.OnDestroy Called when CWnd is being destroyed.OnEnable Called when CWnd is enabled or disabled. OnEndSession Called when the session is ending.OnEnterIdle Called to inform an application’s main windowprocedure that a modal dialog box or a menu isentering an idle state.OnEraseBkgnd Called when the window background needs erasing. OnGetMinMaxInfo Called whenever Windows needs to know themaximized position or dimensions, or the minimumor maximum tracking size.OnIconEraseBkgnd Called when CWnd is minimized (iconic) and thebackground of the icon must be filled before paintingthe icon.OnKillFocus Called immediately before CWnd loses the inputfocus.OnMenuChar Called when the user presses a menu mnemoniccharacter that doesn’t match any of the predefinedmnemonics in the current menu.OnMenuSelect Called when the user selects a menu item.OnMove Called after the position of the CWnd has beenchanged.OnMoving Indicates that a user is moving a CWnd object. OnDeviceChange Notifies an application or device driver of a change tothe hardware configuration of a device or thecomputer.OnStyleChanged Indicates that the::SetWindowLong Windowsfunction has changed one or more of the window'sstyles.OnStyleChanging Indicates that the::SetWindowLong Windowsfunction is about to change one or more of thewindow's styles.OnPaint Called to repaint a portion of the window. OnParentNotify Called when a child window is created or destroyed,or when the user clicks a mouse button while thecursor is over the child window.OnQueryDragIcon Called when a minimized (iconic) CWnd is about tobe dragged by the user.Control Message Handlers OnQueryEndSessionCalled when the user chooses to end the Windows session.OnQueryNewPalette Informs CWnd that it is about to receive the input focus.OnQueryOpenCalled when CWnd is an icon and the user requests that the icon be opened.OnSetFocusCalled after CWnd gains the input focus.OnShowWindowCalled when CWnd is to be hidden or shown.OnSizeCalled after the size of CWnd has changed.OnSizingIndicates that the user is resizing the rectangle.OnStyleChangedIndicates that one or more of the window's styles has changed.OnStyleChanging Indicates that one or more of the window's styles is about to change.OnCharToItem Called by a child list box with the LBS_WANTKEYBOARDINPUT style in response to a WM_CHAR message.OnCompareItem Called to determine the relative position of a new itemin a child sorted owner-draw combo box or list box.OnDeleteItem Called when an owner-draw child list box or combobox is destroyed or when items are removed from the control.OnDrawItem Called when a visual aspect of an owner-draw child button control, combo-box control, list-box control, ormenu needs to be drawn.OnDSCNotify Called in response to an event that a data-sourcecontrol fires when a control to which the data-source control is bound modifies or attempts to modify theunderlying cursor.OnGetDlgCode Called for a control so the control can process arrow-key and TAB-key input itself.OnMeasureItem Called for an owner-draw child combo box, list box, or menu item when the control is created. CWnd informsWindows of the dimensions of the control.SendChildNotifyLastMsg Provides a notification message to a child window,from the parent window, so the child window can handle a task.ReflectChildNotify Helper function which reflects a message to its source.OnWndMsgIndicates if a windows message was handled.Input Message Handlers ReflectLastMsgReflects the last message to the child window.OnVKeyToItemCalled by a list box owned by CWnd in response to a WM_KEYDOWN message.OnCharCalled when a keystroke translates to a nonsystem character.OnDeadCharCalled when a keystroke translates to a nonsystem dead character (such as accent characters).OnHScroll Called when the user clicks the horizontal scroll bar of CWnd .OnKeyDownCalled when a nonsystem key is pressed.OnKeyUpCalled when a nonsystem key is released.OnLButtonDblClk Called when the user double-clicks the left mouse button.OnLButtonDown Called when the user presses the left mouse button.OnLButtonUpCalled when the user releases the left mouse button.OnMButtonDblClkCalled when the user double-clicks the middle mouse button.OnMButtonDownCalled when the user presses the middle mouse button.OnMButtonUpCalled when the user releases the middle mouse button.OnMouseActivateCalled when the cursor is in an inactive window and the user presses a mouse button.OnMouseMove Called when the mouse cursor moves.OnMouseWheel Called when a user rotates the mouse wheel. Uses Windows NT 4.0 message handling.OnRegisteredMouseWheel Called when a user rotates the mouse wheel. Uses Windows 95 and Windows NT 3.51 message-handling.OnRButtonDblClkCalled when the user double-clicks the right mouse button.OnRButtonDownCalled when the user presses the right mouse button.OnRButtonUp Called when the user releases the right mouse button.OnSetCursor Called if mouse input is not captured and the mouse causes cursor movement within a window.OnTimerCalled after each interval specified in SetTimer .OnVScroll Called when the user clicks the window’s vertical scrollNonclient-Area Message Handlers bar.OnCaptureChanged Sends a message to the window that is losing themouse capture.OnNcActivate Called when the nonclient area needs to be changedto indicate an active or inactive state. OnNcCalcSize Called when the size and position of the client areaneed to be calculated.OnNcCreate Called prior to OnCreate when the nonclient area isbeing created.OnNcDestroy Called when the nonclient area is being destroyed. OnNcHitTest Called by Windows every time the mouse is moved ifCWnd contains the cursor or has captured mouseinput with SetCapture.OnNcLButtonDblClk Called when the user double-clicks the left mousebutton while the cursor is within a nonclient area ofCWnd.OnNcLButtonDown Called when the user presses the left mouse buttonwhile the cursor is within a nonclient area of CWnd. OnNcLButtonUp Called when the user releases the left mouse buttonwhile the cursor is within a nonclient area of CWnd. OnNcMButtonDblClk Called when the user double-clicks the middlemouse button while the cursor is within a nonclientarea of CWnd.OnNcMButtonDown Called when the user presses the middle mousebutton while the cursor is within a nonclient area ofCWnd.OnNcMButtonUp Called when the user releases the middle mousebutton while the cursor is within a nonclient area ofCWnd.OnNcMouseMove Called when the cursor is moved within a nonclientarea of CWnd.OnNcPaint Called when the nonclient area needs painting. OnNcRButtonDblClk Called when the user double-clicks the right mousebutton while the cursor is within a nonclient area ofCWnd.OnNcRButtonDown Called when the user presses the right mousebutton while the cursor is within a nonclient area ofCWnd.OnNcRButtonUp Called when the user releases the right mousebutton while the cursor is within a nonclient area ofCWnd.MDI Message HandlersClipboard Message HandlersMenu Loop Notification CWnd Overview | Base Class Members | Hierarchy Chart Send feedback to MSDN.Look here for MSDN Online resources.OnMDIActivateCalled when an MDI child window is activated or deactivated.OnAskCbFormatNameCalled by a Clipboard viewer application when a Clipboard owner will display the Clipboard contents.OnChangeCbChainNotifies that a specified window is being removed from the chain.OnDestroyClipboardCalled when the Clipboard is emptied through a call to the Windows EmptyClipboard function.OnDrawClipboardCalled when the contents of the change.OnHScrollClipboard Called when a Clipboard owner should scroll the Clipboard image, invalidate the appropriate section,and update the scroll-bar values.OnPaintClipboard Called when the client area of the Clipboard viewer needs repainting.OnRenderAllFormats Called when the owner application is being destroyed and needs to render all its formats.OnRenderFormat Called for the Clipboard owner when a particular format with delayed rendering needs to be rendered.OnSizeClipboard Called when the size of the client area of the Clipboard-viewer window has changed.OnVScrollClipboardCalled when the owner should scroll the Clipboard image, invalidate the appropriate section, and update the scroll-bar values.OnEnterMenuLoopCalled when a menu modal loop has been entered.OnExitMenuLoop Called when a menu modal loop has been exited.。