EM_SETREADONLY

来源:互联网 发布:粒子群算法工具箱下载 编辑:程序博客网 时间:2024/03/28 22:03

::SendMessage(CWnd::GetSafeHwnd(), EM_SETREADONLY, (WPARAM)(BOOL)TRUE, 0);

上面的消息可以设置Edit控件为只读属性。

 

想改窗口属性可用m_Edit.ModifyStyle(0,ES_READONLY)无效?  
  后来又改成  
    DWORD   dwStyle   =   ::GetWindowLong(m_eInputEnglish.m_hWnd,   GWL_STYLE);  
    DWORD   dwNewStyle   =(   dwStyle|   ES_READONLY);  
    if   (dwStyle   ==   dwNewStyle)  
      return   ;  
    ::SetWindowLong(m_eInputEnglish.m_hWnd,GWL_EXSTYLE,   dwNewStyle);  
  还是没有用?  

Note   :     For   some   styles   in   certain   controls   (the   ES_READONLY   style   in   the   edit   control,   for   example),   ModifyStyle   may   not   properly   change   the   style   because   the   control   may   need   to   perform   special   internal   processing.   In   these   cases,   a   corresponding   message   to   change   the   style   will   be   available   (EM_SETREADONLY   in   the   example   mentioned).  
   
  your   can   change   eidt   Style   as   below  
   
  ::SendMessage(m_ctlEdit.m_hWnd,EM_SETREADONLY,TRUE,0);