www.pudn.com > PressMonitor_q.zip > 3DSliderCtrl.cpp
// 3DSliderCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "3DSliderCtrl.h"
#include "MemDC.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static COLORREF tmpColor[]=
{
RGB(0,0,0), RGB(0,0,160),RGB(128,0,128), RGB(26,166,57),
RGB(0,128,0),RGB(0,128,128),RGB(220,0,0),RGB(128,128,0)
};
/////////////////////////////////////////////////////////////////////////////
// C3DSliderCtrl
#define PANE_LEFT 5
#define PANE_RIGHT 5
#define PANE_TOP 20
#define PANE_BOTTOM 60
C3DSliderCtrl::C3DSliderCtrl()
{
m_CurrentValue =0;
//fontHeight Value
m_nScaleHeight = 12;
m_nUnitHeight = 12;
m_nNameHeight = 12;
m_nValueHeight = 14;
m_nScaleStep = 4;
m_MiniValue = 0;
m_MaxiValue = 24;
m_strUnit = "mm";
m_strName = "";
m_nFrameWidth = 4;
m_crWindowText = GetSysColor(COLOR_WINDOWTEXT);
m_crWindow = GetSysColor(COLOR_WINDOW);
m_cr3DFace = GetSysColor(COLOR_3DFACE);
m_crShadow = GetSysColor(COLOR_3DSHADOW) ;
m_crDkShadow = GetSysColor(COLOR_3DDKSHADOW);
m_crLight = GetSysColor(COLOR_3DLIGHT);
m_crHighlight = GetSysColor(COLOR_3DHIGHLIGHT) ;
m_crFrame = GetSysColor(COLOR_3DFACE);
m_crSlider = GetSysColor(COLOR_3DFACE);
m_crSliderBack = RGB(255,255,255);
m_crPane = GetSysColor(COLOR_3DFACE);
m_crScale = GetSysColor(COLOR_WINDOWTEXT);
m_crValue = GetSysColor(COLOR_WINDOW);
m_crValueBack = RGB(0,128,192);//GetSysColor(COLOR_WINDOWTEXT);
m_crName = RGB(0,64,128);
m_crRulerScale = RGB(255,255,255);
m_crProgress = RGB(255,0,0);
}
C3DSliderCtrl::~C3DSliderCtrl()
{
if ((m_pBitmapOldBackground) &&
(m_bitmapBackground.GetSafeHandle()) &&
(m_dcBackground.GetSafeHdc()))
{
m_dcBackground.SelectObject(m_pBitmapOldBackground);
m_dcBackground.DeleteDC() ;
m_bitmapBackground.DeleteObject();
}
}
BEGIN_MESSAGE_MAP(C3DSliderCtrl, CStatic)
//{{AFX_MSG_MAP(C3DSliderCtrl)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// C3DSliderCtrl message handlers
BOOL C3DSliderCtrl::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
}
void C3DSliderCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
// Find out how big we are
GetClientRect (&m_rectCtrl) ;
// ULONG totalNumber = m_BarItemArray.GetSize();
// if(totalNumber <=0)
// {
// TRACE("OnPaint(): No items!\n");
// return;
// }
// make a memory dc
CMemDC memDC(&dc, &m_rectCtrl);
// set up a memory dc for the background stuff
// if one isn't being used
if ((m_dcBackground.GetSafeHdc() == NULL) || (m_bitmapBackground.m_hObject == NULL))
{
m_dcBackground.CreateCompatibleDC(&dc) ;
m_bitmapBackground.CreateCompatibleBitmap(&dc, m_rectCtrl.Width(), m_rectCtrl.Height()) ;
m_pBitmapOldBackground = m_dcBackground.SelectObject(&m_bitmapBackground) ;
// Fill this bitmap with the background.
// Note: This requires some serious drawing and calculating,
// therefore it is drawn "once" to a bitmap and
// the bitmap is stored and blt'd when needed.
DrawFrame(&m_dcBackground);
DrawPane(&m_dcBackground);
DrawRuler(&m_dcBackground);
DrawScale(&m_dcBackground);
DrawValueBack(&m_dcBackground);
}
// drop in the background
memDC.BitBlt(0, 0, m_rectCtrl.Width(), m_rectCtrl.Height(),
&m_dcBackground, 0, 0, SRCCOPY) ;
DrawValue(&memDC);
DrawProgress(&memDC);
DrawSlider(&memDC);
}
void C3DSliderCtrl::OnSize(UINT nType, int cx, int cy)
{
CStatic::OnSize(nType, cx, cy);
ReconstructControl() ;
}
void C3DSliderCtrl::ReconstructControl()
{
TRACE("C3DSliderCtrl::ReconstructControl()\n");
// if we've got a stored background - remove it!
if ((m_pBitmapOldBackground) &&
(m_bitmapBackground.GetSafeHandle()) &&
(m_dcBackground.GetSafeHdc()))
{
m_dcBackground.SelectObject(m_pBitmapOldBackground);
m_dcBackground.DeleteDC() ;
m_bitmapBackground.DeleteObject();
m_bitmapBackground.Detach();
}
ReCalculating();
Invalidate () ;
}
void C3DSliderCtrl::DrawFrame(CDC *pDC)
{
CPen penFrame,penHighlight,penDkShadow,*pPenOld;
penFrame.CreatePen(PS_SOLID, m_nFrameWidth*2,m_crFrame) ;
penHighlight.CreatePen(PS_SOLID, 1, m_crHighlight) ;
penDkShadow.CreatePen(PS_SOLID, 1, m_crDkShadow) ;
CBrush brushBack,*pBrushOld;
brushBack.CreateSolidBrush(m_crSliderBack) ;
// 画外边框
pPenOld = pDC->SelectObject(&penFrame) ;
pBrushOld = pDC->SelectObject(&brushBack) ;
pDC->Rectangle(m_rectCtrl) ;
/*
// draw the left and top sides with the highlight
pDC->SelectObject(&penHighlight) ;
pDC->MoveTo(m_rectCtrl.left, m_rectCtrl.bottom) ;
pDC->LineTo(m_rectCtrl.left, m_rectCtrl.top) ;
pDC->LineTo(m_rectCtrl.right-1, m_rectCtrl.top) ;
// draw the right and bottom sides with the shadow
pDC->SelectObject(&penDkShadow) ;
pDC->LineTo(m_rectCtrl.right-1, m_rectCtrl.bottom-1) ;
pDC->LineTo(m_rectCtrl.left, m_rectCtrl.bottom-1) ;
*/
// draw the left and top sides with the shadow
pDC->SelectObject(&penDkShadow) ;
pDC->MoveTo(m_rectPane.left, m_rectPane.bottom) ;
pDC->LineTo(m_rectPane.left, m_rectPane.top) ;
pDC->LineTo(m_rectPane.right-1, m_rectPane.top) ;
// draw the right and bottom sides with the highlight
pDC->SelectObject(&penHighlight) ;
pDC->LineTo(m_rectPane.right-1, m_rectPane.bottom-1) ;
pDC->LineTo(m_rectPane.left, m_rectPane.bottom-1) ;
pDC->SelectObject(pPenOld);
pDC->SelectObject(pBrushOld);
}
void C3DSliderCtrl::DrawPane(CDC *pDC)
{
CBrush brushPane,*pBrushOld;
brushPane.CreateSolidBrush(m_crPane) ;
CPen penShadow,penHighlight,*pPenOld;
penShadow.CreatePen(PS_SOLID, 1, m_crDkShadow) ;
penHighlight.CreatePen(PS_SOLID, 1, m_crHighlight) ;
pBrushOld=pDC->SelectObject(&brushPane) ;
// Draw Pane left part
pDC->FillRect(CRect(m_rectPaneLeft.left+1, m_rectPaneTop.top+1,
m_rectSlide.left, m_rectPaneBottom.bottom-1),
&brushPane);
//Draw Pane right part
pDC->FillRect(CRect(m_rectSlide.right, m_rectPaneTop.top+1,
m_rectPaneRight.right-1, m_rectPaneBottom.bottom-1),
&brushPane);
// Draw Pane top part
pDC->FillRect(CRect(m_rectPaneTop.left, m_rectPaneTop.top+1,
m_rectPaneTop.right, m_rectSlide.top),
&brushPane);
// Draw Pane bottom part
pDC->FillRect(CRect(m_rectPaneBottom.left, m_rectSlide.bottom,
m_rectPaneBottom.right, m_rectPaneBottom.bottom-1),
&brushPane);
//对Chart区画3D边框
// draw the left and top sides with the shadow
pPenOld=pDC->SelectObject(&penShadow) ;
pDC->MoveTo(m_rectSlide.left-1, m_rectSlide.bottom+1) ;
pDC->LineTo(m_rectSlide.left-1, m_rectSlide.top-1) ;
pDC->LineTo(m_rectSlide.right+1, m_rectSlide.top-1) ;
// pDC->MoveTo(m_rectSlide.left-2, m_rectSlide.bottom+2) ;
// pDC->LineTo(m_rectSlide.left-2, m_rectSlide.top-2) ;
// pDC->LineTo(m_rectSlide.right+2, m_rectSlide.top-2) ;
// draw the right and bottom sides with the highlight
pDC->SelectObject(&penHighlight) ;
pDC->MoveTo(m_rectSlide.right+1, m_rectSlide.top-1) ;
pDC->LineTo(m_rectSlide.right+1, m_rectSlide.bottom+1) ;
pDC->LineTo(m_rectSlide.left-1, m_rectSlide.bottom+1) ;
// pDC->MoveTo(m_rectSlide.right+2, m_rectSlide.top-2) ;
// pDC->LineTo(m_rectSlide.right+2, m_rectSlide.bottom+2) ;
// pDC->LineTo(m_rectSlide.left-2, m_rectSlide.bottom+2) ;
pDC->SelectObject(pPenOld);
pDC->SelectObject(pBrushOld);
}
void C3DSliderCtrl::DrawRuler(CDC *pDC)
{
int xx;
double nWidth;
CPen penRulerScale,*pPenOld;
penRulerScale.CreatePen(PS_SOLID,1,m_crRulerScale);
pPenOld=pDC->SelectObject(&penRulerScale);
nWidth=m_rectSlide.Width()*1.0/m_nScaleStep;
for(int i=0;i<=m_nScaleStep;i++)
{
xx = m_rectSlide.left +(int)(i * nWidth);
pDC->MoveTo(xx,m_rectSlide.top-3);
pDC->LineTo(xx,m_rectSlide.top-11);
}
for(i=0;i<=5*m_nScaleStep;i++)
{
xx = m_rectSlide.left +(int)(0.2 * i * nWidth);
pDC->MoveTo(xx,m_rectSlide.top-3);
pDC->LineTo(xx,m_rectSlide.top-7);
}
for(i=0;i<=m_nScaleStep;i++)
{
xx = m_rectSlide.left +(int)(i * nWidth);
pDC->MoveTo(xx,m_rectSlide.bottom+3);
pDC->LineTo(xx,m_rectSlide.bottom+11);
}
for(i=0;i<=5*m_nScaleStep;i++)
{
xx = m_rectSlide.left +(int)(0.2 * i * nWidth);
pDC->MoveTo(xx,m_rectSlide.bottom+3);
pDC->LineTo(xx,m_rectSlide.bottom+7);
}
pDC->SelectObject(pPenOld);
}
void C3DSliderCtrl::DrawScale(CDC *pDC)
{
int xx;
double nWidth;
CString pStr;
CRect rectScale;
CFont fontUse,*pFontOld;
fontUse.CreateFont(m_nScaleHeight,0,0,0,400,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Times New Roman") ;
pFontOld=pDC->SelectObject(&fontUse);
int nBkModeOld=pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(m_crScale);
nWidth=m_rectSlide.Width()*1.0/ m_nScaleStep;
for(int i=0; i<= (int)m_nScaleStep ;i++)
{
pStr.Format("%d", (int)(m_MiniValue + (m_MaxiValue - m_MiniValue) * i/ m_nScaleStep));
xx = m_rectPaneBottom.left+(int)(i*nWidth);
rectScale.SetRect(xx-(int)(nWidth/2),m_rectPaneBottom.top+11,xx+(int)(nWidth/2),m_rectPaneBottom.bottom);
pDC->DrawText(pStr,&rectScale,DT_CENTER|DT_TOP|DT_SINGLELINE);
}
pDC->SelectObject(pFontOld);
pDC->SetBkMode(nBkModeOld);
}
BOOL C3DSliderCtrl::ReCalculating()
{
GetClientRect(&m_rectCtrl);
m_rectPane=m_rectCtrl;
m_rectPane.DeflateRect(m_nFrameWidth,m_nFrameWidth,m_nFrameWidth,m_nFrameWidth);
m_rectPaneLeft.left=m_rectPane.left;
m_rectPaneLeft.right=m_rectPane.left+m_rectPane.Width()*PANE_LEFT/100;
m_rectPaneLeft.top=m_rectPane.top+m_rectPane.Height()*PANE_TOP/100;
m_rectPaneLeft.bottom=m_rectPane.bottom-m_rectPane.Height()*PANE_BOTTOM/100;
m_rectPaneRight.left=m_rectPane.right-m_rectPane.Width()*PANE_RIGHT/100;
m_rectPaneRight.right=m_rectPane.right;
m_rectPaneRight.top=m_rectPane.top+m_rectPane.Height()*PANE_TOP/100;
m_rectPaneRight.bottom=m_rectPane.bottom-m_rectPane.Height()*PANE_BOTTOM/100;
m_rectPaneTop.left=m_rectPane.left+m_rectPane.Width()*PANE_LEFT/100;
m_rectPaneTop.right=m_rectPane.right-m_rectPane.Width()*PANE_RIGHT/100;
m_rectPaneTop.top=m_rectPane.top;
m_rectPaneTop.bottom=m_rectPane.top+m_rectPane.Height()*PANE_TOP/100;
m_rectPaneBottom.left=m_rectPane.left+m_rectPane.Width()*PANE_LEFT/100;
m_rectPaneBottom.right=m_rectPane.right-m_rectPane.Width()*PANE_RIGHT/100;
m_rectPaneBottom.top=m_rectPane.bottom-m_rectPane.Height()*PANE_BOTTOM/100;
m_rectPaneBottom.bottom=m_rectPane.bottom;
m_rectSlide.left=m_rectPane.left+m_rectPane.Width()*PANE_LEFT/100;
m_rectSlide.right=m_rectPane.right-m_rectPane.Width()*PANE_RIGHT/100;
m_rectSlide.top=m_rectPane.top+m_rectPane.Height()*PANE_TOP/100;
m_rectSlide.bottom=m_rectPane.bottom-m_rectPane.Height()*PANE_BOTTOM/100;
//设置字体高度
m_nNameHeight=(int)(m_rectPaneTop.Height()*0.45);
m_nValueHeight=(int)(m_rectPaneBottom.Height()*0.4);
m_nScaleHeight=(int)(m_rectPaneLeft.Height()*0.85);
m_nUnitHeight=(int)(m_rectPaneBottom.Height()*0.2);
m_rectValue.left=m_rectPaneBottom.CenterPoint().x-m_rectPaneBottom.Width()/5;
m_rectValue.right=m_rectPaneBottom.CenterPoint().x+m_rectPaneBottom.Width()/5;
m_rectValue.top=m_rectPaneBottom.top+m_nScaleHeight+11;
m_rectValue.bottom=m_rectPaneBottom.bottom-4;
return TRUE;
}
BOOL C3DSliderCtrl::Initialize()
{
SetScaleFromToValue(-200,200,4);
return ReCalculating();
}
BOOL C3DSliderCtrl::SetScaleFromToValue(float from, float to, int ValueStep)
{
m_MiniValue = (float)from;
m_MaxiValue = (float)to;
if(to<=from)
{
TRACE("From Value >= To Value, Cannot create Chart!\n");
return false;
}
m_nScaleStep = ValueStep ;
return true;
}
void C3DSliderCtrl::DrawValue(CDC *pDC)
{
CString pStr;
CRect rectValue;
CFont fontUse,*pFontOld;
fontUse.CreateFont(m_nValueHeight,0,0,0,300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Times New Roman") ;
pFontOld=pDC->SelectObject(&fontUse);
int nBkModeOld=pDC->SetBkMode(TRANSPARENT);
// pDC->SetBkColor(RGB(128,128,255));
pDC->SetTextColor(m_crValue);
pStr.Format("%3.1f", GetValue());
//pStr+=GetUnit();
pDC->DrawText(pStr,&m_rectValue,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
pDC->SelectObject(pFontOld);
pDC->SetBkMode(nBkModeOld);
}
CString C3DSliderCtrl::GetName()
{
return m_strName;
}
void C3DSliderCtrl::SetName(CString strName)
{
m_strName=strName;
}
float C3DSliderCtrl::GetValue()
{
return m_CurrentValue;
}
void C3DSliderCtrl::SetValue(float nValue)
{
m_CurrentValue=nValue;
}
void C3DSliderCtrl::DrawValueBack(CDC *pDC)
{
CPen penShadow,penHighlight,penValueBack,*pPenOld;
penShadow.CreatePen(PS_SOLID, 1, m_crShadow) ;
penHighlight.CreatePen(PS_SOLID, 1, m_crHighlight) ;
penValueBack.CreatePen(PS_SOLID, 1, m_crValueBack) ;
CBrush brushValueBack,*pBrushOld;
brushValueBack.CreateSolidBrush(m_crValueBack) ;
// Draw the recessed rectangle
// for the numerical value.
// draw the left and top sides with the shadow
pPenOld=pDC->SelectObject(&penShadow) ;
pDC->MoveTo(m_rectValue.left, m_rectValue.bottom) ;
pDC->LineTo(m_rectValue.left, m_rectValue.top) ;
pDC->LineTo(m_rectValue.right, m_rectValue.top) ;
// draw the right and bottom sides with the highlight
pDC->SelectObject(&penHighlight) ;
pDC->LineTo(m_rectValue.right, m_rectValue.bottom) ;
pDC->LineTo(m_rectValue.left, m_rectValue.bottom) ;
pDC->SelectObject(&penValueBack) ;
pBrushOld=pDC->SelectObject(&brushValueBack) ;
pDC->Rectangle(m_rectValue);
pDC->SelectObject(pPenOld);
pDC->SelectObject(pBrushOld);
}
void C3DSliderCtrl::DrawSlider(CDC *pDC)
{
int x;
CPen penLight,penDkShadow,penHighlight,penShadow,*pPenOld;
penLight.CreatePen(PS_SOLID, 1, m_crLight) ;
penDkShadow.CreatePen(PS_SOLID, 1, m_crDkShadow) ;
penHighlight.CreatePen(PS_SOLID, 1, m_crHighlight) ;
penShadow.CreatePen(PS_SOLID, 1, m_crShadow) ;
CBrush brushSlider,*pBrushOld;
brushSlider.CreateSolidBrush(m_crSlider) ;
static CPoint Left[] =
{
CPoint(m_rectSlide.left,m_rectSlide.bottom+m_rectSlide.Height()/2),
CPoint(m_rectSlide.left-m_rectSlide.Width()/30,m_rectSlide.bottom),
CPoint(m_rectSlide.left-m_rectSlide.Width()/30,m_rectSlide.top-m_rectSlide.Height()/5),
CPoint(m_rectSlide.left+m_rectSlide.Width()/30,m_rectSlide.top-m_rectSlide.Height()/5),
CPoint(m_rectSlide.left+m_rectSlide.Width()/30,m_rectSlide.bottom),
};
#define LEFT_LEN (sizeof(Left)/sizeof(Left[0]))
CPoint pointSlider[LEFT_LEN];
x=(int)((m_CurrentValue-m_MiniValue)*m_rectSlide.Width()/(m_MaxiValue-m_MiniValue));
// draw the slider
for (int i = 0; i < LEFT_LEN; i++)
{
pointSlider[i] = Left[i];
pointSlider[i].Offset(x, 0);
}
pBrushOld=pDC->SelectObject(&brushSlider) ;
CRgn SliderRgn;
SliderRgn.CreatePolygonRgn(pointSlider, LEFT_LEN, ALTERNATE);
pDC->FillRgn(&SliderRgn, &brushSlider);
// Draw the recessed rectangle
// for the numerical value.
// draw the left and top sides with the light
pPenOld=pDC->SelectObject(&penLight) ;
pDC->MoveTo(pointSlider[0]);
pDC->LineTo(pointSlider[1]);
pDC->LineTo(pointSlider[2]);
pDC->LineTo(pointSlider[3]);
// draw the right and bottom sides with the shadow
pDC->SelectObject(&penDkShadow) ;
pDC->LineTo(pointSlider[4]);
pDC->LineTo(pointSlider[0]);
// draw the left and top sides with the Highlight
pDC->SelectObject(&penHighlight) ;
pDC->MoveTo(pointSlider[0].x,pointSlider[0].y-1);
pDC->LineTo(pointSlider[1].x+1,pointSlider[1].y);
pDC->LineTo(pointSlider[2].x+1,pointSlider[2].y+1);
pDC->LineTo(pointSlider[3].x-1,pointSlider[3].y+1);
// draw the right and bottom sides with the shadow
pDC->SelectObject(&penShadow) ;
pDC->LineTo(pointSlider[4].x-1,pointSlider[4].y);
pDC->LineTo(pointSlider[0].x,pointSlider[0].y-1);
pDC->SelectObject(pPenOld);
pDC->SelectObject(pBrushOld);
}
void C3DSliderCtrl::DrawProgress(CDC *pDC)
{
int x;
CRect rectTemp;
x=m_rectSlide.left+(int)((m_CurrentValue-m_MiniValue)*m_rectSlide.Width()/(m_MaxiValue-m_MiniValue));
if(x>=m_rectSlide.CenterPoint().x)
{
rectTemp.SetRect(m_rectSlide.CenterPoint().x,m_rectSlide.top,m_rectSlide.right,m_rectSlide.bottom);
DrawGradient(pDC, rectTemp,x,RGB(255,196,196),m_crProgress,true);
}
else
{
rectTemp.SetRect(m_rectSlide.left,m_rectSlide.top,m_rectSlide.CenterPoint().x,m_rectSlide.bottom);
DrawGradient(pDC,rectTemp,x,RGB(255,196,196),m_crProgress,false);
}
}
void C3DSliderCtrl::DrawGradient(CDC *pDC, const CRect &rect, const int &nMaxWidth,COLORREF crStart,COLORREF crEnd,BOOL ascend /*= true*/)
{
CRect rectFill; // Rectangle for filling band
float fStep; // How wide is each band?
// First find out the largest color distance between the start and end colors. This distance
// will determine how many steps we use to carve up the client region and the size of each
// gradient rect.
int r, g, b; // First distance, then starting value
float rStep, gStep, bStep; // Step size for each color
// Get the color differences
r = (GetRValue(crEnd) - GetRValue(crStart));
g = (GetGValue(crEnd) - GetGValue(crStart));
b = (GetBValue(crEnd) - GetBValue(crStart));
// Make the number of steps equal to the greatest distance
int nSteps = max(abs(r), max(abs(g), abs(b)));
// Determine how large each band should be in order to cover the
// client with nSteps bands (one for every color intensity level)
fStep = (float)rect.Width() / (float)nSteps;
// Calculate the step size for each color
rStep = r/(float)nSteps;
gStep = g/(float)nSteps;
bStep = b/(float)nSteps;
// Reset the colors to the starting position
r = GetRValue(crStart);
g = GetGValue(crStart);
b = GetBValue(crStart);
// Start filling bands
for (int iOnBand = 0; iOnBand < nSteps; iOnBand++)
{
if(ascend) // Paint from left to right;
{
rectFill.SetRect(rect.left+(int)(iOnBand * fStep), // Upper left X
rect.top, // Upper left Y
rect.left+(int)((iOnBand+1) * fStep), // Lower right X
rect.bottom); // Lower right Y
PaintRect(pDC,rectFill,RGB(r+rStep*iOnBand, g + gStep*iOnBand, b + bStep *iOnBand));
// If we are past the maximum for the current position we need to get out of the loop.
// Before we leave, we repaint the remainder of the client area with the background color.
if (rectFill.right >nMaxWidth )
{
break;
}
}
else // Paint from right to left;
{
rectFill.SetRect(rect.right-(int)((iOnBand+1) * fStep), // Upper left X
rect.top, // Upper left Y
rect.right-(int)(iOnBand * fStep), // Lower right X
rect.bottom); // Lower right Y
PaintRect(pDC,rectFill,RGB(r+rStep*iOnBand, g + gStep*iOnBand, b + bStep *iOnBand));
// If we are past the maximum for the current position we need to get out of the loop.
// Before we leave, we repaint the remainder of the client area with the background color.
if (rectFill.left SelectObject(&brush);
pDC->FillRect(&rect,&brush);
pDC->SelectObject(pOldBrush);
}