Beispiel #1
0
void CImageCtrl::OnDraw(
			CDC* pDC, const CRect& rcBounds, const CRect& /*rcInvalid*/)
{
	if (m_bitprop.m_Bitmap.m_hObject != NULL)
	{
		CWindowDC screenDC(NULL);
		CDC dc;
		dc.CreateCompatibleDC(&screenDC);
		CBitmap* pBitmap = dc.SelectObject(&m_bitprop.m_Bitmap);

		int cx(min(rcBounds.Width(), m_bitprop.m_BitmapSize.cx));
		int cy(min(rcBounds.Height(), m_bitprop.m_BitmapSize.cy));

		pDC->BitBlt(rcBounds.left, rcBounds.top, cx, cy, &dc, 0, 0, SRCCOPY);
		if (cx < rcBounds.Width())
			pDC->PatBlt(cx, rcBounds.top, rcBounds.Width() - cx, rcBounds.Height(), BLACKNESS);
		if (cy < rcBounds.Height())
			pDC->PatBlt(rcBounds.left, cy, rcBounds.Width(), rcBounds.Height() - cy, BLACKNESS);

		if (!IsOptimizedDraw())
		{
			// The container does not support optimized drawing.
			// So, we'll have to clean up what we did to the DC

			dc.SelectObject(pBitmap);
		}
	}
	else
	{
		pDC->PatBlt(rcBounds.left, rcBounds.top,
					rcBounds.Width(), rcBounds.Height(), BLACKNESS);
	}

}
Beispiel #2
0
void CXCardOCXCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	// TODO: Replace the following code with your own drawing code.
	pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
	pdc->Ellipse(rcBounds);

	if (!IsOptimizedDraw())
	{
		// The container does not support optimized drawing.

		// TODO: if you selected any GDI objects into the device context *pdc,
		//		restore the previously-selected objects here.
		//		For more information, please see MFC technical note #nnn,
		//		"Optimizing an ActiveX Control".
	}
}
Beispiel #3
0
void CEasyPDFCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	if (!pdc)
		return;

	// TODO: 用您自己的绘图代码替换下面的代码。
	/*pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
	pdc->Ellipse(rcBounds);*/
	if (!IsOptimizedDraw())
	{
		// 容器不支持优化绘图。

		// TODO: 如果将任何 GDI 对象选入到设备上下文 *pdc 中,
		//		请在此处恢复先前选定的对象。
		
	}
}