Device Context 小结
来源:互联网 发布:数据分析与预测 编辑:程序博客网 时间:2024/06/06 07:49
Windows在一些事件发生时,会将窗体的client部分至为无效,并发送WM_PAINT消息,比如:
1 A previously hidden area of the window is brought into view when a user moves a window or uncovers a window.
2 The user resizes the window (if the window class style has the CS_HREDRAW and CW_VREDRAW bits set).
3 The program uses the ScrollWindow or ScrollDC function to scroll part of its client area.
4 The program uses the InvalidateRect or InvalidateRgn function to explicitly generate a WM_PAINT message.
这些消息可能直接发送到window procedure,也可能放入消息队列。
Windows对于WM_PAINT消息必须处理,但如果在Windows处理一个WM_PAINT消息时,又有新的WM_PAINT消息进入消息队列,
也就是又有新的client area变为无效区域,那么,Windows会把新旧无效区域合并成一个新的无效区域。
有时候,Windows不做合并,在把新的消息放入消息队列后就等待window procedure自行处理了。
Windows在上述1-3的情况下,将自动使用wndclass.hbrBackground属性指定的背景色来将无效区域擦“干净“,并发送WM_PAINT消息。
在这之后,如果window procedure对于WM_PAINT消息的处理使用了BeginPaint (hwnd, &ps) ;来将整个client area(不只无效区域)重新变为有效,那么由于Windows已经擦过无效区域,因此,BeginPaint的&ps指向的PAINTSTRUCT结构的fErase参数将为FALSE。
如果使用第4种方法由用户程序指定无效区域时,使用了InvalidateRect (hwnd, NULL, TRUE/FALSE)。
则无效区域是否擦除将由InvalidateRect的最后一个参数指定:
TRUE->BeginPaint会擦出无效区域的内容;BeginPaint调用后PAINTSTRUCT结构的fErase参数将为FALSE;
FALSE->BeginPaint会保留无效区域的内容;BeginPaint调用后PAINTSTRUCT结构的fErase参数将为TRUE。
另一个重要问题是:clipping region。这个概念是指可以描画或输出文字的区域。
这个与invalid region不同。
当调用hdc = BeginPaint (hwnd, &ps) ;获得Device Context的指针时clipping region就是invalid region;
当调用hdc = GetDC (hwnd) ;获得Device Context的指针时,clipping region是整个client area。即可以在整个用户区任意描画。
device context可以设置mapping mode,即logic coordinates如何转换到physical coordinates;
在不同的mapping mode下,GetTextMetrics返回的字体大小的数值和单位会有变化,如1pixel,2mm,
虽然用不同 mapping mode单位下表示的字体大小的数值不同,字体的实际大小是确定的,
字体实际大小只取决于显示器分辩率(如1024X768)和所选择的Font(如System Font)。
- Device Context 小结
- device context
- rendering context和Device context
- Context小结
- The Device Context
- DC Device Context
- Device Context Types
- Writing Solaris Device Driver: Device Context Management
- Device context overview- wxWidgets wxPython
- Win32 Series - The Device Context
- android Context小结
- android application context 小结
- 怎样理解DC(device context) 这个词
- Device Context 设备环境 设备上下文 理解
- Device Context 设备环境 设备上下文 理解
- Device Context 设备环境 设备上下文 理解
- windows device driver 小结感想
- 两种获得Device Context方法的区别
- Start ...
- 编译时RAM超了的简单解决办法
- 中国区2010第4季度安全威胁报告
- 关于ie下阻止ActiveX控件
- 现西第二册 1 惯用词组
- Device Context 小结
- JCL Study
- 关于Python的下载问题
- sql-mode可以设置警告级别,如默认值不能为空的不能提交==
- 使用JS和HttpWatch监控携程网低价机票信息(非广告纯代码)
- 使用trace_sql跟踪用户sql
- SDL的C++程序框架
- SDL的FreeBASIC程序框架
- 使用python打开网页