Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

1 solution

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.
 
Share this answer
 
Comments
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
Thanks
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):
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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900