void CLCDProgressBar::OnDraw(CLCDGfx &rGfx) { rGfx.ClearScreen(); // draw the border RECT r = { 0, 0, GetWidth(), GetHeight() }; FrameRect(rGfx.GetHDC(), &r, m_hBrush); // draw the progress switch(m_eStyle) { case STYLE_CURSOR: { int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax, (float)1, (float)(GetWidth() - m_nCursorWidth-1), m_fPos); r.left = nCursorPos; r.right = r.left + m_nCursorWidth; FillRect(rGfx.GetHDC(), &r, m_hBrush); } break; case STYLE_FILLED: { int nBarWidth = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax, 0.0f, (float)GetWidth(), m_fPos); r.right = nBarWidth; FillRect(rGfx.GetHDC(), &r, m_hBrush); } break; default: break; } }
void CLCDProgressBar::OnDraw(CLCDGfx &rGfx) { HPEN hOldPen; rGfx.ClearScreen(); // draw the border RECT r = { 0, 0, GetWidth(), GetHeight() }; FrameRect(rGfx.GetHDC(), &r, m_hBrush); // draw the progress switch(m_eStyle) { case STYLE_CURSOR: { int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax, (float)1, (float)(GetWidth() - m_nCursorWidth-1), m_Pos); r.left = nCursorPos; r.right = r.left + m_nCursorWidth; FillRect(rGfx.GetHDC(), &r, m_hBrush); } break; case STYLE_FILLED_V: case STYLE_FILLED_H: { int nBar = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax, 0.0f, (m_eStyle == STYLE_FILLED_H ? (float)GetWidth() : (float)GetHeight())-4, m_Pos); r.left = r.left+2; r.bottom = r.bottom-2; if (m_eStyle == STYLE_FILLED_H) { r.right = nBar+2; r.top = r.top+2; } else { r.right = r.right-2; r.top = r.bottom-nBar; } FillRect(rGfx.GetHDC(), &r, m_hBrush); } break; case STYLE_DASHED_CURSOR: { int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax, (float)1, (float)(GetWidth() - m_nCursorWidth-1), m_Pos); r.left = nCursorPos; r.right = r.left + m_nCursorWidth; FillRect(rGfx.GetHDC(), &r, m_hBrush); hOldPen = (HPEN)::SelectObject(rGfx.GetHDC(), m_hPen); ::MoveToEx(rGfx.GetHDC(), 0, (r.bottom - r.top)/2, NULL); ::LineTo(rGfx.GetHDC(), nCursorPos, (r.bottom - r.top)/2); ::SelectObject(rGfx.GetHDC(), hOldPen); } break; default: break; } }