Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Custom Control vs. Owner Draw Control?

Custom Control vs. Owner Draw Control?

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiographicshelptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sawerr
    wrote on last edited by
    #1

    Hi Custom Draw, Owner Draw, Custom Control, Owner Draw Control... Overriding DrawItem() Method, Overriding OnPaint() Method, OnCustomDraw() Method, WM_CTLCOLOR Handler, adding custom control which is in toolbox and "Custom Control DLL"... I started to search control development in MFC to learn how to write (stylish)controls but it seems that it will be difficult and confused... I have basic 2 questions, if you help me to find answers i will be very glad. 1-) In Terminology, are "custom control" and "owner draw control" same things? If not, i understand that custom control means that writing "custom control dll" and overriding OnPaint() method and this control will be reusable in other projects. But owner draw control means changing controls color for that solution and we only override DrawItem() method. Am i right? 2-) As seen and i am correct, there are many ways to draw a control with different style and colors. If i want to make a button with gradient color and want to add it in Toolbox to use in different projects and there will be 2 color options that developer will adjust for drawing button in properties window when add it to form and select it. Which way must i choose? What must be the roadmap? Thanks..

    R J 2 Replies Last reply
    0
    • S sawerr

      Hi Custom Draw, Owner Draw, Custom Control, Owner Draw Control... Overriding DrawItem() Method, Overriding OnPaint() Method, OnCustomDraw() Method, WM_CTLCOLOR Handler, adding custom control which is in toolbox and "Custom Control DLL"... I started to search control development in MFC to learn how to write (stylish)controls but it seems that it will be difficult and confused... I have basic 2 questions, if you help me to find answers i will be very glad. 1-) In Terminology, are "custom control" and "owner draw control" same things? If not, i understand that custom control means that writing "custom control dll" and overriding OnPaint() method and this control will be reusable in other projects. But owner draw control means changing controls color for that solution and we only override DrawItem() method. Am i right? 2-) As seen and i am correct, there are many ways to draw a control with different style and colors. If i want to make a button with gradient color and want to add it in Toolbox to use in different projects and there will be 2 color options that developer will adjust for drawing button in properties window when add it to form and select it. Which way must i choose? What must be the roadmap? Thanks..

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2
      1. Good question. To my understanding, custom controls usually have customized functionalities, which are not necessarily another layout or skinning. Owner drawn is when you change how the things look like, but not necessarily change the functionality. But you can mix the two of them. I think that custom controls are not necessarily owner drawn, while owner drawn are usually customs. :| 2) You can use both ways. Search for article about Buttons here on CP, and make your choice.
      1 Reply Last reply
      0
      • S sawerr

        Hi Custom Draw, Owner Draw, Custom Control, Owner Draw Control... Overriding DrawItem() Method, Overriding OnPaint() Method, OnCustomDraw() Method, WM_CTLCOLOR Handler, adding custom control which is in toolbox and "Custom Control DLL"... I started to search control development in MFC to learn how to write (stylish)controls but it seems that it will be difficult and confused... I have basic 2 questions, if you help me to find answers i will be very glad. 1-) In Terminology, are "custom control" and "owner draw control" same things? If not, i understand that custom control means that writing "custom control dll" and overriding OnPaint() method and this control will be reusable in other projects. But owner draw control means changing controls color for that solution and we only override DrawItem() method. Am i right? 2-) As seen and i am correct, there are many ways to draw a control with different style and colors. If i want to make a button with gradient color and want to add it in Toolbox to use in different projects and there will be 2 color options that developer will adjust for drawing button in properties window when add it to form and select it. Which way must i choose? What must be the roadmap? Thanks..

        J Offline
        J Offline
        Joe Woodbury
        wrote on last edited by
        #3

        owner drawn means that the underlying control provides a mechanism to allow you to draw display elements. custom controls are where you either write a control from scratch or override functionality in a base control, usually through preclassing, subclassing or reflection. (If using MFC, you can just override some virtual functions, several of which do one of the previous things.)

        Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

        S 1 Reply Last reply
        0
        • J Joe Woodbury

          owner drawn means that the underlying control provides a mechanism to allow you to draw display elements. custom controls are where you either write a control from scratch or override functionality in a base control, usually through preclassing, subclassing or reflection. (If using MFC, you can just override some virtual functions, several of which do one of the previous things.)

          Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          S Offline
          S Offline
          sawerr
          wrote on last edited by
          #4

          In MSDN: NM_CUSTOMDRAW: This message is sent by some common controls to notify their parent windows about drawing operations WM_DRAWITEM: This message is sent to the owner window of an owner-drawn button or menu when a visual aspect of the button or menu has changed. Is there a difference between override CustomDraw method and DrawItem method?

          J 1 Reply Last reply
          0
          • S sawerr

            In MSDN: NM_CUSTOMDRAW: This message is sent by some common controls to notify their parent windows about drawing operations WM_DRAWITEM: This message is sent to the owner window of an owner-drawn button or menu when a visual aspect of the button or menu has changed. Is there a difference between override CustomDraw method and DrawItem method?

            J Offline
            J Offline
            Joe Woodbury
            wrote on last edited by
            #5

            NM_CUSTOMDRAW is used by the common controls library. WM_DRAWITEM is for basic windows controls. They are logically the same thing. DrawItem() handles WM_DRAWITEM messages. There is no CustomDraw() method for any MFC classes. If such a method exists, you, or a third party, added it. A guess would be that it handled NM_CUSTOMDRAW messages, but if not documented, you'd have to examine the actual parameters and even the message map.

            Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups