本人编写一个程序,让用户在Edit Box中输入RGB的R、G、 B的值然后,在一个控件(如:Static)中显示输入的相应颜色,不知怎样实现,小弟不才,请高手指教。谢谢!!!

解决方案 »

  1.   

    得到相应的RGB值!在控件CWnd *pWnd = GetDlgItem(ID_STATIC);
    CDC * pMyDC = pWnd->GetDC();
    CBrush brush(RGB( r,g,b));
    CRect rect = pWnd->GetWindowRect( &rect) 
    pMyDC->FillRect(&rect,&brush);pWnd->ReleaseDC();
      

  2.   

    CWnd::GetWindowRect
    void GetWindowRect( LPRECT lpRect ) const;ParameterslpRectPoints to a CRect object or a RECT structure that will receive the screen coordinates of the upper-left and lower-right corners.
      

  3.   

    CDC::FillRect
    void FillRect( LPCRECT lpRect, CBrush* pBrush );ParameterslpRectPoints to a RECT structure that contains the logical coordinates of the rectangle to be filled. You can also pass a CRect object for this parameter.pBrushIdentifies the brush used to fill the rectangle.