MFC 基础概念
来源:互联网 发布:时间序列数据聚类分析 编辑:程序博客网 时间:2024/06/06 21:02
msdn原文:(几个消息响应函数的解释)
OnCreate:The framework calls this member function when an application requests that the windows windows be created by calling the Create or CreateEx member function. The CWnd object receives this member function to perform any needed initialization before it becomes visible.
OnSize: The framework calls this member function after the window's size has changed.
OnInitDialog:This member function is called in response to the WM_INITDIALOG message. This message is sent to the dialog box during the Create, CreateIndirect, or DoModal calls, which occur immediately before the dialog box is displayed.
执行过程:onCreate,OnSize,OnInitDialog
OnPaint:
The WM_PAINT message is generated by the system and should not be sent by an application. To force a window to draw into a specific device context, use theWM_PRINT or WM_PRINTCLIENT message. Note that this requires the target window to support theWM_PRINTCLIENT message. Most common controls support the WM_PRINTCLIENT message.
The DefWindowProc function validates the update region. The function may also send theWM_NCPAINT message to the window procedure if the window frame must be painted and send theWM_ERASEBKGND message if the window background must be erased.
The system sends this message when there are no other messages in the application's message queue.DispatchMessage determines where to send the message;GetMessage determines which message to dispatch.GetMessage returns the WM_PAINT message when there are no other messages in the application's message queue, andDispatchMessage sends the message to the appropriate window procedure.
A window may receive internal paint messages as a result of calling RedrawWindow with the RDW_INTERNALPAINT flag set. In this case, the window may not have an update region. An application should call theGetUpdateRect function to determine whether the window has an update region. IfGetUpdateRect returns zero, the application should not call the BeginPaint and EndPaint functions.
An application must check for any necessary internal painting by looking at its internal data structures for eachWM_PAINT message, because a WM_PAINT message may have been caused by both a non-NULL update region and a call toRedrawWindow with the RDW_INTERNALPAINT flag set.
The system sends an internal WM_PAINT message only once. After an internalWM_PAINT message is returned from GetMessage or PeekMessage or is sent to a window by UpdateWindow, the system does not post or send furtherWM_PAINT messages until the window is invalidated or until RedrawWindow is called again with the RDW_INTERNALPAINT flag set.
For some common controls, the default WM_PAINT message processing checks thewParam parameter. If wParam is non-NULL, the control assumes that the value is an HDC and paints using that device context.
对于窗口程序,一般有个特点:窗口大部分的区域保持不变,只有不分区域需要重新绘制。如果将整个窗口全部刷新的画,就做了许多不必要的工作,因而,MFC采用了一套基于无效区的处理机制。在分析无效区处理之前,我们要明白一个现实,现在的机器还不够牛,如果够牛的话,我们干脆将整个窗口不断的重新绘制好了。事实上即使够牛也不行,对于一个单线程程序,通过一个while循环不断的刷新窗口,程序也无法相应其他消息(除非使用多线程),看来使用无效区的处理机制还是有其必然性的。
- MFC 基础概念
- MFC界面编程 之 基础概念
- 基础概念
- 基础概念
- 基础概念
- 基础概念
- 基础概念
- 基础概念
- 基础概念
- 基础概念
- 基础概念
- MFC的一些概念
- MFC-Application framework概念
- (总结之mfc书最后附录)c++基础知识点-概念
- MFC基础
- mfc基础
- MFC基础
- MFC 基础!!
- Android发送汉字到服务器端为乱码解决办法
- Lisa随手记1.8 帮助
- 关于Activity向右滑动销毁的具体实现
- [授权发表]缓冲区溢出与注入分析
- 【C语言】将大写字母换成小写字母输出
- MFC 基础概念
- 关于C语言中feof的使用
- Shiro在web应用中实现验证码功能
- 慎用mysql的enum字段
- tomcat8.0环境下解决get方法中文参数乱码问题
- 从浏览器内核级别修改layout相关的UI行为
- 设计模式学习(十八):状态模式
- 软件开发之心态篇
- Linux-常用命令(2)权限管理命令