#define WM_CTLCOLORMSGBOX               0x0132
#define WM_CTLCOLOREDIT                 0x0133  //编辑控件Edit
#define WM_CTLCOLORLISTBOX              0x0134  //列表控件ListBox
#define WM_CTLCOLORBTN                  0x0135  //按钮控件BottonBox
#define WM_CTLCOLORDLG                  0x0136
#define WM_CTLCOLORSCROLLBAR            0x0137
#define WM_CTLCOLORSTATIC               0x0138  //静态框控件StaticEdit
//上面是系统定义的各种控件的颜色消息,要修改啥控件就捕获相应的消息
//WM_CTLCOLOREDIT 编辑控件Edit的实现 //自定义文本颜色和背景色 #define TEXTBKCOLOR RGB(224, 255, 255)//文字颜色 #define TEXTCOLOR RGB(0, 0, 255) //背景色 //在消息中捕获到消息; case WM_CTLCOLOREDIT: OnCtlColorEdit(wParam,lParam); break; //函数实现部分: INT_PTR MmApp::OnCtlColorEdit(WPARAM wParam, LPARAM lParam) { HWND hEdit1, hedit2; hEdit1 = ::GetDlgItem(m_hWnd, IDC_EDIT1); hedit2 = ::GetDlgItem(m_hWnd, IDC_EDIT2); HDC hDc = (HDC)wParam; if (hedit2 == (HWND)lParam||hEdit1==(HWND)lParam) { ::SetTextColor(hDc, TEXTCOLOR); //RGB(0, 0, 255) ::SetBkMode(hDc, OPAQUE); //TRANSPARENT,OPAQUE //说明:TRANSPARENT是设置背景透明,但是控件多行滚动时有重影, //还没弄明白,所以用的OPAOUE,这也不明白是啥玩意,但能达到目的就OK, ::SetBkColor(hDc, TEXTBKCOLOR); return (INT_PTR)CreateSolidBrush(TEXTBKCOLOR);//返回背景色的画刷 } ReleaseDC(hEdit1, hDc); ReleaseDC(hedit2, hDc); return 0; }

这就是今天学习修改Edit控件颜色的成果,弄了好久,头都弄大了,我饿了,要去吃饭去了,

修改后的样式;

 

版权声明:本文为greenleaf1976原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/greenleaf1976/p/14320601.html