我做了一个类,基于CStatic的, 我想让这个类create出来的是白色的底色,怎么实现?

解决方案 »

  1.   

    给我你的email,我给你一个例子!:)
      

  2.   

    添加对WM_CTLCOLOR消息的处理。
      

  3.   

    如何改变控件的颜色
    http://vcfly.home.chinaren.com/vcstudy/2/2-2-2.htm
      

  4.   

    重载消息函数PreCreateWindow(),在函数中添加程序:
       CBrush brush(RGB(255,255,255));
       SetClassLong(GetSafeHwnd( ) ,GCL_HBRBACKGROUND,(LONG)(HBRUSH)brush);
    你试一下。
      

  5.   

    void CMyStatic::OnPaint() 
    {
    CPaintDC dc(this); // device context for painting

    // TODO: Add your message handler code here
        RECT   rc;
        HBRUSH hbrFace = CreateSolidBrush( RGB(255,255,255) );    memset( &rc, 0, sizeof( rc ) );
        GetClientRect( &rc );
        InvalidateRect( &rc, FALSE );
        FillRect( dc.m_hDC, &rc, hbrFace );
        SetBkColor( dc.m_hDC, RGB( 255, 255, 255 ));
        InflateRect( &rc, -1, -1 );
        DeleteObject( hbrFace   );
    // Do not call CStatic::OnPaint() for painting messages
    }