bool CurseGUIPicture::SetAutoAlloc(bool a) { SCTriple fill; fill.r = 0; fill.g = 0; fill.b = 0; //free memory if auto-allocated if (autoalloc && pict) { free(pict); pict = NULL; } //set new flag autoalloc = a; //allocate memory if (a) { pict = (SGUIPixel*)malloc(length); if (!pict) { autoalloc = false; return false; } ColorFill(fill); } //All operations are completed successfully return true; }
BOOL __stdcall pvdDisplayPaint2(void *pContext, void* pDisplayContext, pvdInfoDisplayPaint2* pDisplayPaint) { _ASSERTE(pDisplayPaint->cbSize >= sizeof(pvdInfoDisplayPaint2)); _ASSERTE(pDisplayContext); BOOL lbRc = FALSE; WmfContext* p = (WmfContext*)pDisplayContext; switch (pDisplayPaint->Operation) { case PVD_IDP_BEGIN: { //if (!BeginPaint(pDisplayPaint->hWnd, &p->ps)) { if (!(p->ps.hdc = GetDC(pDisplayPaint->hWnd))) { pDisplayPaint->nErrNumber = PWE_WIN32_ERROR; gnLastWin32Error = GetLastError(); } else { lbRc = TRUE; } } break; case PVD_IDP_COMMIT: { //EndPaint(pDisplayPaint->hWnd, &p->ps); ReleaseDC(pDisplayPaint->hWnd, p->ps.hdc); lbRc = TRUE; } break; case PVD_IDP_COLORFILL: { ColorFill(p->ps.hdc, pDisplayPaint->DisplayRect, pDisplayPaint->nBackColor); lbRc = TRUE; } break; case PVD_IDP_PAINT: { if (pDisplayPaint->DisplayRect.right == pDisplayPaint->DisplayRect.left || pDisplayPaint->DisplayRect.bottom == pDisplayPaint->DisplayRect.top || pDisplayPaint->ImageRect.right == pDisplayPaint->ImageRect.left || pDisplayPaint->ImageRect.bottom == pDisplayPaint->ImageRect.top ) { ColorFill(p->ps.hdc, pDisplayPaint->DisplayRect, pDisplayPaint->nBackColor); lbRc = FALSE; pDisplayPaint->nErrNumber = PWE_INVALID_RECT; } else { SIZE FullSize = p->PreferredSize; POINT StartPoint = {0,0}; if (pDisplayPaint->ImageRect.left || pDisplayPaint->ImageRect.top || ((pDisplayPaint->DisplayRect.right - pDisplayPaint->DisplayRect.left) != FullSize.cx) || ((pDisplayPaint->DisplayRect.bottom - pDisplayPaint->DisplayRect.top) != FullSize.cy)) { FullSize.cx = (pDisplayPaint->DisplayRect.right - pDisplayPaint->DisplayRect.left) * p->PreferredSize.cx / (pDisplayPaint->ImageRect.right - pDisplayPaint->ImageRect.left); FullSize.cy = (pDisplayPaint->DisplayRect.bottom - pDisplayPaint->DisplayRect.top) * p->PreferredSize.cy / (pDisplayPaint->ImageRect.bottom - pDisplayPaint->ImageRect.top); _ASSERTE(FullSize.cx && FullSize.cy); StartPoint.x = pDisplayPaint->ImageRect.left * FullSize.cx / p->PreferredSize.cx; StartPoint.y = pDisplayPaint->ImageRect.top * FullSize.cy / p->PreferredSize.cy; } if (FullSize.cx != p->CurrentSize.cx || FullSize.cy != p->CurrentSize.cy) { if (!p->CreateComp(p->ps.hdc, FullSize.cx, FullSize.cy)) { pDisplayPaint->nErrNumber = PWE_WIN32_ERROR; gnLastWin32Error = GetLastError(); lbRc = FALSE; } else { RECT rcFill = {0,0,FullSize.cx,FullSize.cy}; ColorFill(p->hCompDC, rcFill, pDisplayPaint->nBackColor); // To stop this function, an application can call the CancelDC function from another thread to terminate the operation. In this case, the function returns FALSE. lbRc = PlayEnhMetaFile(p->hCompDC, p->h, &rcFill); if (!lbRc) { pDisplayPaint->nErrNumber = PWE_WIN32_ERROR; gnLastWin32Error = GetLastError(); } } } if (p->hCompDC) { lbRc = BitBlt(p->ps.hdc, pDisplayPaint->DisplayRect.left, pDisplayPaint->DisplayRect.top, pDisplayPaint->DisplayRect.right - pDisplayPaint->DisplayRect.left, pDisplayPaint->DisplayRect.bottom - pDisplayPaint->DisplayRect.top, p->hCompDC, StartPoint.x, StartPoint.y, SRCCOPY); if (!lbRc) { pDisplayPaint->nErrNumber = PWE_WIN32_ERROR; gnLastWin32Error = GetLastError(); } } } } } return lbRc; }