见笑,怎样改变窗口的背景色啊?

解决方案 »

  1.   

    得到窗口的区域RECT,跟设备环境DC,自己画。
      

  2.   

    在你的CXXXView里用class wizard加入消息WM_ERASEBNGND消息,
    在对应的BOOL CXXXView::OnEraseBkgnd(CDC* pDC)里这样写:
     BOOL CAaView::OnEraseBkgnd(CDC* pDC) 
    {   CBrush Brush (RGB (128 , 0 , 128) );//你的颜色   CBrush* pOldBrush = pDC->SelectObject(&Brush);   CRect rcClip;
       pDC->GetClipBox(&rcClip);   pDC-> PatBlt (rcClip.left , rcClip.top , rcClip.Width ( ) , rcClip.Height( ) , PATCOPY );   pDC->SelectObject (pOldBrush );   return TRUE;
    }OK了.....
      

  3.   

    BOOL CBgColorDemoApp::InitInstance()
    {
    AfxEnableControlContainer();// Standard initialization
    // If you are not using these features and wish to reduce the size
    // of your final executable, you should remove from the following
    // the specific initialization routines you do not need.#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endifCBgColorDemoDlg dlg;
    m_pMainWnd = &dlg;
    //在这里加入背景颜色的设置,就一条语句,多简单,
    //前一个 RGB设置背景色,第二个RGB设置字体颜色SetDialogBkColor(RGB(000,204,255), RGB(255, 0,0));
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
    // TODO: Place code here to handle when the dialog is
    // dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
    // TODO: Place code here to handle when the dialog is
    // dismissed with Cancel
    }// Since the dialog has been closed, return FALSE so that we exit the
    // application, rather than start the application's message pump.
    return FALSE;
    }
      

  4.   

    怎 样 改 变 窗 口 背 景 色 
         SetColor( BACKGROUND, **** )函 数 可 以 改 变 窗 口 背 景 色 , 在 适 当 的 位 置 加 上 它 即 可 , 其 中 第 二 个 变 量 可 以 为 以 下 值 : 
         BK_BLUE BK_MAGENTA BK_PINK BK_YELLOW 
         BK_GREEN BK_ORANGE BK_RED 
         以 上 几 种 为 渐 变 色 
         BK_SOLIDBLACK BK_SOLIDMAGENTA BK_SOLIDRED 
         BK_SOLIDBLUE BK_SOLIDORANGE BK_SOLIDWHITE 
         BK_SOLIDGREEN BK_SOLIDPINK BK_SOLIDYELLOW 
         同 时 第 二 个 参 数 也 可 以 用 RGB来 描 述 , 如 SetColor( BACKGROUND, RGB(0,0,255) ) 
      

  5.   

    SetColor
    只有时间控件等有用
      

  6.   

    如果是sdi下继承CView,怎么改变它的背景色
      

  7.   

    怎样设置一个CFormView类的背景颜色?用ClassWizard,怎么找不到WM_ERASEBNGND?
      

  8.   

    呵呵,多了几句,重载WM_ERASEBNGND
    BOOL Csdi1View::OnEraseBkgnd(CDC* pDC)
    {
    CView::OnEraseBkgnd(pDC);
    CRect rect;
    GetClientRect(rect);
    pDC->FillSolidRect(&rect, RGB(0,255,0)); return TRUE;}
      

  9.   

    BOOL Csdi1View::OnEraseBkgnd(CDC* pDC)
    {

    CRect rect;
    GetClientRect(&rect);
    pDC->FillRect(&rect, RGB(0,255,0));
             return TRUE;}