Click here to Skip to main content
13,046,045 members (45,854 online)
Rate this:
Please Sign up or sign in to vote.
doesnot return the exact size of the device context it returns the resolution of my whole screen
how to get only the area of device context where we can draw
Posted 2-Apr-11 1:29am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Usually in an OnPaint() handler you will call BeginPaint(). This fills the PAINTSTRUCT structure with painting info, including the rcPaint RECT.

Another very common way is to simply call GetClientRect(), which returns the RECT for the entire client area of a control.
nbd09 2-Apr-11 9:08am
thanks the getclientrect works well
can you please suggest a good book for mfc gdi
and another for good mfc refernce
Hans Dietrich 2-Apr-11 10:43am
Most of these books are available used, very cheap. The fundamentals of MFC have not changed that much since VS6, so don't think that these books are obsolete. What has changed in MFC are some new controls, that you will find described on the internet. Another thing to consider if you really want to understand MFC: it is a thin wrapper of many Win32 functions, including GDI. Quickly reading through the Petzold book will give you a feel for what GDI is, and how MFC wraps its functions.

Petzold - every Windows programmer should read this at least once (non-MFC):

Two very good basic MFC books:

A more advanced MFC book:

Intermediate to advanced GDI book:

Finally, don't forget that reading code - like in the articles published here - is a great way to learn.

Good luck.
nbd09 2-Apr-11 15:37pm
thanks for so much of useful information

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 2 Apr 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100