Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows MFC VC10.0
GetDeviceCaps(HORZRES);
and
GetDeviceCaps(VERTRES);
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 2:29am
nbd09389

1 solution

Rate this: bad
good
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.
  Permalink  
Comments
nbd09 at 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
Thanks
Hans Dietrich at 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):
http://www.amazon.com/Programming-Windows-Microsoft-Charles-Petzold/dp/157231995X/
 
Two very good basic MFC books:
http://www.amazon.com/Programming-Windows-Second-Jeff-Prosise/dp/1572316950/
http://www.amazon.com/Professional-MFC-Visual-C-6/dp/1861000154/
 
A more advanced MFC book:
http://www.amazon.com/MFC-Internals-Microsoft-Foundation-Architecture/dp/0201407213/
 
Intermediate to advanced GDI book:
http://www.amazon.com/Windows-Graphics-Programming-Hewlett-Packard-Professional/dp/0130869856/
 
Finally, don't forget that reading code - like in the articles published here - is a great way to learn.
 
Good luck.
nbd09 at 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)



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 2 Apr 2011
Copyright © CodeProject, 1999-2014
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