Solved

MFC

Posted on 2000-04-01
2
1,048 Views
Last Modified: 2013-11-25

We use ON_WM_PAINT() macro  to invoke the handler OnPaint(),similarly we use OnDraw(CDC *pDC) which the MFC frame work calls , what is the basic difference between these to calls ?
0
Comment
Question by:r_sam_14
  • 2
2 Comments
 
LVL 1

Accepted Solution

by:
kkarunakar earned 25 total points
ID: 2676198
Hi There,
I am keshav here from india. I am trying to reply to ur question. Pls do inform ur comment on this.
I will discuss this taking two case..
1.OnDraw():- This is method defined in CView,COleControl,CComControl and all related view class.
And OnPaint() is called for class derived from CWnd. Like ur all controls.Frame work call this method with giving CDC object to the window to draw it self.
And Frame work calls CDraw to invalidate any drawing for corresponding document of view.This is called for prinnt,print preview and screen display with given CDC object.
So u can uderstand the difference.
2. I will give u with example of ActiveX control. The control class of activex contrl has both the functions. OnPaint() and OnDraw().
Framework call OnDraw() function when ur control is in design mode.Since it can't invalidate the window since container is not running..
But Frame work calls OnPaint when container is running and this OnPaint calls OnDraw() with given CDC object.
Hope My answer will make ur doubt clear..
Regards.
Keshav karunakar
kkarunakar@hotmail.com
0
 
LVL 1

Expert Comment

by:kkarunakar
ID: 2684496
Hi Sam
I am fine and hope same to u. I will try my best to answer ur queries and hope u will get more clear figure.
WM_PAINT is a message .So frame work has to send it to the control or parent. For that we need to map the message and thus ON_WM_PAINT message come to existance. But for OnDraw () as I told u earlier also it is not message like WM_PAINT and tell u when it is called.
It is a virtual function and class or object has to overide this function to draw itself. So whenever document want to print or print priview it ..It just calls OnDraw() with specfic CDC Object and and draw itself.
Now I think u r doubt is more clear..
Regards keshav..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
lucky13 challenge 11 157
MaxSpan challenge 9 122
Convert GUI app into console app for Win32 Env 5 125
Why is "packages element is not declared"? 2 448
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question