본문 바로가기

old drawer/C, C++, MFC

[MFC] Rect로 버튼 그리기

CRect increaseTempRect(increaseButtonRect);
 increaseTempRect += CRect(1, 1, 1, 1);
 dc.Rectangle(&increaseTempRect);
 dc.FillSolidRect(&increaseButtonRect, ::GetSysColor(COLOR_BTNFACE));

 if (increaseButtonClicked){
  dc.Draw3dRect(increaseButtonRect, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DLIGHT));
 }else{
  dc.Draw3dRect(increaseButtonRect, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DSHADOW));
 }

 dc.SetBkColor(::GetSysColor(COLOR_BTNFACE));
 dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT));

 if (increaseButtonClicked){
  CRect Rect = increaseButtonRect;
  Rect += CRect(0, 0, 2, 2);
  dc.DrawText(L"Increase", &Rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
 }else{
  dc.DrawText(L"Increase", &increaseButtonRect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
 }

 CRect decreaseTempRect(decreaseButtonRect);
 decreaseTempRect += CRect(1, 1, 1, 1);
 dc.Rectangle(&decreaseTempRect);
 dc.FillSolidRect(&decreaseButtonRect, ::GetSysColor(COLOR_BTNFACE));

 if (decreaseButtonClicked){
  dc.Draw3dRect(decreaseButtonRect, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DLIGHT));
 }else{
  dc.Draw3dRect(decreaseButtonRect, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DSHADOW));
 }

 dc.SetBkColor(::GetSysColor(COLOR_BTNFACE));
 dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT));

 if (decreaseButtonClicked){
  CRect Rect = decreaseButtonRect;
  Rect += CRect(0, 0, 2, 2);
  dc.DrawText(L"Decrease", &Rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
 }else{
  dc.DrawText(L"Decrease", &decreaseButtonRect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
 }