zoukankan      html  css  js  c++  java
  • Custom draw 和 Owner draw 的区别

    "Custom Draw" is a feature shared by all of Microsoft's common controls, which allows you to interject your own code while the control is drawing itself. In this way, you can customize the appearance of the control, altering it to suit your needs and tastes.

    There have been a number of great articles on custom draw, in the context of various different controls. One of the best is Michael Dunn's "Neat Stuff to do in List Controls Using Custom Draw", which illustrates how to tame an unruly custom draw interface to customize the appearance of aCListCtrl (which is a common listview control). Other examples and a good explanation can be found at MSDN, beginning with the article "Customizing a Control's Appearance Using Custom Draw".

    "Custom Draw" is not the same thing as "Owner Draw". Custom draw notifications are sent out automatically (it's up to you to catch the notifications and process them correctly), whereas for "owner draw", you need to set a style flag (such asLVS_OWNERDRAWFIXED for a list-view control) before the control will send you aWM_DRAWITEM message. In custom draw, the control pretty much draws itself completely, and your code customizes its appearance only here-and-there, whereas for owner draw, you must draweverything, usually in an OnDrawItem handler, even if you want to make the most trivial change. Custom draw is available only for the common controls (like Header controls, List-view controls, Rebar controls, Toolbar controls, ToolTip controls, Trackbar controls, and Tree-view controls) but is not available for the standard (and older) Windows controls (like button controls, combo box controls, list box controls, progress bar controls, static controls, and tab controls); owner draw, on the other hand, is available for all controls.

    You can think of custom draw as a kind of "light-weight" owner draw (Michael Dunn's words), where the control does most of the work, and you modify just a bit of it. In the hierarchy of things, if you like the way a control looks and how it functions, then use the control "as is"; if you like most of the way the control looks and how it functions, then use custom draw; if you don't like the way a control looks but you like how it functions, then use Owner draw; and if you don't like the way it looks or the way it functions, then write your own custom control.

    Here is a diagram showing the general flow of NM_CUSTOMDRAW notification messages for a list control with two items, each with two sub-items (columns): 

    OK. That’s a lot of notification messages. But what’s in it for me? Well, lets compare the advatnages of custom draw over owner draw for ListView controls:

    Owner Draw Custom Draw
    Only works with report-view style Works for any style
    Must do all the drawing yourself Can choose you own drawing, default drawing of combinations of both. You can also change colours and fonts for default drawing.
    Must draw the entire line (including subitems) in one go Can handle sub items individually
     
    http://blog.csdn.net/xiexievv/article/details/6279219
  • 相关阅读:
    如何最快速的找到页面某一元素所绑定的点击事件,并查看js代码
    Python3 实现 JS 中 RSA 加密的 NoPadding 模式
    Python实现京东自动登录
    使用Chrome或Fiddler抓取WebSocket包
    python的ws库功能,实时获取服务器ws协议返回的数据
    js遍历对象所有的属性名称和值
    selenium webdriver 实现Canvas画布自动化测试
    CE教程
    How to Get Text inside a Canvas using Webdriver or Protractor
    HTML <​canvas> testing with Selenium and OpenCV
  • 原文地址:https://www.cnblogs.com/findumars/p/5402949.html
Copyright © 2011-2022 走看看