Solved

MFC

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…

757 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

21 Experts available now in Live!

Get 1:1 Help Now