Exemplo n.º 1
0
void CSkinSliderCtrl::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	
	CRect rcClient;
	GetClientRect(&rcClient);

	CMemoryDC MemDC(&dc, rcClient);

	//绘制背景
	DrawParentWndBg(GetSafeHwnd(),MemDC->GetSafeHdc());
	
	//  [3/9/2016 Dingshuai]
	if (m_pBackImg != NULL && !m_pBackImg->IsNull())
	{
		m_pBackImg->DrawImage(&MemDC,0,0,rcClient.Width(),rcClient.Height());
	}

	//绘制轨迹
	if ( !IsWindowEnabled() )
	{
		if (m_pDisImg != NULL && !m_pDisImg->IsNull())
		{
			m_pDisImg->DrawImage(&MemDC,0,0);
		}		
	}
	else
	{
		if (m_pBackImg != NULL && !m_pBackImg->IsNull())
		{
			m_pBackImg->DrawImage(&MemDC,0,0);
		}
	}

	//绘制痕迹
	if (m_pTraceImg != NULL && !m_pTraceImg->IsNull())
	{
		m_pTraceImg->DrawImage/*DrawExtrude*/(&MemDC,CRect(0, 0,m_rcThumRect.left,m_pTraceImg->GetHeight()));
	}

	if (m_bLoopArrow)
	{
		//绘制A,B点
		if (m_pAImg != NULL && !m_pAImg->IsNull())
		{
			m_pAImg->DrawImage(&MemDC,m_nArrowLeftPos , -1);
		}							  
		if (m_pBImg != NULL && !m_pBImg->IsNull())
		{
			m_pBImg->DrawImage(&MemDC,m_nArrowRightPos, 0);
		}
	}

	//绘制滑块
	if (m_pThumImg != NULL && !m_pThumImg->IsNull())
	{
		m_pThumImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top);
	}

	//绘制按钮
	if (m_pBtImg != NULL && !m_pBtImg->IsNull())
	{
		if( m_bPress )
			m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,m_szThum.cx*2,0,m_pBtImg->GetWidth()/3,m_pBtImg->GetHeight());
		else if ( m_bHover )
			m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,m_szThum.cx,0,m_pBtImg->GetWidth()/3,m_pBtImg->GetHeight());
		else 
			m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,0,0,m_pBtImg->GetWidth()/3,m_pBtImg->GetHeight());
	}
}
Exemplo n.º 2
0
void CSkinListBox::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	
	CRect rcClient;
	GetClientRect(&rcClient);

	CMemoryDC BufferDC(&dc,rcClient);

 	//创建缓冲
 	CImage ImageBuffer;
 	ImageBuffer.Create(rcClient.Width(),rcClient.Height(),32);
 
 	//变量定义
 	CDC * pBufferDC=CDC::FromHandle(ImageBuffer.GetDC());

	//变量定义
	CRect rcItem;

	pBufferDC->SelectObject(GetCtrlFont());

	//绘画背景
	pBufferDC->FillSolidRect(0,0,rcClient.Width(),rcClient.Height(),m_colBack);
	DrawParentWndBg(GetSafeHwnd(),pBufferDC->GetSafeHdc());

	if (m_pBackImgN != NULL && !m_pBackImgN->IsNull())
		m_pBackImgN->Draw(pBufferDC, rcClient);

	for (int i=0;i<GetCount();i++)
	{	
		GetItemRect(i,&rcItem);

		//获取字符
		CString strString;
		GetText(i,strString);

		//计算位置
		CRect rcString;
		rcString.SetRect(rcItem.left+4,rcItem.top,rcItem.right-8,rcItem.bottom);

		bool bSelect = GetSel(i);

		//颜色定义
		COLORREF crTextColor=bSelect?m_colSelectText:m_colNormalText;

		//节点选中
		if ( bSelect )
		{
			if ( m_pSelectImg!= NULL && !m_pSelectImg->IsNull() )
			{
				m_pSelectImg->Draw(pBufferDC,CRect(rcItem.left,rcItem.top,rcItem.right,rcItem.bottom));
			}
		}

		//节点高亮
		else if ( m_nHovenItem == i )
		{
			if ( m_pBackImgH!= NULL && !m_pBackImgH->IsNull() )
			{
				m_pBackImgH->Draw(pBufferDC,CRect(rcItem.left,rcItem.top,rcItem.right,rcItem.bottom));
			}
		}

		//绘画字符
		pBufferDC->SetBkMode(TRANSPARENT);
		pBufferDC->SetTextColor(crTextColor);
		pBufferDC->DrawText(strString,&rcString,DT_VCENTER|DT_SINGLELINE);
	}

 	//绘画界面
 	BufferDC.BitBlt(0,0,rcClient.Width(),rcClient.Height(),pBufferDC,0,0,SRCCOPY);
 
 	//清理资源
 	ImageBuffer.ReleaseDC();
}