Re: CPaintDC class



"Alex Blekhman" <xfkt@xxxxxxxxx> wrote in message
news:OcBU4d65GHA.1188@xxxxxxxxxxxxxxxxxxxx
NickP wrote:
Hi there,

I have some form drawing code that uses the CPaintDC class and
it works fine. But I am just wondering if it is as good as using
BeginPaint and EndPaint.

I know this class calls these 2 methods anyway, but I am unsure
as to whether it takes in for account the invalid rectangle whilst
calling it's BitBlt method.

For example, if I declare "CPaintDC dc(myWindowHandle)" and the
paint event args specify that only a small portion of the entire
surface is to be repainted does BitBlt only paint said region?

------

Let's say only the rectangle (100,100,150,150) needs
repainting.... ------

CPaintDC dc(m_hWnd);
CRect rc; GetClientRect(&rc);

//Clear the buffer
m_memDC.FillRect(&rc,m_bkgrnd);

//Draw to the buffer here
...

//Blit the buffer
dc.BitBlt(rc.left,
rc.top,
rc.right,
rc.bottom,
m_memDC,
rc.left,
rc.top,
SRCCOPY);

------

Does BitBlt actual perform a block copy of the entire rectangle
specified, or only the one that is specified in the paint arguments?


BitBlt is very stupid. It just copies bits from source DC to
destination DC. You can use CPaintDC::m_ps member to figure
out exact paint rectangle.


Stupid or not, BitBlt will not paint outside the invalid region in a
WM_PAINT call. There may be some performance difference when you use the
PAINTSTRUCT variable to clip painting yourself, but I have no information on
that.


--
John Carson


.



Relevant Pages

  • Re: CPaintDC class
    ... I know this class calls these 2 methods anyway, but I am unsure as to whether it takes in for account the invalid rectangle whilst calling it's BitBlt method. ... if I declare "CPaintDC dc" and the paint event args specify that only a small portion of the entire surface is to be repainted does BitBlt only paint said region? ...
    (microsoft.public.vc.language)
  • Re: shape recognition
    ... instead of ANDing each pixel as you ... I was thinking more of using BitBlt to paint the image ...
    (microsoft.public.vb.general.discussion)
  • Re: using CClientDC::BitBlt() to capture only the client window
    ... There are generally 2 types of paint programs, ones that simply draw, like ... to the memory dc with the bitmap selected in it. ... And in the OnPaint method of your view, you would simply bitblt the content ... BitBltto capture the drawing area that is the window of my ...
    (microsoft.public.vc.mfc)
  • Re: Simulate Autoredraw
    ... I personally use the bitblt and it's ligntning ... I would think that an image has to be rendered during each paint ... I was able to figure out to create the graphics from the bitmap, ... and was able to draw to it, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ActiveX control draws outside of its window when IE scrolls?
    ... >> worker thread if you want, but BitBlt it to the screen on the UI ... Post yourself a user-defined message. ... grab the DC with GetDC and paint to your heart's content. ...
    (microsoft.public.vc.atl)