MFC OnPaint与DrawItem [英] MFC OnPaint vs DrawItem

查看:515
本文介绍了MFC OnPaint与DrawItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试使用不同的外观来推导我自己的MFC组件。我想知道为各种组件(CButton,CListBox,CWnd,CListBox,...)重写 OnPaint() DrawItem 之间有什么区别,以及如何选择他们之间...



提前完成,

JK

Hi,

I am trying to derive my own MFC components with different appearence. I would like to know what is the difference between overriding OnPaint() and DrawItem for various compoents (CButton, CListBox, CWnd, CListBox, ...) and how to choose between them...

Thanx in advance,
J.K.

推荐答案

在某种控件(如列表框)的情况下,WM_PAINT消息被分解(由窗口或框架)到零或多个OnDrawItem / WM_DRAWITEM消息。通常,OnPaint / WM_PAINT可能包含零个或多个OnDrawItem / WM_DRAWITEM消息(以及其他绘图活动)。如果只想影响单个项目的外观(例如在列表框中),则始终使用OnDrawItem / WM_DRAWITEM。这样你就不会拉动控件的其他部分(比如border),你可以为控件留出更多的自由来实现控件其他部分的绘制(border / header / ...),通常它更容易使用OnDrawItem当它可用时。
In case of some kind of control (like listboxes) the WM_PAINT message is broken down (either by windows or by your framework) into zero or more OnDrawItem/WM_DRAWITEM messages. In general your OnPaint/WM_PAINT may contain zero or more OnDrawItem/WM_DRAWITEM messages (among other drawing activities). When you want to influence only the appearance of a single item (for example in a listbox) then always use OnDrawItem/WM_DRAWITEM. This way you are not owerdrawing other parts of the control (like border) and you leave more freedom for the control to implement the drawing of other parts of the control (border/header/...) and usually its much easier to use OnDrawItem when its available.


这篇关于MFC OnPaint与DrawItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆