Solved

MFC

Posted on 2000-04-01
2
1,025 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FizzBuzz challenge 9 77
Which Microsoft MSDN Package Is The One I need? 3 42
Best way to accomplish this task? 3 86
WPF issue with Trigger 2 96
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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now