gdiplus环境的初始化,在头文件
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment(lib, "gdiplus.lib")
定义两个成员变量
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
构造函数里
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
析构函数里
GdiplusShutdown(gdiplusToken);
实现代码
///////////////////Gdiplus与Gdi混合实现双缓冲////////////////////
HDC hMemDC = CreateCompatibleDC(m_hDC);
HBITMAP hMemBitmap = CreateCompatibleBitmap(m_hDC, DEFAULT_STATUS_WIDTH, DEFAULT_STATUS_HEIGHT);
SelectObject(hMemDC, hMemBitmap);
Graphics *memGraphics = new Graphics(hMemDC);
Pen pen(Color(192, 192, 192));
SolidBrush brush(Color(255, 255, 255));
memGraphics->FillRectangle(&brush, xPos, yPos, DEFAULT_STATUS_WIDTH, DEFAULT_STATUS_HEIGHT);
memGraphics->DrawRectangle(&pen, xPos, yPos, DEFAULT_STATUS_WIDTH, DEFAULT_STATUS_HEIGHT);
for (int i = 0; i < SMALL_IMAGE_COUNT; i++)
{
DrawImageFromId(memGraphics, imgID[i], imgXPos[i], imgYPos[i]);
}
DeleteObject(hMemBitmap);
BitBlt(m_hDC, xPos, yPos, DEFAULT_STATUS_WIDTH, DEFAULT_STATUS_HEIGHT, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
delete memGraphics;
迁移2011-05-08