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

发表评论

电子邮件地址不会被公开。 必填项已用*标注

鄂ICP备17003086号. Copyright © 2016. All Rights Reserved.