CodeProject上的一些摘抄
来源:互联网 发布:php 文章内链 编辑:程序博客网 时间:2024/05/14 06:27
1.问题:
控件只读但不要背景变灰。解决方案:
(1)重载控件的WM_CTLCOLOR消息响应(ON_WM_CTLCOLOR_REFLECT())
HBRUSH CReadOnlyEdit::CtlColor(CDC* pDC, UINT nCtlColor) {// TODO: Return a non-NULL brush if the parent's //handler should not be called//set text colorpDC->SetTextColor(m_crText);//set the text's background colorpDC->SetBkColor(m_crBackGnd); //return the brush used for background this sets control background return m_brBackGnd;}
(2)重载控件的EN_SETFOCUS消息响应
Essentially, deriving your own class from CEdit would be the ideal way, but you say you don't want it. So, I have a silly hack for you.
Add a handler for EN_SETFOCUS
and voluntarily give away the focus there. This way, the user won't be able to type anything into it or modify it. Because he just cannot set the focus. But, with a member variable for the control, you will be able to manipulate it from within your program, essentially making it "read only".
void CTestDlg::OnEnSetfocusEdit1(){::SetFocus(m_hWnd);} void CTestDlg::OnBnClickedSetText(){m_Edit.SetWindowText(_T("Sample text"));}
0 0
- CodeProject上的一些摘抄
- codeproject的一些好文章
- 翻译CodeProject上的文章
- codeproject上发现的DataSet调试利器
- codeproject上发现的DataSet调试利器
- CodeProject上的几种Layout
- codeproject上发现的DataSet调试利器
- codeproject上发现的DataSet调试利器
- codeproject 上关于安全的文章
- 我在CodeProject上的第一篇文章
- CodeProject上的两个简单绘图程序
- 一些CSDN的摘抄
- 在CodeProject上看到的关于Extend Label的控件
- codeproject上看到的一个好的日历控件
- codeproject上看到的一个好的日历控件
- 一些摘抄!
- 一些摘抄
- 一些摘抄
- 数据库中插入不进数据现象
- 熵(信息论中)
- 本地管理表空间(LMT)
- 四元数
- php 上传文件到ftp上
- CodeProject上的一些摘抄
- Ubuntu中Git服务器搭建(做了修改)
- .NET中的Task
- google play v2支付修改 android:targetSdkVersion 这个大于11出现异常问题
- 黑马程序员_多线程
- HQL的多表查询 left jon 等 (需要配置一对多)
- 序列化和反序列化
- android 图库缓存问题
- 在安装flash player 时提示不是最新的版本 && 安装失败