给类CXXFormView添加一个CBrush类的成员变量m_brush  
  然后在其构造函数中加m_brush.CreateSolidBrush(RGB(255,255,255));  
  如我的CXXFormView类  
  CPackInterView::CPackInterView()  
  :   CFormView(CPackInterView::IDD)  
  {  
  //{{AFX_DATA_INIT(CPackInterView)  
  //}}AFX_DATA_INIT  
  m_brush.CreateSolidBrush(RGB(255,255,255));//设为白色  
  }  
  接着映射一个WM_CTLCOLOR消息,在ClassWizard中添加.在OnCtlColor中如下设置即可  
  HBRUSH   CPackInterView::OnCtlColor(CDC*   pDC,   CWnd*   pWnd,   UINT   nCtlColor)    
  {  
  HBRUSH   hbr   =   CFormView::OnCtlColor(pDC,   pWnd,   nCtlColor);  
   
  //   TODO:   Change   any   attributes   of   the   DC   here  
  if(nCtlColor==CTLCOLOR_DLG)  
  return   (HBRUSH)m_brush.GetSafeHandle();  
  //   TODO:   Return   a   different   brush   if   the   default   is   not   desired  
  return   hbr;  
  }   
   
Posted on 2007-04-12 10:19 艾凡赫 阅读(2369) 评论(0)  编辑 收藏 引用 所属分类: MFC技术

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理