void COLORREFTOCOLOR16(COLORREF color,COLOR16* R,COLOR16* G,COLOR16* B)
{
BYTE red = GetRValue(color); // the red value in the range 0-255
BYTE green = GetGValue(color);
BYTE blue = GetBValue(color);
*R = (COLOR16)(red * 256); // multiply to convert it to the range of COLOR16
*G= (COLOR16)(green * 256);
*B= (COLOR16)(blue * 256);
}
void CCOMTextDlg::OnPaint()
{
CPaintDC dc(this);
CRect r(10,10,100,54);
dc.RoundRect(&r,CPoint(3,3));
COLOR16 R,G,B;
COLORREFTOCOLOR16(RGB(113,113,114),&R,&G,&B);
COLOR16 R1,G1,B1;
COLORREFTOCOLOR16(RGB(58,58,58),&R1,&G1,&B1);
TRIVERTEX vert[2] ;
GRADIENT_RECT gRect;
vert [0] .x = 11;
vert [0] .y = 11;
vert [0] .Red = R;
vert [0] .Green = G;
vert [0] .Blue = B;
vert [0] .Alpha = 0x0000;
vert [1] .x = 99;
vert [1] .y = 31;
vert [1] .Red = R1;
vert [1] .Green = G1;
vert [1] .Blue = B1;
vert [1] .Alpha = 0x0019;
gRect.UpperLeft = 0;
gRect.LowerRight = 1;
GradientFill(dc.m_hDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_V);
COLORREFTOCOLOR16(RGB(13,13,13),&R,&G,&B);
COLORREFTOCOLOR16(RGB(30,30,31),&R1,&G1,&B1);
//图2
TRIVERTEX vert2[2] ;
GRADIENT_RECT gRect2;
vert2 [0] .x = 11;
vert2 [0] .y = 31;
vert2 [0] .Red = R;
vert2 [0] .Green = G;
vert2 [0] .Blue = B;
vert2 [0] .Alpha = 0x0000;
vert2 [1] .x = 99;
vert2 [1] .y = 53;
vert2 [1] .Red = R1;
vert2 [1] .Green = G1;
vert2 [1] .Blue = B1;
vert2 [1] .Alpha = 0x0000;
gRect2.UpperLeft = 0;
gRect2.LowerRight = 1;
GradientFill(dc.m_hDC,vert2,2,&gRect2,1,GRADIENT_FILL_RECT_V);
CPen Pen;
Pen.CreatePen(PS_SOLID, 1, RGB(142,142,143));
dc.SelectObject( &Pen );
dc.MoveTo(12,11);
dc.LineTo(98,11);
}