我有三个数,int nR  = 255,nG  128,nB = 0;
COLORREF clr;
怎么将这三个数写进 clr ? 
最终实现 clr = 0xff8000 ...

解决方案 »

  1.   

    RGB 宏COLORREF RGB(
      BYTE byRed,    // red component of color
      BYTE byGreen,  // green component of color
      BYTE byBlue    // blue component of color
    );
      

  2.   

    RGB(RED,GREEN,BLUE);
    其中的255 就是ff,128就是80,0就是00
    写个函数吧unsigned int(int R,int G,int B)
    {
        unsigned int x;
        x = R<<16;
        x|= (G<<8);
        x|= B;
        return x;
    }
      

  3.   

    COLORREF clr=RGB((BYTE)nR,(BYTE)nG,(BYTE)nB);