void CBfDrawButton::DrawFocus() { if (IsInFocus()) { CRect WndRect(0, 0, 0, 0), OutRect(0, 0, 0, 0), InRect(0, 0, 0, 0); WndRect = m_WndRect; OutRect = WndRect; OutRect.left++; OutRect.top++; OutRect.right -= 2; OutRect.bottom -= 2; Pen Pn1(Color(150, 68, 198, 247)); RectF GRt = CUiMethod::CRect2RectF(OutRect); m_pDoGrap->DrawRectangle(&Pn1, GRt); InRect = OutRect; InRect.left++; InRect.top++; InRect.right--; InRect.bottom--; Pen Pn2(Color(100, 133, 188, 203)); GRt = CUiMethod::CRect2RectF(InRect); m_pDoGrap->DrawRectangle(&Pn2, GRt); } }
// This function init DC. // set the default parameters. static void dc_InitDC(PDC pdc, HWND hWnd, BOOL bIsClient) { PCONTROL pCtrl; pdc->hwnd = hWnd; pdc->gc = PHYSICALGC; pdc->bkcolor = PIXEL_lightwhite; pdc->bkmode = 0; pdc->brushtype = BT_SOLID; pdc->brushcolor = PIXEL_lightwhite; pdc->BrushOrig.x = pdc->BrushOrig.y = 0; pdc->pentype = PT_SOLID; pdc->pencolor = PIXEL_black; pdc->CurPenPos.x = pdc->CurPenPos.y = 0; pdc->textcolor = PIXEL_black; if (!(pdc->pLogFont = GetWindowFont (hWnd))) pdc->pLogFont = GetSystemFont (SYSLOGFONT_WCHAR_DEF); pdc->tabstop = 8; pdc->CurTextPos.x = pdc->CurTextPos.y = 0; pdc->cExtra = pdc->alExtra = pdc->blExtra = 0; pdc->mapmode = MM_TEXT; pdc->ViewOrig.x = pdc->ViewOrig.y = 0; pdc->ViewExtent.x = pdc->ViewExtent.y = 1; pdc->WindowOrig.x = pdc->WindowOrig.y = 0; pdc->WindowExtent.x = pdc->WindowExtent.y = 1; // assume that the local clip region is empty. // Get global clip region info and generate effective clip region. pdc->pGCRInfo = GetGCRgnInfo (hWnd); pthread_mutex_lock (&pdc->pGCRInfo->lock); pdc->oldage = pdc->pGCRInfo->age; ClipRgnCopy (&pdc->ecrgn, &pdc->pGCRInfo->crgn); if (bIsClient) WndClientRect (pdc->hwnd, &pdc->DevRC); else WndRect (pdc->hwnd, &pdc->DevRC); pdc->bIsClient = bIsClient; if (bIsClient) IntersectClipRect (&pdc->ecrgn, &pdc->DevRC); pCtrl = Control (pdc->hwnd); if (pCtrl && !(pCtrl->dwExStyle & WS_EX_CTRLASMAINWIN)) RestrictControlECRGN (&pdc->ecrgn, pCtrl); pthread_mutex_unlock (&pdc->pGCRInfo->lock); }
BOOL COXScreenGrabber::GrabFullWindow(CWnd* pWnd /* = NULL */) { CRect WndRect(0, 0, 0, 0); if (!PrepareWindow(FALSE, WndRect, pWnd)) return FALSE; return GrabRectangle(WndRect); }
BOOL dc_GenerateECRgn(PDC pdc, BOOL fForce) { RECT rc, rcInter; PCLIPRECT pcr, pgcr; PCONTROL pCtrl; // is global clip region is empty? if ((!fForce) && (!dc_IsVisible (pdc))) return FALSE; // need regenerate? if (fForce || (pdc->oldage != pdc->pGCRInfo->age)) { EmptyClipRgn (&pdc->ecrgn); pcr = pdc->lcrgn.head; while (pcr) { rc = pcr->rc; coor_LP2SP (pdc, &rc.left, &rc.top); coor_LP2SP (pdc, &rc.right, &rc.bottom); pgcr = pdc->pGCRInfo->crgn.head; while (pgcr) { if (IntersectRect (&rcInter, &rc, &pgcr->rc)) AddClipRect (&pdc->ecrgn, &rcInter); pgcr = pgcr->next; } pcr = pcr->next; } if (pdc->lcrgn.head == NULL) ClipRgnCopy (&pdc->ecrgn, &pdc->pGCRInfo->crgn); // update the DevRC; if (pdc->bIsClient) WndClientRect (pdc->hwnd, &pdc->DevRC); else WndRect (pdc->hwnd, &pdc->DevRC); IntersectClipRect (&pdc->ecrgn, &pdc->DevRC); pCtrl = Control (pdc->hwnd); if (pCtrl && !(pCtrl->dwExStyle & WS_EX_CTRLASMAINWIN)) RestrictControlECRGN (&pdc->ecrgn, pCtrl); pdc->oldage = pdc->pGCRInfo->age; } return TRUE; }
void Draw(HWND hWnd, HDC hdc) { CRect WndRect(0, 0, 0, 0); ::GetClientRect(hWnd, WndRect); HDC hMemoryDC = ::CreateCompatibleDC(hdc); if (hMemoryDC != NULL) { HBITMAP hMemoryBitmap = ::CreateCompatibleBitmap(hdc, WndRect.Width(), WndRect.Height()); if (hMemoryBitmap != NULL) { ::SelectObject(hMemoryDC, hMemoryBitmap); AggDraw(hWnd, hMemoryDC, hMemoryBitmap); ::BitBlt(hdc, 0, 0, WndRect.Width(), WndRect.Height(), hMemoryDC, 0, 0, SRCCOPY); ::DeleteObject(hMemoryBitmap); } ::DeleteDC(hMemoryDC); } }
/* * Function: void GUIAPI ReleaseDC(HDC hDC) * This function release the specified DC. * Parameter: * HDC hDC: The DC handle want to release. * Return: * None. */ void GUIAPI ReleaseDC (HDC hDC) { PMAINWIN pWin; PDC pdc; PCONTROL pCtrl; pdc = dc_HDC2PDC(hDC); EmptyClipRgn (&pdc->lcrgn); pWin = (PMAINWIN)(pdc->hwnd); if (pWin && pWin->privCDC == hDC) { /* for private DC, we reset the clip region info. */ pthread_mutex_lock (&pdc->pGCRInfo->lock); pdc->oldage = pdc->pGCRInfo->age; ClipRgnCopy (&pdc->ecrgn, &pdc->pGCRInfo->crgn); if (pdc->bIsClient) WndClientRect (pdc->hwnd, &pdc->DevRC); else WndRect (pdc->hwnd, &pdc->DevRC); IntersectClipRect (&pdc->ecrgn, &pdc->DevRC); pCtrl = Control (pdc->hwnd); if (pCtrl && !(pCtrl->dwExStyle & WS_EX_CTRLASMAINWIN)) RestrictControlECRGN (&pdc->ecrgn, pCtrl); pthread_mutex_unlock (&pdc->pGCRInfo->lock); } else { EmptyClipRgn (&pdc->ecrgn); pdc->pGCRInfo = NULL; pdc->oldage = 0; pthread_mutex_lock (&dcslot); pdc->inuse = FALSE; pthread_mutex_unlock(&dcslot); } }