我建立了一个单文档程序,并把窗口分割成了2个子窗口,左边是树形目录,右边是用来显示文字的,右边的子窗口派生于CEditView,并且里面的文字是用SetWindowText输出的,我现在要改变里面文字的颜色和字体。不知道怎么改,试了N种方法没一个行。我在崩溃的边缘。 
问题补充:OnCtrlColore消息我用过,不能改,如果用TextOut可以用OnCtrlColore消息改颜色。但用SetWindowText不行

解决方案 »

  1.   

    在视图类中反射WM_CTLCOLOR消息:
    BEGIN_MESSAGE_MAP(CYourView, CEditView)
    ON_WM_CTLCOLOR_REFLECT()
    END_MESSAGE_MAP()HBRUSH CYourView::CtlColor(CDC* pDC, UINT nCtlColor)
    {
    pDC->SetTextColor(RGB(255,255,0));
    pDC->SetBkColor(RGB(0,0,255));
    return CreateSolidBrush(RGB(0,0,255));
    }
      

  2.   

    1楼的方法我已经试过了改不了,如果用TextOut输出文本的话就可以用WM_CTLCOLOR消息改。但我想用SetWindowText输出。
      

  3.   

    我说的是反射,不是直接响应WM_CTLCOLOR消息。CtlColor不是OnCtlColor。
      

  4.   

    下面是代码
    void CEditPaneView3::OnInitialUpdate() 
    {
    CEditView::OnInitialUpdate();

    // TODO: Add your specialized code here and/or call the base class
    SetWindowText("算法设计");
    }
    HBRUSH CEditPaneView3::CtlColor(CDC* pDC, UINT nCtlColor) 
    {
    // TODO: Change any attributes of the DC here
    pDC->SetTextColor( RGB(255,0,0) );//设置文本颜色  pDC->SetBkColor( RGB(0,255,0) );//设置背景颜色 
    // TODO: Return a non-NULL brush if the parent's handler should not be called
    return NULL;
    }
      

  5.   

    是你最后return NULL的问题。我早就把代码贴出来,为什么不复制过去试一下?
    pDC->SetTextColor(RGB(255,255,0));
    pDC->SetBkColor(RGB(0,0,255));
    return CreateSolidBrush(RGB(0,0,255));