Ejemplo n.º 1
0
void MfcViewAdapter::onDraw(CDC* pDC)
{
    _coreView->setScreenDpi(pDC->GetDeviceCaps(LOGPIXELSY));
    _coreView->setBkColor(this, pDC->GetBkColor() | 0xFF000000);

    if (_canvas.beginPaint(_wnd->GetSafeHwnd(), pDC->GetSafeHdc())) {
        if (!_canvas.drawCachedBitmap()) {
            _canvas.clearWindow();
            _coreView->drawAll(this, &_canvas);
            // TODO: Fix _canvas.saveCachedBitmap();
        }
        _coreView->dynDraw(this, &_canvas);
        _canvas.endPaint();
    }
}
Ejemplo n.º 2
0
void ondraw(HWND hwnd)
{
    DWORD tick = GetTickCount();

    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);            // 获取重绘消息的句柄数据

    SetBkColor(hdc, GetSysColor(COLOR_WINDOW)); // 设置背景色以便传到画布

    if (_canvas.beginPaint(hwnd, hdc)) {        // 开始在画布上绘制
        if (!_canvas.drawCachedBitmap()) {      // 显示上次保存的内容
            _canvas.clearWindow();              // 使用背景色清除显示
            TestCanvas::test(&_canvas, _tests); // 绘制测试图形
            if ((_tests & 0x400) == 0)          // not testDynCurves
                _canvas.saveCachedBitmap();     // 缓存显示的内容
        }
        dyndraw(&_canvas);                      // 绘制动态图形
        _canvas.endPaint();                     // 结束绘制
    }
    EndPaint(hwnd, &ps);
    tick = GetTickCount() - tick;
}
Ejemplo n.º 3
0
void switchTest(HWND hwnd)
{
    int a[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 
        0x80 | 0x40 | 0x02, 0x100, 0x200, 0x400 };
    int n = sizeof(a)/sizeof(a[0]);
    int i = n;

    while (--i > 0 && a[i] != _tests) ;
    _tests = a[(i + 1) % n];
    regen(hwnd);

    GiGdipCanvas canvas;

    if (canvas.beginPaintBuffered(1024, 768)) {
        TestCanvas::test(&canvas, _tests);

        WCHAR filename[MAX_PATH];
        GetModuleFileNameW(NULL, filename, MAX_PATH);
        wcscpy_s(wcsrchr(filename, L'.'), 5, L".png");
        canvas.save(filename);

        canvas.endPaint();
    }
}