Custom Control vs. Owner Draw Control?
-
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..
-
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..
- 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.
-
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..
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
-
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
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?
-
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?
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