Wednesday, May 04, 2005

Double-Buffered Drawing

Double-buffered drawing has been around for a long time. I won't try to improve on any on the tutorials and examples out there, which are probably better than anything I could do anyway.

This is just a post to show some example code for how to do this in Windows CE. The principles remain the same:

  1. Create an off-screen buffer
  2. Draw in the off-screen buffer
  3. Copy the buffer to system (or graphics) memory
Source snippets:
// Create an off-screen buffer to draw in
CDC dcOffScreen;
CBitmap bmpOffScreen;
rect.Width(), rect.Height());

CBitmap* pOldBmp =

// Set the pointer to the up or down bitmap (if it exists)
if (state & ODS_SELECTED)
pBmp = (m_bmpDn.m_hObject ? &m_bmpDn : &m_bmpUp);
pBmp = &m_bmpUp;

// Draw whichever bitmap the pointer is set to
TransparentImage(pDC->GetSafeHdc(), /* hdcDest */
pRect->left, pRect->top,
bmpInfo.bmWidth, bmpInfo.bmHeight, /* dest */
(HBITMAP) bmp, /* hdcSrc */
0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, /* src */

// Blit the off-screen DC back over to the button DC
pDC->BitBlt(rect.left,, rect.Width(),
rect.Height(), &dcOffScreen, 0, 0, SRCCOPY);


At 7/19/2006 1:40 AM, Anonymous Anonymous said...

What a great site

At 3/17/2007 7:35 AM, Anonymous Anonymous said...

What a great site film editing classes

At 4/24/2007 8:01 AM, Anonymous Anonymous said...

Very nice site! tax code Aqua filter imc Culinary school mexico Business insurance company rhode island American journal nursing online

At 11/09/2009 4:25 PM, Anonymous Anonymous said...

viagra jelly viagra and cannabis try viagra for free viagra free trial how to get viagra cheap herbal viagra viagra australia cialis v s viagra legal viagra female use of viagra buying viagra online viagra online no prescription viagra patent viagra doseage

At 1/21/2010 11:25 PM, Anonymous Anonymous said...

I just found the website who reviews about
home based business reviews

If you want to know more here it is
home business reviews

At 11/18/2012 5:44 AM, Anonymous Anonymous said...

xanax online xanax for social anxiety reviews - xanax pills effects


Post a Comment

<< Home