KernelBitmap* SGNameDrag::MakeImage(UINT32 nDepth) { // If there's no current View, or no Spread, then fail. DocView* pView = DocView::GetCurrent(); if (pView == 0) return 0; Spread* pSpread = pView->FindEnclosingSpread(OilCoord(0, 0)); if (pSpread == 0) return 0; // Create a device context for the display. CDC sdc; sdc.CreateDC("DISPLAY", 0, 0, 0); // Calculate the size of the rendering and set up the rendering matrix etc. Matrix matConvert; FIXED16 fxScale = 1; INT32 nSel = NameGallery::Instance()->GetSelectedItemCount(); DocRect drClip(0, 0, SG_DefaultNameText, nSel * SG_DefaultSmallIcon); // Work out the destination bitmap's characteristics. double dpi = (double) GetDeviceCaps(sdc.m_hDC, LOGPIXELSX); if (nDepth == 0) nDepth = GetDeviceCaps(sdc.m_hDC, BITSPIXEL) * GetDeviceCaps(sdc.m_hDC, PLANES); // Create a render region with the given properties of the display etc. GRenderBitmap* pRenderer = new GRenderBitmap(drClip, matConvert, fxScale, nDepth, dpi); ERRORIF(pRenderer == 0, _R(IDE_NOMORE_MEMORY), 0); pRenderer->AttachDevice(pView, &sdc, pSpread); pRenderer->StartRender(); pRenderer->SaveContext(); // Blank the background. pRenderer->SetLineWidth(0); pRenderer->SetLineColour(COLOUR_WHITE); pRenderer->SetFillColour(COLOUR_WHITE); pRenderer->DrawRect(&drClip); // Render the item's name. DocColour dcText(COLOUR_BLACK), dcBack(COLOUR_WHITE); pRenderer->SetFixedSystemTextColours(&dcText, &dcBack); String_256 strName; m_pSourceItem->GetNameText(&strName); pRenderer->DrawFixedSystemText(&strName, drClip); // Create a kernel bitmap from the OIL bitmap and return it. pRenderer->RestoreContext(); pRenderer->StopRender(); OILBitmap* pOilMaskBmp = pRenderer->ExtractBitmap(); delete pRenderer; KernelBitmap* pkb = new KernelBitmap(pOilMaskBmp, TRUE); ERRORIF(pkb == 0, _R(IDE_NOMORE_MEMORY), 0); return pkb; }
VOID CColorPage::OnPaint() { CRect rcBack, rcGrid; CPaintDC dc(this); CPaintDC dcBack(&BackColor()); CPaintDC dcGrid(&GridColor()); rcBack.CopyRect(&(dcBack.m_ps.rcPaint)); rcGrid.CopyRect(&(dcGrid.m_ps.rcPaint)); dcBack.FillSolidRect(&rcBack, m_lBackColor); dcGrid.FillSolidRect(&rcGrid, m_lGridColor); CPropertyPage::OnPaint(); }