好象有个API,记不清了,查查再回复

解决方案 »

  1.   

    void CMenu::DrawGradRect(CDC *pDC, CRect rect, COLORREF cr1, 
       COLORREF cr2, BOOL bHor)
    {
    int r1 = GetRValue(cr1);
    int g1 = GetGValue(cr1);
    int b1 = GetBValue(cr1); int r2 = GetRValue(cr2);
    int g2 = GetGValue(cr2);
    int b2 = GetBValue(cr2); if(bHor)
    {
    float dr = ((float)(r2 - r1))/(float)(rect.Width());
    float dg = ((float)(g2 - g1))/(float)(rect.Width());
    float db = ((float)(b2 - b1))/(float)(rect.Width());

    for(int i = rect.left; i < rect.right; i ++)
    {
    int r = r1 + (int)(dr*((float)(i - rect.left)));
    int g = g1 + (int)(dg*((float)(i - rect.left)));
    int b = b1 + (int)(db*((float)(i - rect.left)));
    CPen pen(PS_SOLID, 1, RGB(r, g, b));
    CPen *old = pDC->SelectObject(&pen);
    pDC->MoveTo(i, rect.top);
    pDC->LineTo(i, rect.bottom);
    pDC->SelectObject(old);
    }
    }
    else
    {
    float dr = ((float)(r2 - r1))/(float)(rect.Height());
    float dg = ((float)(g2 - g1))/(float)(rect.Height());
    float db = ((float)(b2 - b1))/(float)(rect.Height());

    for(int i = rect.top; i < rect.bottom; i ++)
    {
    int r = r1 + (int)(dr*((float)(i - rect.top)));
    int g = g1 + (int)(dg*((float)(i - rect.top)));
    int b = b1 + (int)(db*((float)(i - rect.top)));
    CPen pen(PS_SOLID, 1, RGB(r, g, b));
    CPen *old = pDC->SelectObject(&pen);
    pDC->MoveTo(rect.left, i);
    pDC->LineTo(rect.right, i);
    pDC->SelectObject(old);
    }
    }
    }
      

  2.   

    使用新的Paltform SDK吧,里面有这样的类,称为GDI+的东西
      

  3.   

    我给的这个函数就是画背景的哦DrawGradRect自己响应消息就可以了