一个sdi应用程序 为了根本改变背景颜色
在CMyView::PreCreateWindow(CREATESTRUCT& cs)
重新注册窗口类 这个窗口类要怎么写?
能否取得原来的窗口类 更改 hbrBackground就可以了

解决方案 »

  1.   

    BOOL CDcsClientView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
    // 样式
    WNDCLASS wndclass; if (GetClassInfo(AfxGetInstanceHandle(),cs.lpszClass,&wndclass))
    {
    wndclass.hbrBackground = CreateSolidBrush(COLOR_WINDOW);
    RegisterClass(&wndclass);
    } return CView::PreCreateWindow(cs);
    }
    什么地方出错了?
      

  2.   

    在CDcsClientView的OnEreaseBackground去重画背景色。
      

  3.   

    BOOL CMiniDrawView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs
    m_ClassName=AfxRegisterWndClass
    (CS_HREDRAW|CS_VREDRAW,
     0,
     (HBRUSH)::GetStockObject(WHITE_BRUSH),
     0);
    cs.lpszClass=m_ClassName;
    return CView::PreCreateWindow(cs);
    }