[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::visualc

Title:Microsoft Visual C/C++
Moderator:PLUGH::needle
Created:Tue Mar 16 1993
Last Modified:Wed Jun 04 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1121
Total number of notes:4385

1111.0. "CClientDC and CPaintDC" by HGOVC::ANDREWFUNG () Mon Apr 21 1997 01:52

    Hello,
    
    	Can anyone inform me what's the difference between CClientDC and
    CPaintDC, and when to  use each of them ?
    
    Rgds,
    Andrew.
    
T.RTitleUserPersonal
Name
DateLines
1111.1STAR::DZIEDZICTony Dziedzic - DTN 381-2438Mon Apr 21 1997 02:4717
    Did you read the documentation on the two classes?  It seemed
    pretty clear to me.
    
    You use CPaintDC in code which is handling a WM_PAINT message;
    usually in your OnPaint message-handling function.  CPaintDC
    automatically calls BeginPaint and EndPaint (in the class'
    constructor and destructor, respectively).  If you're using
    the MFC doc/view architecture, and have overridden OnDraw,
    OnDraw gets passed a CPaintDC which is all ready to be painted
    into by your OnDraw function.
    
    CClientDC encapsulates a device context which represents the
    client area of a window.  You'd use CClientDC when your code
    needs to draw in a window in "real time" (without waiting for
    a WM_PAINT) - for example, when drawing a "rubber band" line
    in response to mouse movement in the view.  CClientDC calls
    GetDC and ReleaseDC (at construction and destruction).