示例#1
0
void SelectionHandler::BitBlt(CDC& offscreenDC)
{
	if (m_selectionState == selstateNoSelection) return;

	COORD	coordStart;
	COORD	coordEnd;
	SHORT	maxX = (m_consoleParams->dwBufferColumns > 0) ? static_cast<SHORT>(m_consoleParams->dwBufferColumns - 1) : static_cast<SHORT>(m_consoleParams->dwColumns - 1);

	GetSelectionCoordinates(coordStart, coordEnd);
	coordStart.X	= 0;
	coordEnd.X		= maxX;

	CRect	selectionRect;
	GetFillRect(coordStart, coordEnd, selectionRect);

	offscreenDC.BitBlt(
					selectionRect.left, 
					selectionRect.top, 
					selectionRect.Width(), 
					selectionRect.Height(), 
					m_dcSelection, 
					selectionRect.left, 
					selectionRect.top, 
					SRCINVERT);
}
示例#2
0
void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
    ASSERT(pDC != NULL);

	HPALETTE hPalette = WFE_GetUIPalette(NULL);
	HPALETTE hOldPalette = ::SelectPalette(lpDrawItemStruct->hDC, hPalette, FALSE);
	::RealizePalette(lpDrawItemStruct->hDC);

    CRect rect;
    GetClientRect(rect);
    int cxClient = rect.Width();
    int cyClient = rect.Height();

    // draw the bitmap contents
    CDC dcMem;
    if (!dcMem.CreateCompatibleDC(pDC))
        return;
    HBITMAP hOldBitmap = (HBITMAP)::SelectObject(dcMem.m_hDC, m_hBitmap);
    if (hOldBitmap == NULL)
        return;

    pDC->BitBlt(0, 0, m_sizeBitmap.cx, m_sizeBitmap.cy, &dcMem, 0, 0, SRCCOPY);

    ::SelectObject(dcMem.m_hDC, hOldBitmap);
	DisplayCopyright();
	::SelectPalette(lpDrawItemStruct->hDC, hOldPalette, TRUE);

    ReleaseDC(pDC);
}
示例#3
0
void CDuiAnimateImage::DrawControl(CDC &dc, CRect rcUpdate)
{
	int nWidth = m_rc.Width();
	int nHeight = m_rc.Height();

	if(!m_bUpdate)
	{
		UpdateMemDC(dc, nWidth * m_nMaxIndex, nHeight);

		Graphics graphics(m_memDC);
		
		CPoint point = GetOriginPoint(nWidth, nHeight, m_sizeImage.cx, m_sizeImage.cy,
						GetGDIAlignment(m_uAlignment), GetGDIVAlignment(m_uVAlignment));

		for(int i = 0; i < m_nMaxIndex; i++)
		{
			m_memDC.BitBlt(i * nWidth, 0, nWidth, nHeight, &dc, m_rc.left ,m_rc.top, SRCCOPY);

			graphics.DrawImage(m_pImage, Rect(point.x , point.y,  m_sizeImage.cx, m_sizeImage.cy),
				i * m_sizeImage.cx, 0, m_sizeImage.cx, m_sizeImage.cy, UnitPixel);

			point.x += nWidth;
		}
	}

	dc.BitBlt(m_rc.left,m_rc.top, m_rc.Width(), m_rc.Height(), &m_memDC, m_nIndex * nWidth, 0, SRCCOPY);
}
示例#4
0
BOOL CommandButton::OnEraseBkgnd(CDC* pDC)
{
	if (m_Bmp.GetSafeHandle() == NULL)
	{
		CRect Rect;
		GetWindowRect(&Rect);
		CWnd *pParent = GetParent();
		ASSERT(pParent);
		pParent->ScreenToClient(&Rect);  //convert our corrdinates to our parents

		//copy what's on the parents at this point
		CDC *pDC = pParent->GetDC();
		CDC MemDC;
		MemDC.CreateCompatibleDC(pDC);
		m_Bmp.CreateCompatibleBitmap(pDC, Rect.Width(), Rect.Height());
		CBitmap *pOldBmp = MemDC.SelectObject(&m_Bmp);
		MemDC.BitBlt(0, 0, Rect.Width(), Rect.Height(), pDC, Rect.left, Rect.top, SRCCOPY);
		MemDC.SelectObject(pOldBmp);
		pParent->ReleaseDC(pDC);
	}
	else //copy what we copied off the parent the first time back onto the parent
	{
		CRect Rect;
		GetClientRect(Rect);
		CDC MemDC;
		MemDC.CreateCompatibleDC(pDC);
		CBitmap *pOldBmp = MemDC.SelectObject(&m_Bmp);
		pDC->BitBlt(0, 0, Rect.Width(), Rect.Height(), &MemDC, 0, 0, SRCCOPY);
		MemDC.SelectObject(pOldBmp);
	}

	return TRUE;
}
示例#5
0
void CUIDesignerView::OnDraw(CDC* pDrawDC)
{
	CUIDesignerDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: 在此处为本机数据添加绘制代码
	CMemDC memDC(*pDrawDC, this);
	CDC* pDC = &memDC.GetDC();

	CRect rectClient;
	GetClientRect(rectClient);
	CPoint point=GetScrollPosition();
	rectClient.OffsetRect(point);
	pDC->FillSolidRect(rectClient,RGB(255, 255, 255));

	CSize szForm=m_LayoutManager.GetForm()->GetInitSize();
	CSize szFormOffset(FORM_OFFSET_X,FORM_OFFSET_Y);
	CDC hCloneDC;
	HBITMAP hNewBitmap;
	hCloneDC.CreateCompatibleDC(pDC);
	hNewBitmap=::CreateCompatibleBitmap(pDC->GetSafeHdc(),szForm.cx,szForm.cy);
	HBITMAP hOldBitmap=(HBITMAP)hCloneDC.SelectObject(hNewBitmap);
	m_LayoutManager.Draw(&hCloneDC);
	pDC->BitBlt(szFormOffset.cx,szFormOffset.cy,szForm.cx,szForm.cy,&hCloneDC,0,0,SRCCOPY);
	hCloneDC.SelectObject(hOldBitmap);
	::DeleteDC(hCloneDC);
	::DeleteObject(hNewBitmap);

	m_MultiTracker.Draw(pDC,&szFormOffset);
}
示例#6
0
void CViewBitmap::Capture(CRect &rect)
{ 
 if(m_pPalette)
 { DeleteObject();
   delete m_pPalette;
 }
 m_width=rect.Width();
 m_heighth=rect.Height();
 double wid=rect.left/1024;
 double hei=rect.top/768;

 CDC dcscreen;
 dcscreen.CreateDC("DISPLAY",NULL,NULL,NULL);
 CDC dcMem;
 dcMem.CreateCompatibleDC( &dcscreen );
 CreateCompatibleBitmap( &dcscreen, m_width, m_heighth );
 dcMem.SelectObject( this );

 dcMem.BitBlt(0,0,m_width, m_heighth,&dcscreen,rect.left,rect.top,SRCCOPY);
// create an empty logical palette that¡¯s big enough to hold all the colors
 int nColors = ( 1 << ( dcscreen.GetDeviceCaps( BITSPIXEL ) *dcscreen.GetDeviceCaps( PLANES ) ) );
 LOGPALETTE *pLogpal=(LOGPALETTE*) new BYTE[sizeof(LOGPALETTE)+(nColors * sizeof(PALETTEENTRY))];
 pLogpal -> palVersion = 0x300;
 pLogpal -> palNumEntries = nColors;
// load this empty palette with the system palette's colors
 GetSystemPaletteEntries( dcscreen.m_hDC, 0, nColors,(LPPALETTEENTRY)(pLogpal->palPalEntry));
 m_pPalette = new CPalette;
 m_pPalette -> CreatePalette( pLogpal );
 delete []pLogpal;
 dcMem.DeleteDC();
 dcscreen.DeleteDC();
}
示例#7
0
void CSkinListBox::OnNcPaint()
{
	//如果资源没有就是不想绘制边框了
	if ( m_pBackImgN == NULL ) 
	{
		__super::OnNcPaint();
		return;
	}

	CRect rcWindow;
	GetWindowRect(&rcWindow);

	CRect rcClient;
	GetClientRect(&rcClient);

	ClientToScreen(&rcClient);
	rcClient.OffsetRect(-rcWindow.left, -rcWindow.top);

	rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top);

	CDC *pWindowDC = GetWindowDC();
	CMemoryDC MemDC(pWindowDC,rcWindow);

	DrawParentWndBg(GetSafeHwnd(),MemDC.GetSafeHdc());

	if (m_pBackImgN != NULL && !m_pBackImgN->IsNull())
		m_pBackImgN->Draw(&MemDC, rcWindow);
	
	pWindowDC->BitBlt(rcWindow.left,rcWindow.top,rcWindow.Width(),rcWindow.Height(),&MemDC,0,0,SRCCOPY);

	ReleaseDC(pWindowDC);
}
void CInstrumentGraph::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CWnd::OnPaint()
	CDC memDC ;
	CBitmap memBitmap ;
	CBitmap* oldBitmap ; // bitmap originally found in CMemDC

	// no real plotting work is performed here, 
	// just putting the existing bitmaps on the client

	// to avoid flicker, establish a memory dc, draw to it 
	// and then BitBlt it to the client
	if (m_bDrawUnit == true)
	{
		return;
	}
	memDC.CreateCompatibleDC(&dc) ;
	memBitmap.CreateCompatibleBitmap(&dc, m_rectClient.Width() - m_iVScrBarInterval, m_rectClient.Height() - m_iHScrBarInterval) ;
	oldBitmap = (CBitmap *)memDC.SelectObject(&memBitmap) ;

	if (memDC.GetSafeHdc() != NULL)
	{
		// first drop the grid on the memory dc
		memDC.BitBlt(0, 0, m_rectClient.Width() - m_iVScrBarInterval, m_rectClient.Height() - m_iHScrBarInterval, 
			&m_dcGraph, m_iHScrPos - m_iLeftMovePos, 0, SRCCOPY) ;
		// finally send the result to the display
		dc.BitBlt(0, 0, m_rectClient.Width() - m_iVScrBarInterval, m_rectClient.Height() - m_iHScrBarInterval, 
			&memDC, 0, 0, SRCCOPY) ;
	}
	memDC.SelectObject(oldBitmap) ;
}
示例#9
0
void CSignalView::OnPaint()
{
    //CPaintDC dc(this); // device context for painting
    GetClientRect(&m_SignalRect);

    if(!m_bUpdateLocal)
    {
        CDC *pDC = GetDC();
        CDC MemDC;
        MemDC.CreateCompatibleDC(NULL);
        CBitmap Memmap;
        Memmap.CreateCompatibleBitmap(pDC , m_SignalRect.Width(),m_SignalRect.Height());
        CBitmap *pOldMap = MemDC.SelectObject(&Memmap);
        ReDrawmap(&MemDC);
        pDC->BitBlt(0,0,m_SignalRect.Width(),m_SignalRect.Height(),&MemDC,0,0,SRCCOPY);
        ReleaseDC(pDC);
        MemDC.SelectObject(pOldMap);
        Memmap.DeleteObject();
        MemDC.DeleteDC();
        m_bUpdateLocal = false;
    }
    else
    {
        CDC *pDC = GetDC();
        if (pDC != NULL)
        {
            DrawMap(pDC, m_NewSignalData.GetData(), m_NewSignalData.GetDataSize());
            ReleaseDC(pDC);
        }
        else
            ReleaseDC(pDC);
        m_bUpdateLocal = TRUE;
    }
    CWnd::OnPaint();
}
示例#10
0
void COBDPNDDlgData::OnPaint()
{
	if (m_dwBkResID !=NULL && m_memdcBkBmp != NULL)
	{
		CClientDC pDC(this);

		CRect rect; 
		CDC   memDC; 

		GetWindowRect(&rect); 	
		memDC.CreateCompatibleDC(&pDC); 	

		CBitmap* pOldMemBmp = NULL; 
		pOldMemBmp = memDC.SelectObject(&m_cBitmapBkBmp);
		memDC.BitBlt(0,0,rect.Width(),rect.Height(),&m_memdcBkBmp,0,0,SRCCOPY);

		memDC.SetBkMode(TRANSPARENT);	
		memDC.SetTextColor(theMainDlg->m_clrTitle);

		//将背景位图复制到窗口客户区 
		pDC.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY); 

		if(pOldMemBmp)   
			memDC.SelectObject(pOldMemBmp); 

		DeleteObject(pOldMemBmp);	
		DeleteDC(memDC);

	}
	CDialog::OnPaint();
}
示例#11
0
//界面绘画函数
void CButtonEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	//定义变量
	CRect rcClient;
	GetClientRect(&rcClient);
	bool bDisable=((lpDrawItemStruct->itemState&ODS_DISABLED)!=0);
	bool bButtonDown=((lpDrawItemStruct->itemState&ODS_SELECTED)!=0);

	CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	//获取文字
	CString strText;
	GetWindowText(strText);
	
	//绘制父窗口背景
	CRect rcWindow;
	CClientDC clDC(GetParent());

	GetWindowRect(rcWindow);
	GetParent()->ScreenToClient(rcWindow);

	CDC dcParent;
	CBitmap bmp,*pOldBitmap;
	dcParent.CreateCompatibleDC(&clDC);
	bmp.CreateCompatibleBitmap(&clDC,rcClient.Width(),rcClient.Height());
	pOldBitmap = dcParent.SelectObject(&bmp);
	dcParent.BitBlt(0,0,rcClient.Width(),rcClient.Height(),&clDC,rcWindow.left,rcWindow.top,SRCCOPY);
	bmp.DeleteObject();

	//加载背景图
	if ( !m_ImageBack.IsNull() )
	{
		//计算位图位置
		int nWidth=m_ImageBack.GetWidth()/4,nDrawPos=0;
		if (bDisable) nDrawPos=nWidth*3;
		else if (bButtonDown) nDrawPos=nWidth*2;
		else if (m_bHovering) nDrawPos=nWidth*1;

		//绘画背景图
		if (m_bExpand==false) m_ImageBack.DrawImage(pDC,0,0,rcClient.Width(),rcClient.Height(),nDrawPos,0);
		else m_ImageBack.DrawImage(pDC,0,0,rcClient.Width(),rcClient.Height(),nDrawPos,0,nWidth,m_ImageBack.GetHeight());
	}
	else
	{
		//绘画默认界面
		pDC->FillSolidRect(&rcClient,GetSysColor(COLOR_BTNFACE));
		if (bButtonDown) pDC->Draw3dRect(&rcClient,GetSysColor(COLOR_WINDOWFRAME),GetSysColor(COLOR_3DHILIGHT));
		else pDC->Draw3dRect(&rcClient,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_WINDOWFRAME));
	}

	//绘画字体
	rcClient.top+=1;
	pDC->SetBkMode(TRANSPARENT);
	if (bDisable) pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
	else pDC->SetTextColor(m_crTextColor);
	pDC->DrawText(strText,strText.GetLength(),rcClient,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

	return;
}
示例#12
0
void CPanelWnd::PaintCaption(CDC& dc)
{
	CString strCaption;
	CRect rc, rcWnd;

	GetWindowRect( &rcWnd );
	rc.SetRect( 0, 0, rcWnd.Width(), CAPTION_HEIGHT );
	GetWindowText( strCaption );

	CDC* pBuffer = CoolInterface.GetBuffer( dc, rc.Size() );

	if ( ! CoolInterface.DrawWatermark( pBuffer, &rc, &Skin.m_bmPanelMark, 0, 0 ) )
	{
		pBuffer->FillSolidRect( &rc, Skin.m_crPanelBack );
	}

	int nIconY = rc.Height() / 2 - 8;
	DrawIconEx( pBuffer->GetSafeHdc(), 4, nIconY,
		GetIcon( FALSE ), 16, 16, 0, NULL, DI_NORMAL );

	CFont* pOldFont	= (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntCaption );
	CSize szCaption	= pBuffer->GetTextExtent( strCaption );

	pBuffer->SetBkMode( TRANSPARENT );

	if ( Skin.m_crPanelBorder != CLR_NONE )
	{
		pBuffer->SetTextColor( Skin.m_crPanelBorder );
		pBuffer->ExtTextOut( 8 + 16 - 1, rc.Height() / 2 - szCaption.cy / 2 - 1,
			ETO_CLIPPED, &rc, strCaption, NULL );
		pBuffer->ExtTextOut( 8 + 16 + 1, rc.Height() / 2 - szCaption.cy / 2 - 1,
			ETO_CLIPPED, &rc, strCaption, NULL );
		pBuffer->ExtTextOut( 8 + 16, rc.Height() / 2 - szCaption.cy / 2 - 1 - 1,
			ETO_CLIPPED, &rc, strCaption, NULL );
		pBuffer->ExtTextOut( 8 + 16, rc.Height() / 2 - szCaption.cy / 2 - 1 + 1,
			ETO_CLIPPED, &rc, strCaption, NULL );
	}

	pBuffer->SetTextColor( Skin.m_crPanelText );
	pBuffer->ExtTextOut( 8 + 16, rc.Height() / 2 - szCaption.cy / 2 - 1,
		ETO_CLIPPED, &rc, strCaption, NULL );

	if ( m_bPanelClose )
	{
		pBuffer->SelectObject( &theApp.m_gdiFont );
		CString strText	= _T("Close");
		CSize szText	= pBuffer->GetTextExtent( strText );

		m_rcClose.SetRect( rc.right - szText.cx - 8, rc.top, rc.right, rc.bottom );
		pBuffer->ExtTextOut( m_rcClose.left + 2,
			( m_rcClose.top + m_rcClose.bottom ) / 2 - szText.cy / 2 - 1,
			ETO_CLIPPED, &m_rcClose, strText, NULL );
		m_rcClose.OffsetRect( rcWnd.left, rcWnd.top );
	}

	pBuffer->SelectObject( pOldFont );

	dc.BitBlt( rc.left, rc.top, rc.Width(), rc.Height(), pBuffer, 0, 0, SRCCOPY );
}
示例#13
0
void ToppyFramework::Draw(CDC* pDC)
{
	CDC* pMemDC = GetDC();


	if (NeedsRepaint())
	{
		m_TheState.Draw(pMemDC);

		CDC osdDC;
		osdDC.CreateCompatibleDC(pDC);
		osdDC.SetBkColor(TRANSPARENT_COLOUR);
		CBitmap bmOsd;
		bmOsd.CreateCompatibleBitmap(pDC, 720, 576);
		osdDC.SelectObject(&bmOsd);
		osdDC.FillSolidRect(0,0,720,576,TRANSPARENT_COLOUR);
		if (m_OSDregions.Draw(&osdDC))
		{
			CDC monoDC;
			monoDC.CreateCompatibleDC(pDC);
			CBitmap maskBm;
			maskBm.CreateBitmap(720, 576, 1, 1, NULL);
			monoDC.SelectObject(maskBm);
			osdDC.SetBkColor(TRANSPARENT_COLOUR);
			monoDC.BitBlt(0, 0, 720, 576, &osdDC, 0, 0, SRCCOPY);

			CDC tempDC;
			tempDC.CreateCompatibleDC(pDC);
			CBitmap tempBM;
			tempBM.CreateCompatibleBitmap(pDC, 720, 576);
			tempDC.SelectObject(&tempBM);
			tempDC.BitBlt(0,0, 720, 576, pMemDC, 0, 0, SRCCOPY);

			BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255-(BYTE)(GetConfig()->GetOsdTransparency() * 255/100), 0};
			pMemDC->AlphaBlend(0, 0, 720, 576, &osdDC, 0, 0, 720, 576, bf );
	//
	////		 now contains correct over OSD area, wrong in background
	//
			pMemDC->MaskBlt(0,0, 720, 576, &tempDC, 0, 0, maskBm, 0, 0, MAKEROP4(SRCCOPY, DSTCOPY));
			//memDC.BitBlt(0, 0, 720, 576, &osdDC, 0, 0, SRCCOPY);
		}
	}

	pDC->BitBlt(0,0, 720, 576, pMemDC, 0, 0, SRCCOPY); 
	ReleaseDC();
}
示例#14
0
void CIconButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect rectItem = lpDrawItemStruct->rcItem;

	// set up for double buffering
	CDC dcMem;
	dcMem.CreateCompatibleDC(pDC);
	CBitmap bmp;
	bmp.CreateCompatibleBitmap(pDC, rectItem.Width(), rectItem.Height());
	CBitmap *pOldBitmap = dcMem.SelectObject(&bmp);
	dcMem.SetBkMode(TRANSPARENT);

	DrawBackGround(&dcMem);

	// button state
	BOOL bDrawFocusRect = !(lpDrawItemStruct->itemState & ODS_NOFOCUSRECT);
	BOOL bIsFocused     = lpDrawItemStruct->itemState & ODS_FOCUS;
	BOOL bIsPressed		= lpDrawItemStruct->itemState & ODS_SELECTED;

	DWORD state = bIsPressed ? PBS_PRESSED : PBS_NORMAL;

	if (state == PBS_NORMAL)
	{
		if (m_bhover)
		{
			state = PBS_HOT;
		}
	}

	if(bIsPressed)
	{
		dcMem.FillSolidRect(&rectItem, RGB(0, 0, 155));
	}
	else if(bIsFocused)
	{
		dcMem.FillSolidRect(&rectItem, RGB(0, 155, 0));
	}


	if(m_hIcon)
	{
		DrawIcon(&dcMem, rectItem);
	}
	else if(m_bitmap.GetSafeHandle())
	{
		DrawBitmap(&dcMem, rectItem);
	}

	// end double buffering
	pDC->BitBlt(0, 0, rectItem.Width(), rectItem.Height(),
		&dcMem, 0, 0, SRCCOPY);

	// swap back the original bitmap
	dcMem.SelectObject(pOldBitmap);
	bmp.DeleteObject();
	dcMem.DeleteDC();
}
示例#15
0
void CSkinTab::OnPaint()
{
	int i = 0;
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	CRect r;
	GetClientRect(&r);	

	CDC memDC;
	memDC.CreateCompatibleDC(&dc);
	CBitmap btScreen;
	btScreen.CreateCompatibleBitmap(&dc, r.Width(), r.Height());
	memDC.SelectObject(&btScreen);
	btScreen.DeleteObject();

	//画背景 
	memDC.BitBlt(r.left, r.top, r.Width(), r.Height(), &m_memDC, 0, 0, SRCCOPY);

	//memDC.Rectangle(r);
	for( i=0;i<m_nTabCount;i++)
	{
		CRect rect=m_pTabRect[m_nTabCount-i-1];
		
		rect.top +=22;
		DrawRangeImage(&m_BitmapBack[0],&memDC,rect);

	}
	if(m_nCurDownIndex!=-1)
	{
		CRect rect=m_pTabRect[m_nCurDownIndex];
		DrawRangeImage(&m_BitmapBack[1],&memDC,rect);

	
	}

	for(i = 0; i < MAX_TEXT_COUNT;i++)
	{
		if(strlen(m_TextTitle[i]) > 0)
		{
			CRect rect=m_pTabRect[i];
			CSize sizeTemp=memDC.GetTextExtent(m_TextTitle[i],_tcslen(m_TextTitle[i]));
			int xPos = (rect.Width() - sizeTemp.cx )/ 2 + rect.left;
			int YPos = (rect.Height() - sizeTemp.cy )/ 2 + rect.top + 11 ;
			if(xPos < 0)
				xPos = rect.left + 2;
			if(YPos < 0)
				YPos = rect.top + 2;
			memDC.SetBkMode(TRANSPARENT);
			memDC.TextOut(xPos ,YPos,m_TextTitle[i]);
		}
	}

	dc.BitBlt(r.left, r.top, r.Width(), r.Height(), &memDC, 0, 0, SRCCOPY);

	memDC.DeleteDC();
	// 不为绘图消息调用 CStatic::OnPaint()
}
示例#16
0
void CFontComboBox::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	ASSERT(lpDIS->CtlType == ODT_COMBOBOX);
	int id = (int)(WORD)lpDIS->itemID;

	CDC *pDC = CDC::FromHandle(lpDIS->hDC);
	CRect rc(lpDIS->rcItem);
	if (lpDIS->itemState & ODS_FOCUS)
		pDC->DrawFocusRect(rc);
	int nIndexDC = pDC->SaveDC();

	CBrush brushFill;
	if (lpDIS->itemState & ODS_SELECTED)
	{
		brushFill.CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
		pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
	}
	else
		brushFill.CreateSolidBrush(pDC->GetBkColor());
	pDC->SetBkMode(TRANSPARENT);
	pDC->FillRect(rc, &brushFill);

	CFontDesc* pDesc= (CFontDesc*)lpDIS->itemData;
	ASSERT(pDesc != NULL);
	DWORD dwData = pDesc->m_dwFlags;
	if (dwData & (TT_FONT|DEVICE_FONT)) // truetype or device flag set by SetItemData
	{
		CDC dc;
		dc.CreateCompatibleDC(pDC);
		CBitmap* pBitmap = dc.SelectObject(&m_bmFontType);
		if (dwData & TT_FONT)
			pDC->BitBlt(rc.left, rc.top, BMW, BMH, &dc, BMW, 0, SRCAND);
		else // DEVICE_FONT
			pDC->BitBlt(rc.left, rc.top, BMW, BMH, &dc, 0, 0, SRCAND);
		dc.SelectObject(pBitmap);
	}

	rc.left += BMW + 6;
	CString strText;
	GetLBText(id, strText);
	pDC->TextOut(rc.left,rc.top,strText,strText.GetLength());

	pDC->RestoreDC(nIndexDC);
}
示例#17
0
void CEx_DrawView::OnSaveAsBitmap() 
{
	// TODO: Add your command handler code here
	CFileDialog dlg(FALSE, _T(".bmp"), _T("图片1"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("位图(*.bmp)|*.bmp||"));
    if (dlg.DoModal() != IDOK)
    {
        return;
    }

    CFile file;
    file.Open(dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate);

    CDC* pDC = GetDC();
    BITMAP bm;
//     pDC->GetCurrentBitmap()->GetBitmap(&bm); // 这个在XP下会失败
    CDC dc;
    CBitmap bitmap;
    dc.CreateCompatibleDC(pDC);
    BITMAPINFO biPicInfo;
    LPVOID pvBits = NULL;
    biPicInfo.bmiHeader.biSize          = sizeof(biPicInfo.bmiHeader);
    biPicInfo.bmiHeader.biWidth         = m_size.cx;
    biPicInfo.bmiHeader.biHeight        = m_size.cy;
    biPicInfo.bmiHeader.biPlanes        = 1;
    biPicInfo.bmiHeader.biBitCount      = 32;
    biPicInfo.bmiHeader.biCompression   = BI_RGB;      // = 0 不压缩
    biPicInfo.bmiHeader.biSizeImage     = (m_size.cx * biPicInfo.bmiHeader.biBitCount + 31) / 32 * 4 * m_size.cy;
    biPicInfo.bmiHeader.biXPelsPerMeter = 0;    //
    biPicInfo.bmiHeader.biYPelsPerMeter = 0;    //
    biPicInfo.bmiHeader.biClrUsed       = 0;    // use all
    biPicInfo.bmiHeader.biClrImportant  = 0;    // use all
    bitmap.Attach(CreateDIBSection(NULL, &biPicInfo, DIB_RGB_COLORS, &pvBits, NULL, 0));
    bitmap.GetBitmap(&bm);
    dc.SelectObject(&bitmap);
    dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, NULL, 0, 0, WHITENESS);
    DrawGraphic(&dc);
    ReleaseDC(pDC);

    DWORD size = bm.bmWidthBytes * bm.bmHeight;

    BITMAPFILEHEADER bf;
    bf.bfType = 0x4d42;
    bf.bfSize = size + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
    bf.bfReserved1 = 0;
    bf.bfReserved2 = 0;
    bf.bfOffBits = 0x36;

    LPVOID pBits = (LPVOID) GlobalAlloc(GMEM_ZEROINIT, size);
    CopyMemory(pBits, pvBits, size);

    file.Write(&bf, sizeof(BITMAPFILEHEADER));
    file.Write(&biPicInfo.bmiHeader, sizeof(BITMAPINFOHEADER));
    file.Write(pBits, size);
    
    GlobalFree(pBits);
}
示例#18
0
void CScreenDlg::SaveSelectBmp(){
  if(!m_SelectionFinished)
    return;
  CDC dcSave;
  dcSave.CreateCompatibleDC(NULL);
  CBitmap bitmap;
  BITMAP bm;
  m_bmpScreen.GetBitmap(&bm);
  bool shadow=false,border=false;
  COLORREF bcolor=0;
  nsplugin::GetImgCapParam(border,shadow,bcolor);
  int shadow_offset=(shadow?shadow_size:0);
  int border_offset =(border?border_size:0);
  bm.bmWidth  = rect_w+shadow_offset+border_offset*2;//shadow picture's length is 6 pixel.
  bm.bmHeight = rect_h+shadow_offset+border_offset*2;
  bitmap.CreateBitmapIndirect(&bm);
  HBITMAP pOldBmp = dcSave.SelectBitmap(bitmap.m_hBitmap);
  dcSave.BitBlt(border_offset,border_offset,rect_w,rect_h,m_dcMem.m_hDC,realleftx,realtopy,SRCCOPY);

  using namespace Gdiplus;
  GdiplusStartupInput gdiplusStartupInput;
  ULONG_PTR           gdiplusToken;
  GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

  using _6bees_util::ultrapath;
  const wstring& upath = ultrapath::R().get(ultrapath::picdir);
  if(!_6bees_util::MakeSureDir(upath.c_str())){
    return;
  }
  Thumbpath.Format(_T("%sScreenCap_%lu_thumb.jpg"),upath.c_str(),time(0));
  RECT r={realleftx,realtopy,realleftx+rect_w,realtopy+rect_h};
  _6bees_gdi::GenerateThumb(Thumbpath,m_dcMem.m_hDC,r);

  // more fancy effects:-)
  if (border){
    dcSave.SelectPen(pen_Border.m_hPen);

    dcSave.MoveTo(0,0);
    dcSave.LineTo(0, rect_h+border_offset);
    dcSave.LineTo(rect_w+border_offset, rect_h+border_offset);
    dcSave.LineTo(rect_w+border_offset, 0);
    dcSave.LineTo(0, 0);
  }
  if (shadow){
    _6bees_gdi::_6BeeAddShadow(S1,S2,S3,S4,S5,dcSave,rect_w,rect_h,border_offset,shadow_size);
  }

  HBITMAP hBmp = (HBITMAP)bitmap.Detach();
  dcSave.SelectBitmap(pOldBmp);
  if(::OpenClipboard(m_hWnd)){
    ::EmptyClipboard();
    ::SetClipboardData(CF_BITMAP, hBmp);
    ::CloseClipboard();
  }
  GdiplusShutdown(gdiplusToken);
}
示例#19
0
BOOL PASCAL CInfBam::FitAndCenterBitmap(HBITMAP &hOriginal, COLORREF clrBackground,
	int nWidth, int nHeight)
{
	CBitmap *pBmp = CBitmap::FromHandle(hOriginal);
	if (!pBmp)
		return(FALSE);

	BITMAP bm;
	pBmp->GetBitmap(&bm);
	
	if (bm.bmWidth >= nWidth && bm.bmHeight >= nHeight)
		return(TRUE);

	CDC *pDC = AfxGetMainWnd()->GetDC();
	if (!pDC)
		return(FALSE);

	// DC to use to create the new image.
	CDC dcMem;
	dcMem.CreateCompatibleDC(pDC);

	// Need to have the original bitmap in a dc to manipulate it.
	CDC dcBmp;
	dcBmp.CreateCompatibleDC(pDC);
	CBitmap *pOldBmp = dcBmp.SelectObject(pBmp);

	// Need a new bitmap in the memory dc to copy onto.
	CBitmap bmpNew;
	bmpNew.CreateCompatibleBitmap(pDC,nWidth,nHeight);
	CBitmap *pOldMemBmp = dcMem.SelectObject(&bmpNew);

	// Erase the surface the background color.
	dcMem.FillSolidRect(0,0,nWidth,nHeight,clrBackground);

	// Find the centered coordinates.
	int nLeft = nWidth/2 - bm.bmWidth/2;
	int nTop = nHeight/2 - bm.bmHeight/2;

	// Copy the smaller original bitmap onto the 32x32 in the cenetered position.
	dcMem.BitBlt(nLeft,nTop,bm.bmWidth,bm.bmHeight,&dcBmp,0,0,SRCCOPY);

	// Select out the bitmaps.
	dcMem.SelectObject(pOldMemBmp);
	dcBmp.SelectObject(pOldBmp);

	AfxGetMainWnd()->ReleaseDC(pDC);

	// Delete the original and point it at the new one.
	pBmp->Detach();
	::DeleteObject(hOriginal);

	hOriginal = (HBITMAP)bmpNew;
	bmpNew.Detach();

	return(TRUE);
}
示例#20
0
void COthelloView::BiltBitmap(CDC &dc, int x1, int y1, int x2, int y2, HBITMAP hbm)
{
	CDC dcMem;
	HBITMAP hbmpOld;
	dcMem.CreateCompatibleDC(&dc);
	hbmpOld=(HBITMAP)::SelectObject(dcMem,hbm);

	dc.BitBlt(x1,y1,x2,y2,&dcMem,0,0,SRCCOPY);
	::SelectObject(dcMem,hbmpOld);
}
示例#21
0
void CZButton::DrawTransparent(int x,int y,CDC *pDC,CBitmap *pBitmap,COLORREF Color,CRect* rect)
{
	BITMAP bm;
	pBitmap->GetObject(sizeof(BITMAP),&bm);
	CDC ImageDC;
	ImageDC.CreateCompatibleDC(pDC);
	CBitmap *pOldImageBitmap=ImageDC.SelectObject(pBitmap);
	CDC MaskDC;
	MaskDC.CreateCompatibleDC(pDC);
	CBitmap MaskBitmap;
	MaskBitmap.CreateBitmap(bm.bmWidth,bm.bmHeight,1,1,NULL);
	CBitmap *pOldMaskBitmap=MaskDC.SelectObject(&MaskBitmap);
	ImageDC.SetBkColor(Color);
	MaskDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&ImageDC,0,0,SRCCOPY);
	CDC OrDC;
	OrDC.CreateCompatibleDC(pDC);
	CBitmap OrBitmap;
	OrBitmap.CreateCompatibleBitmap(&ImageDC,bm.bmWidth,bm.bmHeight);
	CBitmap *pOldOrBitmap=OrDC.SelectObject(&OrBitmap);
	OrDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&ImageDC,0,0,SRCCOPY);
	OrDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&MaskDC,0,0,0x220326);
	CDC TempDC;
	TempDC.CreateCompatibleDC(pDC);
	CBitmap TempBitmap;
	TempBitmap.CreateCompatibleBitmap(&ImageDC,bm.bmWidth,bm.bmHeight);
	CBitmap *pOldTmepBitmap=TempDC.SelectObject(&TempBitmap);
	TempDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,pDC,x,y,SRCCOPY);
	TempDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&MaskDC,0,0,SRCAND);
	TempDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&OrDC,0,0,SRCPAINT);
	if (rect!=NULL)
		pDC->BitBlt(x,y,rect->Width(),rect->Height(),&TempDC,rect->left,rect->top,SRCCOPY);
	else
		pDC->BitBlt(x,y,bm.bmWidth,bm.bmHeight,&TempDC,0,0,SRCCOPY);
	TempDC.SelectObject(pOldTmepBitmap);
	OrDC.SelectObject(pOldOrBitmap);
	MaskDC.SelectObject(pOldMaskBitmap);
	ImageDC.SelectObject(pOldImageBitmap);

	DeleteDC(TempDC);
	DeleteDC(OrDC);
	DeleteDC(MaskDC);
	DeleteDC(ImageDC);
}
示例#22
0
void COthelloView::BiltBitmap(CDC &dc, CRect &rc, HBITMAP hbm)
{
	CDC dcMem;
	HBITMAP hbmpOld;
	dcMem.CreateCompatibleDC(&dc);
	hbmpOld=(HBITMAP)::SelectObject(dcMem,hbm);

	dc.BitBlt(rc.left,rc.top,rc.right,rc.bottom,&dcMem,0,0,SRCCOPY);
	::SelectObject(dcMem,hbmpOld);
}
示例#23
0
文件: CMemDC.cpp 项目: cswanghan/code
	~CMemDC(){
                               //在内存画布释放时将内存画布的内容绘制在目标区域中
		m_pDC->BitBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),this,m_Rect.left,m_Rect.top,SRCCOPY);
		SelectObject(m_poldbmp);  //选中之前选中的位图对象
		if (m_poldbmp != NULL)   //判断位图对象是否为空
		{
			delete m_poldbmp;      //释放位图对象
		}
		DeleteObject(this);  //释放设备上下文
	}
示例#24
0
void CTextCheckBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC			memDC;
	CDC			*pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CBitmap		*pNewBitmap;
	CFont		cFont;
	
	// Grab the bitmap and font based on our check state
	if( m_bChecked )
	{
		m_crText = RGB(128, 128, 128);
		pNewBitmap = &m_bmpChecked;
	}
	else
	{
		// See if we have focus
		CDialogEx	*pParent = (CDialogEx*)GetParent();
		if( (pParent->GetFocusButton() == this) && (m_bmpNormal.m_hObject != NULL) )
		{
			m_crText = crHighlightText;
			pNewBitmap = &m_bmpFocus;
		}
		else
		{
			m_crText = crNormalText;
			pNewBitmap = &m_bmpNormal;
		}
	}

	//
	// Display the appropriate CheckBox bitmap
	//
	memDC.CreateCompatibleDC( pDC );
	CBitmap	*pOldBitmap = memDC.SelectObject( pNewBitmap );
	if( !pOldBitmap )
		return;

	BITMAP	bmpInfo;
	m_bmpNormal.GetBitmap( &bmpInfo );
	pDC->BitBlt( 0, 1, bmpInfo.bmWidth, bmpInfo.bmHeight, &memDC, 0, 0, SRCCOPY );
	memDC.SelectObject( pOldBitmap );

	//
	// Display the text with the appropriate font and color
	//
	cFont.CreateFontIndirect( &m_lfNormal );
	CFont	*pOldFont = pDC->SelectObject( &cFont );

	pDC->SetTextColor(m_crText);
	pDC->SetBkMode(TRANSPARENT);
	pDC->TextOut(bmpInfo.bmWidth + 2, 0, m_strWinText );

	pDC->SelectObject( pOldFont );

}
示例#25
0
void CHideButton::DrawControl(CDC &dc, CRect rcUpdate)
{
	int nWidth = m_rc.Width();
	int nHeight = m_rc.Height();

	if(!m_bUpdate)
	{		
		UpdateMemDC(dc, nWidth * 5, nHeight);
		
		for(int i = 0; i < 4; i++)
		{
			m_memDC.BitBlt(i * nWidth, 0, nWidth, nHeight, &dc, m_rc.left ,m_rc.top, SRCCOPY);
		}
		
		Color clrText[4] = {m_clrTextNormal, m_clrTextHover, m_clrTextDown, m_clrTextDisable};

		Graphics graphics(m_memDC);
		BSTR bsFont = m_strFont.AllocSysString();
		FontFamily fontFamily(bsFont);
		Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
		graphics.SetTextRenderingHint( TextRenderingHintClearTypeGridFit );
		::SysFreeString(bsFont);

		// 设置水平和垂直对齐方式
		DUI_STRING_ALIGN_DEFINE();

		strFormat.SetFormatFlags( StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces);
		Size sizeTip = GetTextBounds(font, strFormat, m_strTip);
		Size sizeText = GetTextBounds(font, strFormat, m_strTitle);
		
		m_rcText.SetRect(m_rc.left + sizeTip.Width + 10, m_rc.top, m_rc.left + sizeTip.Width + 10 + sizeText.Width, m_rc.top + sizeText.Height);
		
		SolidBrush solidBrushTip(m_clrTip);

		for(int i = 0; i < 4; i++)
		{
			RectF rect((Gdiplus::REAL)(i * nWidth), (Gdiplus::REAL)0, (Gdiplus::REAL)(sizeTip.Width + 10), (Gdiplus::REAL)sizeTip.Height);

			BSTR bsTip = m_strTip.AllocSysString();
			graphics.DrawString(bsTip, (INT)wcslen(bsTip), &font, rect, &strFormat, &solidBrushTip);
			::SysFreeString(bsTip);

			if(i > 0)
			{
				SolidBrush solidBrush(clrText[i - 1]);	
				RectF rect((Gdiplus::REAL)(sizeTip.Width + 10 + i * nWidth), (Gdiplus::REAL)0, (Gdiplus::REAL)(nWidth - (sizeTip.Width + 10)), (Gdiplus::REAL)sizeText.Height);
				BSTR bsTitle = m_strTitle.AllocSysString();
				graphics.DrawString(bsTitle, (INT)wcslen(bsTitle), &font, rect, &strFormat, &solidBrush);
				::SysFreeString(bsTitle);
			}
		}
	}

	dc.BitBlt(m_rc.left,m_rc.top, m_rc.Width(), m_rc.Height(), &m_memDC, m_bShowButton ? (1 + m_enButtonState) * nWidth : 0, 0, SRCCOPY);
}
示例#26
0
int OSDRegion::DrawPixmap(DWORD x, DWORD y, DWORD w, DWORD h, void *pixmap, bool sprite, BYTE dataFormat )
{
	CDC* pDC = GetDC();
	if (dataFormat == OSD_256)
	{
		BYTE* data = (BYTE*) pixmap;
		int lutCount = Regions::GetLutLen();
		DWORD* lut = Regions::GetLut();
		for (unsigned int j = 0; j<h; j++)
		{
			for (unsigned int i = 0; i<w; i++)
			{
				int iIndex = *data;
				data++;
				if ((iIndex == 0) && sprite)
					continue;

				pDC->SetPixelV(i+x + GetXOffs(), y+j + GetYOffs(), lut[iIndex]);
			}
		}
	}
	else if (dataFormat == OSD_1555)
	{
		WORD* pSource = (WORD*) pixmap;
	
		CBitmap bm;
		bm.CreateCompatibleBitmap(pDC, w, h);
		BITMAPINFO bmInfo;
		ZeroMemory(&bmInfo, sizeof(BITMAPINFO));
		bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		bmInfo.bmiHeader.biWidth = w;
		bmInfo.bmiHeader.biHeight = -((int)h);
		bmInfo.bmiHeader.biPlanes = 1;
		bmInfo.bmiHeader.biBitCount = 16;
		bmInfo.bmiHeader.biCompression = BI_RGB;

		::SetDIBits(pDC->m_hDC, (HBITMAP)bm.m_hObject, 0, h, pSource, &bmInfo, 0);

		CDC newDC;
		newDC.CreateCompatibleDC(pDC);
		newDC.SelectObject(&bm);
		if ( sprite )
			pDC->TransparentBlt(x + GetXOffs(), y + GetYOffs(), w, h, &newDC, 0, 0, w, h, 0);
		else
			pDC->BitBlt(x  + GetXOffs(), y + GetYOffs(), w, h, &newDC, 0, 0, SRCCOPY);
	}
	else
	{
		LogUnimplemented(__FUNCTION__ "(" __FUNCSIG__ ")");
		return 1;
	}

	ReleaseDC();
	return 0;
}
示例#27
0
BOOL GDIPluseExt::SaveScreenToJpg(CRect rect)
{
	// 得到屏幕DC
	HWND hDeskWnd = ::GetDesktopWindow();                        //获得屏幕的HWND. 
	CDC *pDestDC = CDC::FromHandle(::GetDC(hDeskWnd));           //获取当前整个屏幕DC
	int Width = rect.Width();                                    //宽
	int Height = rect.Height();                                  //高

	// 创建与屏幕兼容的Bitmap 
	CBitmap memBitmap;   
	memBitmap.CreateCompatibleBitmap(pDestDC, Width, Height);

	// 创建屏幕的内存DC
	CDC memDC;     
	memDC.CreateCompatibleDC(pDestDC);

	// 将兼容Bitmap格式选入内存DC
	memDC.SelectObject(&memBitmap);

	// 将屏幕DC数据copy至内存DC
	memDC.BitBlt(0, 0, Width, Height, pDestDC, 0, 0, SRCCOPY); 

	// 获得位图信息
	BITMAP bmpInfo;
	memBitmap.GetBitmap(&bmpInfo);

	// 生成BITMAPINFO
	BITMAPINFO m_BITMAPINFO;
	memset(&m_BITMAPINFO, 0, sizeof(BITMAPINFO));
	m_BITMAPINFO.bmiHeader.biSize     = sizeof(BITMAPINFOHEADER);
	m_BITMAPINFO.bmiHeader.biPlanes     = 1;
	m_BITMAPINFO.bmiHeader.biBitCount    = bmpInfo.bmBitsPixel;
	m_BITMAPINFO.bmiHeader.biCompression   = BI_RGB;
	m_BITMAPINFO.bmiHeader.biWidth     = bmpInfo.bmWidth;
	m_BITMAPINFO.bmiHeader.biHeight     = bmpInfo.bmHeight;

	// 获取位图数据
	BYTE * pBuffer = new BYTE[bmpInfo.bmWidthBytes * bmpInfo.bmHeight];
	GetDIBits(memDC.m_hDC, (HBITMAP) memBitmap.m_hObject, 0, Height, pBuffer,
		(LPBITMAPINFO) &m_BITMAPINFO, DIB_RGB_COLORS);

	// 生成位图
	Bitmap *pSrcBmp = Bitmap::FromBITMAPINFO(&m_BITMAPINFO, (void*)pBuffer);

	// 保存成jpg文件
	CLSID encoderClsid;
	GetEncoderClsid(L"image/jpeg", &encoderClsid);
	pSrcBmp-> Save(L"destop.jpg", &encoderClsid);

	// 释放内存
	delete pSrcBmp;
	delete pBuffer;
	AfxGetMainWnd()->ReleaseDC(pDestDC);
	return TRUE;
}
示例#28
0
void CCatchScreenDlg::DoPaint(CDC& dc)
{
	CRect rect;
	GetClientRect(&rect);
	CDC dcMem;
	dcMem.CreateCompatibleDC(&dc);
	HBITMAP hBitmap = CreateCompatibleBitmap(dc.GetSafeHdc(), rect.Width(), rect.Height());

	// 把新位图选到内存设备描述表中
	HBITMAP hOldBitmap = (HBITMAP)dcMem.SelectObject( hBitmap);
	//用整个桌面填充全屏对话框背景
	if (m_BackgroundBitmap.GetSafeHandle()) {
		BITMAP bmp;
		m_BackgroundBitmap.GetBitmap(&bmp);

		CDC dcCompatible;
		dcCompatible.CreateCompatibleDC(&dcMem);
		dcCompatible.SelectObject(m_BackgroundBitmap);
		CRect rect;
		GetClientRect(&rect);
		dcMem.BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);
	}
	//画出像皮筋矩形
	if(m_bDrawTracker)
	{
		//画出橡皮筋里面的原始图像
		DrawOrgRect(&dcMem,m_rectTracker.m_rect);
		m_rectTracker.Draw(&dcMem);
		//显示截取矩形大小信息
		if(m_bShowMsg)
		{
			CRect rect;
			m_rectTracker.m_rect.NormalizeRect();
			DrawMessage(dcMem,m_rectTracker.m_rect);
		}
	}
	
	dc.BitBlt(0,0,rect.Width(),rect.Height(),&dcMem, 0, 0, SRCCOPY);
	hBitmap = (HBITMAP)dcMem.SelectObject( hOldBitmap);
	dcMem.DeleteDC();
	DeleteObject(hBitmap);
}
示例#29
0
void BContainer::OnPaint()
{
	CRect   cr;

	
	  

	GetClientRect(&cr);
	CPaintDC dc(this);
	CDC* pDC = &dc;
	CDC* pParsedDC = pDC;
	CDC     MemDC;
	CBitmap MemBM;
	//pDC->SetViewportExt(cr.right, cr.bottom);

	//pDC->SetMapMode(MM_ISOTROPIC);
    //pDC->SetViewportOrg(cr.left, cr.bottom);
	//pDC->SetWindowExt(1,1);
	//pDC->SetViewportExt(1,-1);

	MemBM.CreateCompatibleBitmap(pParsedDC,cr.Width(),cr.Height());
	MemDC.CreateCompatibleDC(pParsedDC);
	MemDC.SelectObject(&MemBM);
	pDC = &MemDC;
	
	//umple backgroundul

	CRect fillRect;
    fillRect.SetRect(0,0,cr.Width(),cr.Height());


    pDC->FillSolidRect(&fillRect, RGB(240,240,240));	
	pDC->SetBkMode(TRANSPARENT);
	//fillRect.SetRect(ELEMENT_LEFT+LABEL_WIDTH,0,ELEMENT_LEFT+LABEL_WIDTH+SPACE_BETWEEN_ELEMENT,cr.Height());
	//pDC->FillSolidRect(&fillRect, RGB(220,220,220));
	
	//pDC->DrawEdge(&fillRect,BDR_RAISEDINNER,BF_RECT);

	//pDC->Draw3dRect(o
	
//--------------------------
// flicker
//--------------------------
	//pDC->SetViewportOrg(0,0);
	//MemDC.SetViewportOrg(0,0);

	//verifica daca este vreun element care trebuie collapsed sau nu



	pParsedDC->BitBlt( 0 , 0 , cr.Width() , cr.Height() , &MemDC , 0 , 0 , SRCCOPY );
		
	//CWnd::OnPaint();		
}
示例#30
0
void CMyEdit::OnNcPaint()
{
	CRect rcWindow;
	GetWindowRect(&rcWindow);

	CRect rcClient;
	GetClientRect(&rcClient);

	ClientToScreen(&rcClient);
	rcClient.OffsetRect(-rcWindow.left, -rcWindow.top);

	rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top);

	CDC *pWindowDC = GetWindowDC();
	CMemoryDC MemDC(pWindowDC,rcWindow);

	CRect rcIcon;
	if (m_pIconImg != NULL && !m_pIconImg->IsNull())
	{
		int cxIcon = m_pIconImg->GetWidth();
		int cyIcon = m_pIconImg->GetHeight();

		CalcCenterRect(rcWindow, cxIcon, cyIcon, rcIcon);
		rcIcon.right = rcWindow.right - 2;
		rcIcon.left = rcIcon.right - cxIcon;
	}

	DrawParentWndBg(GetSafeHwnd(),MemDC.GetSafeHdc());

	if (m_bHover)
	{
		if (m_pBackImgH != NULL && !m_pBackImgH->IsNull())
		{
			m_pBackImgH->Draw(&MemDC, rcWindow);
		}
		else
		{
			if (m_pBackImgN != NULL && !m_pBackImgN->IsNull())
				m_pBackImgN->Draw(&MemDC, rcWindow);
		}
	}
	else
	{
		if (m_pBackImgN != NULL && !m_pBackImgN->IsNull())
			m_pBackImgN->Draw(&MemDC, rcWindow);
	}

	if (m_pIconImg != NULL && !m_pIconImg->IsNull())
		m_pIconImg->Draw(&MemDC, rcIcon);

	pWindowDC->BitBlt(rcWindow.left,rcWindow.top,rcWindow.Width(),rcWindow.Height(),&MemDC,0,0,SRCCOPY);

	ReleaseDC(pWindowDC);
}