Beispiel #1
0
void Unit::Render()
{
    if (m_IsDeath)
        return;

    auto render = GetComponent<CmdRenderComponent>();
    if (render == nullptr)
        return;

    render->SetCoord(Coord(m_Pos));
    DirectionShow();

    if (m_HitRenderFlag)
    {
        m_HitRenderFlag = false;
        auto orgBGColor = render->GetBGColor();
        render->SetBGColor(Color::MAGENTA);
        GameObject::Render();
        render->SetBGColor(orgBGColor);
    }
    else
    {
        GameObject::Render();
    }
}
int CTransCtrl::DoDesktopLock( )
{
	if( TestDesktop( ) < 0 )
		return 0;

	if( GetTextColor() != m_textcolor )
		SetTextColorEx( m_textcolor );
	
	if( GetBGColor() != CLR_NONE )
		SetTransparent();
	
	CheckExtStyles();

	return 1;
}
Beispiel #3
0
void COGLWin::Display()
{
	//printf("Display\n");
	if (m_bInDisplay)
		return;

	m_bInDisplay = true;

	bool bRedisplay = false;
	//printf("Enter Display\n");

	// Always call this function before drawing

	// Now we display, so we can allow idle loop to check script.
	m_bWaitWithIdleForNextDisplay = false;

	// Reset Perspective Angle to standard
	SetPerspectiveAngle(70);

	BeginDraw();

	// Save Frame Transform 
	float fFrameAngle = m_fFrameAngle;
	STransform Trans = m_mTransform[0];
	bool bRedraw = false;
	bool bEnable2dView = false;
	bool b2dViewChanged = false;
	int iActRTMode = GetActRTMode();

	if (iActRTMode && m_mTransform[iActRTMode].iFlags)
		AddExecModeVar(EXEC_MODE_USER);

	if (m_bCodeChanged)
	{
		bRedraw = true;
		m_bCodeChanged = false;
	}
	else
	{
		for(int i=1;i<=9;i++)
		{
			if (m_mTransform[i].iFlags)
			{
				bRedraw = true;
				break;
			}
		}
		
		if (m_iExecMode & EXEC_MODE_TOOL ||
			m_iExecMode & EXEC_MODE_LINK ||
			m_iExecMode & EXEC_MODE_KEYUP ||
			m_iExecMode & EXEC_MODE_KEYDOWN)
			//||
			//m_iExecMode & EXEC_MODE_RESHAPE)
		{
			bRedraw = true;
			m_bCheckForAnimate = true;
		}

//		if (!m_mTransform[0].iFlags)
//			bRedraw = true;	
	}

	if (HasError() && !bRedraw)
	{
		// Draw Frame Box (optional)
		if (m_dFrameBoxSize > 0.0 && !m_b2dView)
			DrawBox((float)m_dFrameBoxSize);

		EndDraw();
		//SetExecModeVar(EXEC_MODE_NONE);
		m_bInDisplay = false;
		return;
	}

	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GEQUAL, 1.0f);

	// Check whether only space has been transformed
	if (bRedraw)
	{		
		CCodeVar Var;

		// Start drawing into display list
		m_dlSpace.BeginDraw(true);
		
		// Draw Frame Box (optional)
		// DrawBox(3.0);
		
		// Draw you own stuff
		Draw();
	
		// End drawing into display list
		m_dlSpace.EndDraw();

		if (!HasError())
		{
			// Check whether Frame Box is to be drawn and in what size
			if (m_Parse.GetVar("_FrameBoxSize", Var))
			{	
				TCVScalar dVal;
				if (Var.CastToScalar(dVal))
					m_dFrameBoxSize = dVal;
			}
			else m_dFrameBoxSize = 3.0;

			// Set Background Color
			if (m_Parse.GetVar("_BGColor", Var))
			{	
				if (Var.Type() == PDT_COLOR)
				{
					COGLColor colBG = *((COGLColor *) Var.Val());
					if (!(colBG == GetBGColor()))
						bRedisplay = true;
//						m_bBGColChanged = true;

					SetBGColor(colBG);
				}
			}
			//else SetBGColor(Black);

			if (!m_b2dView && ScriptIs2d())
			{
				//printf("Switch to 2d view.\n");

				bEnable2dView = true;
				b2dViewChanged = true;
				//m_bCodeChanged = true;
				//SetExecModeVar(EXEC_MODE_AGAIN);

				bRedisplay = true;
			}
			else if (m_b2dView && !ScriptIs2d())
			{	
				//printf("Switch to 3d view.\n");

				bEnable2dView = false;
				b2dViewChanged = true;
				//m_bCodeChanged = true;
				//SetExecModeVar(EXEC_MODE_AGAIN);

				bRedisplay = true;
			}

			if (m_bBGColChanged)
			{
				//printf("BGCol. changed.\n");

				//m_bBGColChanged = false;
				//SetExecModeVar(EXEC_MODE_AGAIN);

				bRedisplay = true;
			}

			if (m_bFrameTransChanged)
			{
				m_bFrameTransChanged = false;
				//SetExecModeVar(EXEC_MODE_AGAIN);

				bRedisplay = true;
			}

			if (bRedisplay)
			{
				//printf("Redisplay\n");
				// End Draw without swapping buffers
				CCLUDrawBase::EndDraw();

				if (b2dViewChanged)
					Enable2dView(bEnable2dView);

				// Now begin drawing again
				BeginDraw();
				fFrameAngle = m_fFrameAngle;
				Trans = m_mTransform[0];

				glEnable(GL_ALPHA_TEST);
				glAlphaFunc(GL_GEQUAL, 1.0f);
				m_dlSpace.Apply();
			}

		}

		// Draw Frame Box (optional)
		if (m_dFrameBoxSize > 0.0 && !m_b2dView)
			DrawBox((float)m_dFrameBoxSize);
	}
	else
	{
		// Apply display list
		m_dlSpace.Apply();

		// Draw Frame Box (optional)
		if (m_dFrameBoxSize > 0.0 && !m_b2dView)
			DrawBox((float)m_dFrameBoxSize);
	}


	if (!HasError())
	{
		// Get ModelView Identity Matrix back
		glPopMatrix(); 
		// Save it again
		glPushMatrix();
		// Set initial origin again
		glTranslatef(Trans.pfTrans[0], Trans.pfTrans[1], Trans.pfTrans[2]);

		if (m_bUseLocalRot)
		{
			glRotatef(Trans.pfRot[2], 1, 0, 0);
			glRotatef(Trans.pfRot[0], 0, 1, 0);
			glRotatef(Trans.pfRot[1], 0, 0, 1);
		}
		else
		{
			glRotatef(fFrameAngle, Trans.pfRot[0], Trans.pfRot[1], Trans.pfRot[2]);
		}

		glEnable(GL_BLEND);
		glAlphaFunc(GL_LESS, 1.0f);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glDepthMask(GL_FALSE);

		m_dlSpace.Apply();
		
		glDepthMask(GL_TRUE);
		glDisable(GL_BLEND);
	}
	glDisable(GL_ALPHA_TEST);
	//m_Filter << m_E3Base.vI;

	// Always call this function after drawing
	EndDraw();
	

	//CheckToolBoxSize();
	m_bCheckToolBoxSize = true;
	
	//SetExecModeVar(EXEC_MODE_NONE);
	m_bInDisplay = false;
}
Beispiel #4
0
void CSkinBtn::DrawButton()
{

	CPoint posText(0,0);
	if(m_bRePain == FALSE)
	{
		CClientDC  dc(this);

		CRect	rect;
		GetClientRect(&rect);

		CDC memDC;
		memDC.CreateCompatibleDC(&dc);

		CBitmap Screen;
		Screen.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
		memDC.SelectObject(&Screen);
		Screen.DeleteObject();

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

		CString str(_T(""));
		GetWindowText(str);	

		memDC.SetBkMode(TRANSPARENT);
		memDC.SelectObject(m_pFont);

		CDC MemDC;
		MemDC.CreateCompatibleDC(&dc);
		BITMAP bm;

		if(m_IconDraw)
		{
			CRect rImage;
			rImage.top = 0;
			rImage.left = 0;
			
			BOOL		bRetValue;
			ICONINFO	ii;
			::ZeroMemory(&ii, sizeof(ICONINFO));
			bRetValue = ::GetIconInfo(m_IconIn, &ii);
			if (bRetValue == FALSE)
			{
				if (m_IconIn)	::DestroyIcon(m_IconIn);
				rImage.bottom = 16;
	     		rImage.right = 16;
			} 
			else
			{
				rImage.right	= (DWORD)(ii.xHotspot * 2);
				rImage.bottom	= (DWORD)(ii.yHotspot * 2);
			}
			::DeleteObject(ii.hbmMask);
			::DeleteObject(ii.hbmColor);
			//int nXOffset = (rect.Width() - rImage.right)/2;
			int nYOffset = (rect.Height() - rImage.bottom)/2;//rect.Width(), rect.Height()
			if(nYOffset < 0)
				nYOffset = 0;
			rImage.top += nYOffset;
			posText.x = rImage.right + 2;
			posText.y = (rect.Height() - 20)/2;
            if(posText.y < 0)
               posText.y = 0;


			switch(m_state)
			{
			case NORMAL:
				// Ole'!
				memDC.DrawState(rImage.TopLeft(),
								rImage.Size(), 
								m_IconIn,
								DSS_NORMAL, 
								(CBrush*)NULL);
				memDC.SetTextColor(GetFGColor());
	//			memDC.TextOut(m_textPos.x,m_textPos.y,str);
				break;
			case HOVER:
				// Ole'!
				memDC.DrawState(rImage.TopLeft(),
								rImage.Size(), 
								m_IconOut,
								DSS_NORMAL, 
								(CBrush*)NULL);	
				memDC.SetTextColor(RGB(36,93,219));
	//			memDC.TextOut(m_textPos.x,m_textPos.y,str);
				if(m_bDrawRantage)
				{
					memDC.MoveTo(rect.left,rect.top);
					memDC.LineTo(rect.right,rect.top);
					memDC.MoveTo(rect.left,rect.top);
					memDC.LineTo(rect.left,rect.bottom);
					memDC.MoveTo(rect.left,rect.bottom - 1);
					memDC.LineTo(rect.right,rect.bottom - 1);
					memDC.MoveTo(rect.right - 1,rect.top);
					memDC.LineTo(rect.right - 1,rect.bottom);
				}
			//	memDC.SetBkColor(TRANSPARENT);
			//	memDC.Rectangle(rect);
				break;
			case DOWN:
				// Ole'!
//				SetTimer(2,20,NULL);
				memDC.DrawState(rImage.TopLeft(),
								rImage.Size(), 
								m_IconOut,
								DSS_NORMAL, 
								(CBrush*)NULL);	
				memDC.SetTextColor(GetBGColor());
	//			memDC.TextOut(m_textPos.x,m_textPos.y,str);
				break;
			case DISABLE:
				memDC.DrawState(rImage.TopLeft(),
								rImage.Size(), 
								m_IconIn,
								DSS_NORMAL, 
								(CBrush*)NULL);
				memDC.SetTextColor(GetFGColor());
	//			memDC.TextOut(m_textPos.x,m_textPos.y,str);
				break;
			default:
				break;
			}
		}
		else
		{
			CString ss;
			GetWindowText(ss);
			m_imgNormal.GetBitmap(&bm);
			int nYOffset = (rect.Height() - bm.bmHeight)/2;//rect.Width(), rect.Height()
			if(nYOffset < 0)
				nYOffset = 0;

			posText.x = rect.left + bm.bmWidth + 2;
			posText.y = (rect.Height() - 20)/2;
            if(posText.y < 0)
               posText.y = 0;

			posText = m_textPos;
			if(m_ShowState == 1)
			{//强制设成选取中状态
				m_imgDown.GetBitmap(&bm);
//				SetTimer(2,20,NULL);
				MemDC.SelectObject(&m_imgDown);
				if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right)
					memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth,
					bm.bmHeight,SRCCOPY);
				else
					memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY);
				memDC.SetTextColor(GetBGColor());

			}
			else
			{
				switch(m_state)
				{
				case NORMAL:
					m_imgNormal.GetBitmap(&bm);
					MemDC.SelectObject(&m_imgNormal);
					if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right)
						memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth,
						bm.bmHeight,SRCCOPY);
					else
						memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY);
					memDC.SetTextColor(GetFGColor());
		//			memDC.TextOut(m_textPos.x,m_textPos.y,str);
					break;
				case HOVER:
					m_imgHover.GetBitmap(&bm);
					MemDC.SelectObject(&m_imgHover);
					if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right)
						memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth,
						bm.bmHeight,SRCCOPY);
					else
						memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY);
					if(m_bDrawRantage)
					{
						memDC.SetTextColor(GetBGColor());
						memDC.TextOut(m_textPos.x,m_textPos.y,str);
						memDC.MoveTo(rect.left,rect.top);
						memDC.LineTo(rect.right,rect.top);
						memDC.MoveTo(rect.left,rect.top);
						memDC.LineTo(rect.left,rect.bottom);
						memDC.MoveTo(rect.left,rect.bottom - 1);
						memDC.LineTo(rect.right,rect.bottom - 1);
						memDC.MoveTo(rect.right - 1,rect.top);
						memDC.LineTo(rect.right - 1,rect.bottom);
					}
					break;
				case DOWN:
					m_imgDown.GetBitmap(&bm);
	//				SetTimer(2,20,NULL);
					MemDC.SelectObject(&m_imgDown);
					if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right)
						memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth,
						bm.bmHeight,SRCCOPY);
					else
						memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY);
					memDC.SetTextColor(GetBGColor());
		//			memDC.TextOut(m_textPos.x,m_textPos.y,str);
					break;
				case DISABLE:
					 m_imgDisable.GetBitmap(&bm);
	   				 MemDC.SelectObject(&m_imgDisable);
					 if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right)
		 				 memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth,
						 bm.bmHeight,SRCCOPY);
					 else
						 memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY);
					 memDC.SetTextColor(GetFGColor());
		//			 memDC.TextOut(m_textPos.x,m_textPos.y,str);
					break;
				default:
					break;
				}
			}
		}
		if(!str.IsEmpty())
		{
			memDC.TextOut(posText.x,posText.y,str);
		}
		dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);

		memDC.DeleteDC();
		MemDC.DeleteDC();
	}
}
Beispiel #5
0
void CSkinBtn::DrawButtonNullPicture()
{
	if(m_bRePain == FALSE)
	{
		CPoint posText(0,0);
		CClientDC  dc(this);

		CRect	rect;
		GetClientRect(&rect);

		

		CDC memDC;
		memDC.CreateCompatibleDC(&dc);

		CBitmap Screen;
		Screen.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
		memDC.SelectObject(&Screen);
		Screen.DeleteObject();

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

		CString str(_T(""));
		GetWindowText(str);	

		int nLen = str.GetLength();
		if(nLen > 3)
		  posText.x = (rect.Width())/5;
		else
          posText.x = (rect.Width())/3;
		if(posText.x < 0)
           posText.x = 0;
		posText.y = (rect.Height() - 20)/2;
        if(posText.y < 0)
           posText.y = 0;

		memDC.SetBkMode(TRANSPARENT);
		memDC.SelectObject(m_pFont);
        
		CDC MemDC;
		MemDC.CreateCompatibleDC(&dc);
		switch(m_state)
			{
			case NORMAL:
				memDC.SetTextColor(GetBGColor());
				break;
			case HOVER:
				if(m_bDrawRantage)
				{
					memDC.SetTextColor(RGB(36,93,219));
					memDC.MoveTo(rect.left,rect.top);
					memDC.LineTo(rect.right,rect.top);
					memDC.MoveTo(rect.left,rect.top);
					memDC.LineTo(rect.left,rect.bottom);
					memDC.MoveTo(rect.left,rect.bottom - 1);
					memDC.LineTo(rect.right,rect.bottom - 1);
					memDC.MoveTo(rect.right - 1,rect.top);
					memDC.LineTo(rect.right - 1,rect.bottom);
				}
				break;
			case DOWN:				
				memDC.SetTextColor(GetBGColor());
				break;
			case DISABLE:
				 memDC.SetTextColor(GetFGColor());
	//			 memDC.TextOut(m_textPos.x,m_textPos.y,str);
				break;
			default:
				break;
			}

		    if(!str.IsEmpty())
			{
				memDC.TextOut(posText.x,posText.y,str);
			}
			dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);

			memDC.DeleteDC();
			MemDC.DeleteDC();
		}
		
}
Beispiel #6
0
void CSkinBtn::DrawButtonTitle()
{
	if(m_bRePain == FALSE)
	{
		CClientDC  dc(this);

		CRect	rect;
		GetClientRect(&rect);

		CDC memDC;
		memDC.CreateCompatibleDC(&dc);

		CBitmap Screen;
		Screen.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
		memDC.SelectObject(&Screen);
		Screen.DeleteObject();


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

	//	CString str(_T(""));
	//	GetWindowText(str);	

		memDC.SetBkMode(TRANSPARENT);
		memDC.SelectObject(m_pFont);

	//	CDC MemDC;
	//	MemDC.CreateCompatibleDC(&dc);

       
        CPen pen;
		
	//	CRgb textColor(255,255,255);
        
		switch(m_state)
		{
		case NORMAL:
			memDC.SetTextColor(RGB(97,113,197));
			pen.CreatePen(PS_SOLID , 1, RGB(255,0,0));
			break;
		case HOVER:
			memDC.SetTextColor(RGB(36,93,219));
			pen.CreatePen(PS_SOLID , 1, RGB(0,255,0));
			break;
		case DOWN:
			memDC.SetTextColor(GetBGColor());
			pen.CreatePen(PS_SOLID , 1, RGB(0,0,255));
			break;
		case DISABLE:
			memDC.SetTextColor(GetFGColor());
			pen.CreatePen(PS_SOLID , 1, RGB(225,225,225));
			break;
		default:
			break;
		}
        CPen* pOldPen = (CPen*)memDC.SelectObject(&pen);
		memDC.RoundRect(rect.left, rect.top, rect.Width(), rect.Height(),2,2);
		memDC.SelectObject(pOldPen);

		CPen pen0(PS_SOLID , 1, RGB(255, 255, 255));
		CPen* pOldPen0 = (CPen*)memDC.SelectObject(&pen);
		int nXpos = 0;
		int nYpos = 0;
		int n = 0;
		int m = 0;
		int nWidth = 0;
		int nHeight = 0;
		switch(m_BtnNum)
		{
			case 1://最小化
				
				nWidth = 13;
				nXpos = rect.left + 1;
		        nYpos = rect.top +  (nWidth/2 );
                for( n = nXpos + 3;n < nXpos + nWidth;n++)
				{
					//memDC.MoveTo(nXpos + nWidth/2 - 1,nYpos - 1);
					//memDC.LineTo(nXpos + nWidth/2+ 1 ,nYpos - 1);
					memDC.MoveTo(n,nXpos + 6);
		         	memDC.LineTo(n ,nXpos + 2 + 6);
					nYpos--;

				}
				break;
				
			case 2://还原
				nWidth = 7;
				nHeight = 7;
				nXpos = rect.left + 5;
		        nYpos = rect.top + 5;
				for(m = 0;m < 2;m++)
				{
					memDC.MoveTo(nXpos,nYpos);
					memDC.LineTo(nXpos + nWidth ,nYpos);

					memDC.MoveTo(nXpos,nYpos);
					memDC.LineTo(nXpos ,nYpos + nHeight);

					memDC.MoveTo(nXpos + nWidth,nYpos + nHeight);
					memDC.LineTo(nXpos ,nYpos + nHeight);

					memDC.MoveTo(nXpos + nWidth,nYpos + nHeight);
					memDC.LineTo(nXpos + nWidth ,nYpos);
					nXpos+=2;
					nYpos+=2;
				}
				break;
			case 3://关闭
				nWidth = 10;
				nXpos = rect.left + 4;
		        nYpos = rect.top + (nWidth - 1) + 4;
				for(n = nXpos;n < nXpos + 10;n++)
				{
					memDC.MoveTo(n,n);
					memDC.LineTo(n + 3,n);

					memDC.MoveTo(n,nYpos);
					memDC.LineTo(n + 3,nYpos);
					nYpos--;

				}
				break;
			case 4://下三角按妞
				nWidth = 9;
				nXpos = rect.left;
		        nYpos = rect.top ;
				for(m = 0;m < 5;m++)
				{
					memDC.MoveTo(nXpos + m + 3,nYpos + m + 3);
			        memDC.LineTo(nXpos + nWidth - m + 3  ,nYpos + m + 3);
				}
				break;
			case 5://加号按妞
		    	nWidth = 14;
				nXpos = rect.left + 1;
		        nYpos = rect.top +  (nWidth/2 );
                for( n = nXpos + 3;n < nXpos + nWidth;n++)
				{
					//memDC.MoveTo(nXpos + nWidth/2 - 1,nYpos - 1);
					//memDC.LineTo(nXpos + nWidth/2+ 1 ,nYpos - 1);
					memDC.MoveTo(n,nXpos + 6);
		         	memDC.LineTo(n ,nXpos + 2 + 6);

					memDC.MoveTo(nXpos + nWidth/2 - 1 + 1,nYpos - 1 + 7);
		            memDC.LineTo(nXpos + nWidth/2 + 1 + 1,nYpos - 1 + 7);
					nYpos--;

				}
				break;
			case 6://画下划线按妞
				memDC.SetBkColor(TRANSPARENT);
				nXpos = rect.left ;
		        nYpos = rect.top +5;
                memDC.TextOut(23,nYpos,m_strTextOut);
		        
				break;
			default:
				break;
		}
        memDC.SelectObject(pOldPen0);
		dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);
		memDC.DeleteDC();
		//MemDC.DeleteDC();
	}
}
Beispiel #7
0
void CColorButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
    CDC* pDC = CDC::FromHandle(lpDIS->hDC);

    UINT state = lpDIS->itemState;
    CRect focusRect, btnRect;
    focusRect.CopyRect(&lpDIS->rcItem);
    btnRect.CopyRect(&lpDIS->rcItem);

    //
    // Set the focus rectangle to just past the border decoration
    //
    focusRect.left += 4;
    focusRect.right -= 4;
    focusRect.top += 4;
    focusRect.bottom -= 4;

    //
    // Retrieve the button's caption
    //
    const int bufSize = 512;
    TCHAR buffer[bufSize];
    GetWindowText(buffer, bufSize);


    //
    // Draw and label the button using draw methods
    //
    DrawFilledRect(pDC, btnRect, GetBGColor());
    DrawFrame(pDC, btnRect, GetBevel());
    DrawButtonText(pDC, btnRect, buffer, GetFGColor());


    //
    // Now, depending upon the state, redraw the button (down image) if it is selected,
    // place a focus rectangle on it, or redisplay the caption if it is disabled
    //
    if (state & ODS_FOCUS) {
        DrawFocusRect(lpDIS->hDC, (LPRECT)&focusRect);
        if (state & ODS_SELECTED) {
            DrawFilledRect(pDC, btnRect, GetBGColor());
            DrawFrame(pDC, btnRect, -1);


// ----> Changes!	// changes by RW:

            // move the button text if it is pressed...
            CRect rectPressedBtnText = btnRect;

            // to the right and bottom...
            rectPressedBtnText.OffsetRect( 1, 1 );

            // ... and now paint it!
            DrawButtonText(pDC, rectPressedBtnText, buffer, GetFGColor());

            // DrawButtonText(pDC, btnRect, buffer, GetFGColor());
            DrawFocusRect(lpDIS->hDC, (LPRECT)&focusRect);
        }
    }
    else if (state & ODS_DISABLED) {
        //COLORREF disabledColor = bg ^ 0xFFFFFF; // contrasting color
        DrawButtonText(pDC, btnRect, buffer, GetDisabledColor());
    }
}