PDA

View Full Version : OnPaint() Function


Lippy
03-13-2006, 07:56 PM
I'm programming in C++(MFC) and I've created a Parent Dialog...I then created another Dialog thats a child and I created the classes for it and everything... I noticed that theres no OnPaint() in the Child Dialog class?
So where exactly is this dialog being drawn...?

Melon00
03-13-2006, 09:00 PM
I dont fully understand your question. How do you get the dialog to show up? Why is there no OnPaint() function? Or, where will the dialog pop up on the screen?

hyperbole
03-14-2006, 05:48 PM
The Child object inherits from the Parent object.

What this means is that you have created a method in the Parent object called Paint. If you had defined a new method called Paint in the Child object, it would have overridden the Paint method from the Parent object and when you invoke the Paint method in the Child, it would use its own method. Since you did not override the method, the Child object invokes the method from the Parent and that is where the Child object is being drawn.

You can continue this process as many generations as you want. For example, if you had created the Paint method in a Great Grand Parent object and not overridden teh method in any of the Child objects, when you invoked the Paint method from the Child, it would use the Paint method from it's Great Grand parent (or what ever object with a definition of Paint was closest in the inheritance chain).



.