滑块已经基本实现我们的要求了。
接下来实现基本功能:
1.RGB<==>HSV(新建一个类 CColorConvert)
头文件ColorConvert.h
// ColorConvert.h: interface for the CColorConvert class.
//

/**///////////////////////////////////////////////////////////////////////
#if !defined(AFX_COLORCONVERT_H__C06B43EE_791D_407B_ADC2_3A3EA91FE13C__INCLUDED_)
#define AFX_COLORCONVERT_H__C06B43EE_791D_407B_ADC2_3A3EA91FE13C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef struct...{
int R;
int G;
int B;
}TRGBColor;


typedef struct...{
int H;
int S;
int V;
}THSBColor;
class CColorConvert

...{
public:
static THSBColor RGB2HSB(TRGBColor rgb);
static TRGBColor HSB2RGB(THSBColor hsv);
CColorConvert();
virtual ~CColorConvert();

};

#endif // !defined(AFX_COLORCONVERT_H__C06B43EE_791D_407B_ADC2_3A3EA91FE13C__INCLUDED_)

ColorConvert.cpp
// ColorConvert.cpp: implementation of the CColorConvert class.
//

/**///////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DoodlePanel.h"
#include "ColorConvert.h"
#include "math.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


/**///////////////////////////////////////////////////////////////////////
// Construction/Destruction

/**///////////////////////////////////////////////////////////////////////
CColorConvert::CColorConvert()

...{

}

CColorConvert::~CColorConvert()

...{

}

TRGBColor CColorConvert::HSB2RGB(THSBColor hsv)

...{
TRGBColor rgb;
int i;
float f,p,q,t;

if(hsv.S==0)...{

if(hsv.V==0)...{
rgb.B=rgb.G=rgb.R=0;

}else...{
rgb.B=rgb.G=rgb.R=(int)(hsv.V*255/100);
}
return rgb;
}
float r,g,b,h,s,v;
if(hsv.H==360)
h=0;
else
h=(float)hsv.H;
h /=60;
s=(float)(hsv.S)/100;
v=(float)(hsv.V)/100;

i=(int)floor(h);

f=h-(float)i;
p=v *(1-s);
q=v *(1-s *f);
t=v *(1-s *(1-f));

switch(i)...{
case 0:
r=v;g=t;b=p;break;
case 1:
r=q;g=v;b=p;break;
case 2:
r=p;g=v;b=t;break;
case 3:
r=p;g=q;b=v;break;
case 4:
r=t;g=p;b=v;break;
default:
r=v;g=p;b=q;break;
}
rgb.R =(int)(r * 255);
rgb.G= (int)(g * 255);
rgb.B= (int)(b * 255);
return rgb;
}

THSBColor CColorConvert::RGB2HSB(TRGBColor rgb)

...{
THSBColor hsv;
float r = (float)(rgb.R) / 255;
float g = (float)(rgb.G) / 255;
float b = (float)(rgb.B) / 255;
float h,s,v;
float min = 0;
float max = 0;
float delta=0;

if (r >= g && r >= b) ...{
max = r;
min = (g > b) ? b : g;

} else if (g >= b && g >= r) ...{
max = g;
min = (r > b) ? b : r;

} else ...{
max = b;
min = (g > r) ? r : g;
}
v = max;
s = (max) ? ((max - min) / max) : 0;

if (!s) ...{
h = 0;

} else ...{
delta = max - min;

if (r == max) ...{
h = (g - b) / delta;

} else if (g == max) ...{
h = 2 + (b - r) / delta;

} else ...{
h = 4 + (r - g) / delta;
}
hsv.H = (int)(h * 60);

if (hsv.H < 0) ...{
hsv.H += 360;
}
}
hsv.S = (int)(s * 100);
hsv.V = (int)(v * 100);
return hsv;
}

然后在我们的面板中实现WM_HSCroll
void CColorPanel::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)

...{
// TODO: Add your message handler code here and/or call default
CWnd::OnHScroll(nSBCode, nPos, pScrollBar);
m_nH=m_Slider[0].GetPos();
m_nS=m_Slider[1].GetPos();
m_nB=m_Slider[2].GetPos();
CClientDC dc(this);
CRect rect;
GetWindowRect(rect);
THSBColor hsv;
hsv.H=m_nH;
hsv.S=m_nS;
hsv.V=m_nB;

rgb=CColorConvert::HSB2RGB(hsv);
dc.FillSolidRect(rect.left+2, rect.top+2,rect.Width()-4, rect.Height()-4,RGB(rgb.R,rgb.G,rgb.B));
CString str;
str.Format(" R:%d;G:%d;B:%d",rgb.R,rgb.G,rgb.B);
dc.TextOut(10,125,str);
str.Format(" H:%d;S:%d;B:%d",m_nH,m_nS,m_nB);
dc.TextOut(10,145,str);

}
最后看看效果:

至于TM2008中改变整个应用程序的肤色,我们这里就不去实现了。这个面板的基本功能我们已经完成。