CClientDC

T

Tony Johansson

Hello!

The CClientDC class is derived from CDC and takes care of calling the
Windows functions GetDC at construction time and ReleaseDC at destruction
time. This means that the device context associated with a CClientDC object
is the client area of a window.

The rows above is from the documentation of CClientDC.

I just wonder what does the last line mean it says "This means that the
device context associated with a CClientDC object is the client area of a
window".

//Tony
 
D

Doug Harrison [MVP]

Hello!

The CClientDC class is derived from CDC and takes care of calling the
Windows functions GetDC at construction time and ReleaseDC at destruction
time. This means that the device context associated with a CClientDC object
is the client area of a window.

The rows above is from the documentation of CClientDC.

I just wonder what does the last line mean it says "This means that the
device context associated with a CClientDC object is the client area of a
window".

It means the surface area onto which you can paint with this DC is mapped
one-to-one onto the client area of the window you specified when you
created the DC. That said, normally you don't use CClientDC for painting,
which you do in response to WM_PAINT, which gives you a DC to paint on.
Instead, CClientDC is useful when you need to, say, calculate window size
based on font height or text width. With a CClientDC, you can select a font
into the DC, use GetTextMetrics or GetTextExtent or even
DrawText(DT_CALCRECT), and perform calculations based on the font the
window will use to draw text.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top