怎么让CEditCtrl控件是flat风格的,而且带边框?背景和边框颜色怎么弄?

解决方案 »

  1.   

    背景色可以在派生类中处理,也可以在父窗口中处理给对话框添加WM_CTLCOLOR消息映射函数
    HBRUSH CTest6Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    switch(nCtlColor)
    {
    case CTLCOLOR_EDIT:
    if(pWnd->GetDlgCtrlID() == IDC_EDIT1)
    {
    static HBRUSH hbrEdit = ::CreateSolidBrush( RGB(255, 0, 0) );
    pDC->SetBkMode(TRANSPARENT);
    pDC->SetBkColor( RGB(0, 0, 255) );
    pDC->SetTextColor( RGB(0, 255, 0) );
    return hbrEdit;
    } // TODO: Return a different brush if the default is not desired
    return hbr;
    }
    至于边框颜色,则只有在派生类中自绘了。。
      

  2.   

    自己做太费时了,而且效果不好。
    到www.codeproject.com 下个 CButtonST 类,功能很强,使用简单,目前常见的按钮效果几乎都支持。
      

  3.   

    这个是我用的float编辑控件,要带边框和背景在该类的 DrawEdit 函数中稍作修改就能实现http://codeproject.com/editctrl/editflat.asp
      

  4.   

    去掉WS_BORDER加上WS_EX_STATICEDGE样式