//=============================================================================	
void CXButtonXP::DrawIcon(CDC *pDC,
						  BOOL bHasText,
						  CRect& rectItem,		// from LPDRAWITEMSTRUCT
						  CRect& rectText,
						  BOOL bIsPressed,
						  BOOL bIsThemed,
						  BOOL bIsDisabled)
//=============================================================================	
{
	if (m_hIcon)
	{
		// first get size of icon

		DWORD dwWidth = 32;		// assume 32x32
		DWORD dwHeight = 32;
		ICONINFO iconinfo;

		if (GetIconInfo(m_hIcon, &iconinfo))
		{
			CBitmap* pBitmap = CBitmap::FromHandle(iconinfo.hbmColor);
			if (pBitmap)
			{
				BITMAP bm;
				pBitmap->GetBitmap(&bm);
				dwWidth = bm.bmWidth;
				dwHeight = bm.bmHeight;
			}

			if (iconinfo.hbmColor) 
				::DeleteObject(iconinfo.hbmColor);
			if (iconinfo.hbmMask) 
				::DeleteObject(iconinfo.hbmMask);
		}

		CRect rectImage(rectItem);

		PrepareImageRect(bHasText, rectItem, rectText, bIsPressed, bIsThemed,
			dwWidth, dwHeight, rectImage);

		HICON hIcon = m_hIcon;
		UINT nFlags = bIsDisabled ? DSS_DISABLED : DSS_NORMAL;

		if (bIsDisabled && m_hGrayIcon)
		{
			hIcon = m_hGrayIcon;
			nFlags = DSS_NORMAL;
		}

		nFlags |= DST_ICON;

		pDC->DrawState(CPoint(rectImage.left, rectImage.top),
					   CSize(rectImage.right - rectImage.left, rectImage.bottom - rectImage.top),
					   hIcon,
					   nFlags,
					   (CBrush *) NULL);
	}
}
예제 #2
0
void CButtonST::DrawTheIcon(CDC* pDC, BOOL bHasTitle, RECT* rpItem, CRect* rpTitle, BOOL bIsPressed, BOOL bIsDisabled)
{
    BYTE        byIndex        = 0;

    // Select the icon to use
    if (m_bIsCheckBox == TRUE)
    {
        if (bIsPressed == TRUE)
        {
            byIndex = 0;
        }
        else
        {
            byIndex = (m_csIcons[1].hIcon == NULL ? 0 : 1);
        }
    } // if
    else
    {
		if (TRUE == m_buttonpressed)
		{
			byIndex =2;
		}
		else
		{
            if (/*m_bMouseOnButton == TRUE &&*/ bIsPressed == TRUE/*|| bIsPressed == TRUE*/)//modify by liub
			{
                byIndex = 2;

			
			}
            else if (m_bMouseOnButton == TRUE )//add by liub
			{
                byIndex = 0;
			}

            else
			{
                byIndex = (m_csIcons[1].hIcon == NULL ? 0 : 1);
			}
		}
    } // else

    CRect    rImage;
    PrepareImageRect(bHasTitle, rpItem, rpTitle, bIsPressed, 
        m_csIcons[byIndex].dwWidth, m_csIcons[byIndex].dwHeight, &rImage);
    // Ole'!
    pDC->DrawState(rImage.TopLeft(),
                    rImage.Size(), 
                    m_csIcons[byIndex].hIcon,
                    (bIsDisabled ? DSS_DISABLED : DSS_NORMAL), 
                    (CBrush*)NULL);
} // End of DrawTheIcon
void CButtonST::DrawTheBitmap(CDCHandle pDC, bool bHasTitle, RECT &rItem, CRect &rCaption, bool bIsPressed, bool bIsDisabled)
{
	CDC				hdcBmpMem	= 0;
	CBitmapHandle	hbmOldBmp	= 0;
	CDC				hdcMem		= 0;
	CBitmapHandle	hbmT		= 0;
	BYTE			byIndex		= 0;

	// Select the bitmap to use
	if (m_bIsCheckBox)
		{
		if (bIsPressed)
			{
			byIndex = 0;
			}
		else
			{
			byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1);
			}
		}
	else
		{
		if (m_bMouseOnButton || bIsPressed)
			{
			byIndex = 0;
			}
		else
			{
			byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1);
			}
		}

	CRect	rImage;

	PrepareImageRect(bHasTitle, rItem, rCaption, bIsPressed, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, rImage);
	hdcBmpMem.CreateCompatibleDC(pDC);
	hbmOldBmp = hdcBmpMem.SelectBitmap(m_csBitmaps[byIndex].hBitmap);
	hdcMem.CreateCompatibleDC(0);
	hbmT = hdcMem.SelectBitmap(m_csBitmaps[byIndex].hMask);

	pDC.BitBlt(rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND);
	pDC.BitBlt(rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT);

	hdcMem.SelectBitmap(hbmT);
	hdcBmpMem.SelectBitmap(hbmOldBmp);
}
예제 #4
0
파일: BtnST.cpp 프로젝트: darwinbeing/trade
void CButtonST::DrawTheIcon(CDC* pDC, BOOL bHasTitle, RECT* rpItem, CRect* rpTitle, BOOL bIsPressed, BOOL bIsDisabled)
{
	BYTE		byIndex		= 0;

	// Select the icon to use
	if ((m_bIsCheckBox && bIsPressed) || (!m_bIsCheckBox && (bIsPressed || m_bMouseOnButton)))
		byIndex = 0;
	else
		byIndex = (m_csIcons[1].hIcon == NULL ? 0 : 1);

	CRect	rImage;
	PrepareImageRect(bHasTitle, rpItem, rpTitle, bIsPressed, m_csIcons[byIndex].dwWidth, m_csIcons[byIndex].dwHeight, &rImage);

	// Ole'!
	pDC->DrawState(	rImage.TopLeft(),
					rImage.Size(), 
					m_csIcons[byIndex].hIcon,
					(bIsDisabled ? DSS_DISABLED : DSS_NORMAL), 
					(CBrush*)NULL);
} // End of DrawTheIcon
void CButtonST::DrawTheIcon(CDCHandle pDC, bool bHasTitle, RECT &rpItem, CRect &rpTitle, bool bIsPressed, bool bIsDisabled)
{
	BYTE byIndex = 0;

	// Select the icon to use
    if (bIsDisabled)
    {
        byIndex = (m_csIcons[2].hIcon == NULL ? 0 : 2);
    }
	else if (m_bIsCheckBox)
		{
		if (bIsPressed)
			{
			byIndex = 0;
			}
		else
			{
			byIndex = (m_csIcons[1].hIcon == NULL ? 0 : 1);
			}
		}
	else 
		{
		if (m_bMouseOnButton || bIsPressed)
			{
			byIndex = 0;
			}
		else
			{
			byIndex = (m_csIcons[1].hIcon == NULL ? 0 : 1);
			}
		}

	CRect	rImage;
	PrepareImageRect(bHasTitle, rpItem, rpTitle, bIsPressed, m_csIcons[byIndex].dwWidth, m_csIcons[byIndex].dwHeight, rImage);
	// Ole'!
	pDC.DrawState(
		rImage.TopLeft(), rImage.Size(), 
		m_csIcons[byIndex].hIcon,
		/*(bIsDisabled ? DSS_DISABLED :*/ DSS_NORMAL, 
		0);
}
예제 #6
0
파일: BtnST.cpp 프로젝트: darwinbeing/trade
void CButtonST::DrawTheBitmap(CDC* pDC, BOOL bHasTitle, RECT* rItem, CRect *rCaption, BOOL bIsPressed, BOOL bIsDisabled)
{
	HDC			hdcBmpMem	= NULL;
	HBITMAP		hbmOldBmp	= NULL;
	HDC			hdcMem		= NULL;
	HBITMAP		hbmT		= NULL;

	BYTE		byIndex		= 0;

	// Select the bitmap to use
	if ((m_bIsCheckBox && bIsPressed) || (!m_bIsCheckBox && (bIsPressed || m_bMouseOnButton)))
		byIndex = 0;
	else
		byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1);

	CRect	rImage;
	PrepareImageRect(bHasTitle, rItem, rCaption, bIsPressed, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, &rImage);

	hdcBmpMem = ::CreateCompatibleDC(pDC->m_hDC);

	hbmOldBmp = (HBITMAP)::SelectObject(hdcBmpMem, m_csBitmaps[byIndex].hBitmap);

	hdcMem = ::CreateCompatibleDC(NULL);

	hbmT = (HBITMAP)::SelectObject(hdcMem, m_csBitmaps[byIndex].hMask);

	::BitBlt(pDC->m_hDC, rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND);

	::BitBlt(pDC->m_hDC, rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT);

	::SelectObject(hdcMem, hbmT);
	::DeleteDC(hdcMem);

	::SelectObject(hdcBmpMem, hbmOldBmp);
	::DeleteDC(hdcBmpMem);
} // End of DrawTheBitmap
예제 #7
0
void CButtonST::DrawTheBitmap(CDC* pDC, BOOL bHasTitle, RECT* rItem, CRect *rCaption, BOOL bIsPressed, BOOL bIsDisabled)
{
	HDC			hdcBmpMem	= NULL;
	HBITMAP		hbmOldBmp	= NULL;
	HDC			hdcMem		= NULL;
	HBITMAP		hbmT		= NULL;

	BYTE		byIndex		= 0;

	// Select the bitmap to use
	if ((m_bIsCheckBox && bIsPressed) || (!m_bIsCheckBox && (bIsPressed || m_bMouseOnButton)))
		byIndex = 0;
	else
		byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1);

	CRect	rImage;
	PrepareImageRect(bHasTitle, rItem, rCaption, bIsPressed, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, &rImage);

	hdcBmpMem = ::CreateCompatibleDC(pDC->m_hDC);

	hbmOldBmp = (HBITMAP)::SelectObject(hdcBmpMem, m_csBitmaps[byIndex].hBitmap);

	hdcMem = ::CreateCompatibleDC(NULL);

	hbmT = (HBITMAP)::SelectObject(hdcMem, m_csBitmaps[byIndex].hMask);

	if (bIsDisabled && m_bShowDisabledBitmap)
	{
		HDC		hDC = NULL;
		HBITMAP	hBitmap = NULL;

		hDC = ::CreateCompatibleDC(pDC->m_hDC);
		hBitmap = ::CreateCompatibleBitmap(pDC->m_hDC, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight);
		HBITMAP	hOldBmp2 = (HBITMAP)::SelectObject(hDC, hBitmap);

		RECT	rRect;
		rRect.left = 0;
		rRect.top = 0;
		rRect.right = rImage.right + 1;
		rRect.bottom = rImage.bottom + 1;
		::FillRect(hDC, &rRect, (HBRUSH)RGB(255, 255, 255));

		COLORREF crOldColor = ::SetBkColor(hDC, RGB(255,255,255));

		::BitBlt(hDC, 0, 0, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND);
		::BitBlt(hDC, 0, 0, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT);

		::SetBkColor(hDC, crOldColor);
		::SelectObject(hDC, hOldBmp2);
		::DeleteDC(hDC);

		pDC->DrawState(	CPoint(rImage.left/*+1*/, rImage.top), 
						CSize(m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight), 
						hBitmap, DST_BITMAP | DSS_DISABLED);

		::DeleteObject(hBitmap);
	} // if
	else
	{
		::BitBlt(pDC->m_hDC, rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND);

		::BitBlt(pDC->m_hDC, rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT);
	} // else

	::SelectObject(hdcMem, hbmT);
	::DeleteDC(hdcMem);

	::SelectObject(hdcBmpMem, hbmOldBmp);
	::DeleteDC(hdcBmpMem);
} // End of DrawTheBitmap