已定义一个CEdit变量m_edit
根据这个变量m_edit,如何设置它的背景色?

解决方案 »

  1.   

    EDITBOX Element
    The EDITBOX element provides a way for users to enter text within a skin.The EDITBOX element supports the following attributes.Attribute Description 
    backgroundColor Specifies or retrieves the background color for the edit box control. 
    border Specifies or retrieves a value indicating whether the edit box control has a border. 
    editStyle Specifies or retrieves the style of the edit box control. 
    fontFace Specifies or retrieves the font used for text in the edit box control. 
    fontSize Specifies or retrieves the font size for the edit box control. 
    fontStyle Specifies or retrieves the font style for the edit box control. 
    foregroundColor Specifies or retrieves the text color in the edit box control. 
    justification Specifies or retrieves the alignment of the text within the edit box control. 
    lineCount Retrieves the number of lines in the edit box control. 
    readOnly Specifies or retrieves a value indicating whether text in the edit box control is read-only or can be edited. 
    textLimit Specifies or retrieves the maximum number of characters that the user can type in the edit box control. 
    value Specifies or retrieves the text that is displayed in the edit box control. 
    wordWrap Specifies or retrieves a value indicating whether word wrap is enabled in the edit box control. 
    The EDITBOX element supports the following methods.Method Description 
    getLine Retrieves the text for the line with the specified index. 
    getLineFromChar Retrieves the line index for the specified character index. 
    getLineIndex Retrieves the character index for the specified line index. 
    getSelectionEnd Retrieves the ending position of the selected text in the edit box control. 
    getSelectionStart Retrieves the starting position of the selected text in the edit box control. 
    replaceSelection Replaces the current selection with the specified text. 
    setSelection Selects the text in the edit box control from the specified start index to the specified end index. 
    The EDITBOX element supports the ambient attributes and can implement all ambient event handlers with the exception of onclick. For more information, see Ambient Attributes and Ambient Event Handlers.这是MSDN 上关于EDITBOX 的原话,楼主仔细看看就明白了,我多说了也是废话
      

  2.   

    可以在你的Dialog加上一个成员变量CBrush m_b;
    Dialog构造函数中m_b.CreateSolidBrush(RGB(0,255,0));
    重载WM_CTLCOLOR消息,在OnCtlColor函数中加上
    if(nCtlColor==CTLCOLOR_EDIT)return m_b;
      

  3.   

    akiko(弥弥):如何实现动态变换背景色呢?就是可以从CColorDialog选颜色,然后背景色随着变?关注
      

  4.   

    akiko,WM_CTLCOLOR这个消息会使得在这个Dialog上的全部Edit Box改变背景色的吧?
    如果我只想部分的编辑框改变呢?
      

  5.   

    使用CBrush的话
    好象不能把编辑框全部画满背景色啊
    只有显示文字的那一行有颜色
      

  6.   

    OnCtlColor函数里这么写
    if(pWnd->GetDlgCtrlID()==IDC_EDIT1)return m_b;
      

  7.   

    这个“WM_CTLCOLOR”消息和“=WM_CTLCOLOR”消息有什么不同?
    akiko,你的方法是可行的,但是OnCtlColor这个函数应该怎么调用?
    怎样PostMessage才能使得处理的是相应的编辑框?
    谢谢
      

  8.   

    最好是从CEdit继成一个类
    然后重载CtlColor函数
    在里面修改