Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Diff Betwn CClientDC & CWindowDC??

Posted on 1999-07-19
Medium Priority
Last Modified: 2013-11-20
What is the difference between MFC classes "CClientDC" and "CWindowDC"??? Both the classes are derived from CWnd and have a protected "hWnd" member variable(afxwin.h). What scenario suits the usage of which class????

Question by:kbsha
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

rayb earned 300 total points
ID: 1310428
CClientDC by default only includes the client area of your window while CWindowDC contains the non-client area as well.


Expert Comment

ID: 1310429
clientdc is the area returns from
and Windowsdc
is what returns from GetWindowRect() including the statusbar and the toolbar and menu area
LVL 23

Expert Comment

ID: 1310430
CClientDC objects encapsulate working with a device context that represents only the client area of a window. The CClientDC constructor calls the GetDC function, and the destructor calls the ReleaseDC function. CWindowDC objects encapsulate a device context that represents the whole window, including its frame. A CWindowDC object accesses the entire screen area of a CWnd (both client and nonclient areas).

CClientDC creates a a client area DC that can be used outside OnPaint. Means its scope is not limited to OnPaint function. you can call it in any function when you want to to do drawing operation for that window. e.g. In button down messages..

You can make use of CwindowDC for drawing operation on client as well as non-client ares of the window like title bar, borders. This is most commonly used when u want to draw on non-client areas e.g. cutomized title bars :) But the best approach for this situation is handling WM_NCPAINT maessage.


Author Comment

ID: 1310431
Comments from naveenkohli were really elobarative. Thanks for all of u....

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

721 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