<i id='JbC8y'><tr id='JbC8y'><dt id='JbC8y'><q id='JbC8y'><span id='JbC8y'><b id='JbC8y'><form id='JbC8y'><ins id='JbC8y'></ins><ul id='JbC8y'></ul><sub id='JbC8y'></sub></form><legend id='JbC8y'></legend><bdo id='JbC8y'><pre id='JbC8y'><center id='JbC8y'></center></pre></bdo></b><th id='JbC8y'></th></span></q></dt></tr></i><div id='JbC8y'><tfoot id='JbC8y'></tfoot><dl id='JbC8y'><fieldset id='JbC8y'></fieldset></dl></div>
  • <small id='JbC8y'></small><noframes id='JbC8y'>

  • <legend id='JbC8y'><style id='JbC8y'><dir id='JbC8y'><q id='JbC8y'></q></dir></style></legend>

  • <tfoot id='JbC8y'></tfoot>
      <bdo id='JbC8y'></bdo><ul id='JbC8y'></ul>

      1. MFC:更改 CEdit 的颜色

        时间:2023-07-02
        <tfoot id='noJxQ'></tfoot>
          <tbody id='noJxQ'></tbody>
          <legend id='noJxQ'><style id='noJxQ'><dir id='noJxQ'><q id='noJxQ'></q></dir></style></legend>

          <small id='noJxQ'></small><noframes id='noJxQ'>

            <i id='noJxQ'><tr id='noJxQ'><dt id='noJxQ'><q id='noJxQ'><span id='noJxQ'><b id='noJxQ'><form id='noJxQ'><ins id='noJxQ'></ins><ul id='noJxQ'></ul><sub id='noJxQ'></sub></form><legend id='noJxQ'></legend><bdo id='noJxQ'><pre id='noJxQ'><center id='noJxQ'></center></pre></bdo></b><th id='noJxQ'></th></span></q></dt></tr></i><div id='noJxQ'><tfoot id='noJxQ'></tfoot><dl id='noJxQ'><fieldset id='noJxQ'></fieldset></dl></div>
            • <bdo id='noJxQ'></bdo><ul id='noJxQ'></ul>

                  本文介绍了MFC:更改 CEdit 的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  伙计们,谁能简要介绍一下如何在运行时更改 CEdit 控件的背景颜色?如果字段长度为零,我希望能够将背景更改为红色,否则为正常白色.

                  Guys, can someone give me a brief run through of how to change the background colour of a CEdit control at runtime? I want to be able to change the background to red if the field is zero length and the normal white otherwise.

                  推荐答案

                  你不能用一个普通的 CEdit 来完成,你需要覆盖一些位.

                  You cannot do it with a plain CEdit, you need to override a few bits.

                  实现您自己的 ON_WM_CTLCOLOR_REFLECT 处理程序,然后在处理程序中返回您的彩色 CBrush:

                  Implement your own ON_WM_CTLCOLOR_REFLECT handler, then return your coloured CBrush in the handler:

                  (粗略地说,你需要把常用的资源管理放在那里,记住在析构函数中删除你的画笔)

                  (roughly, you'll need to put the usual resource management in there, rememebr to delete your brush in the destructor)

                  class CColorEdit : public CEdit
                  {
                    ....
                    CBrush   m_brBkgnd;
                    afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor)
                    {
                      m_brBkgnd.DeleteObject();
                      m_brBkgnd.CreateSolidBrush(nCtlColor);
                    }
                  }
                  

                  这篇关于MFC:更改 CEdit 的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:VS2003 C++ 中异常的堆大小限制 下一篇:不可复制的对象和值初始化:g++ 与 msvc

                  相关文章

                  <small id='thafY'></small><noframes id='thafY'>

                1. <tfoot id='thafY'></tfoot>
                  <legend id='thafY'><style id='thafY'><dir id='thafY'><q id='thafY'></q></dir></style></legend>

                  • <bdo id='thafY'></bdo><ul id='thafY'></ul>

                    1. <i id='thafY'><tr id='thafY'><dt id='thafY'><q id='thafY'><span id='thafY'><b id='thafY'><form id='thafY'><ins id='thafY'></ins><ul id='thafY'></ul><sub id='thafY'></sub></form><legend id='thafY'></legend><bdo id='thafY'><pre id='thafY'><center id='thafY'></center></pre></bdo></b><th id='thafY'></th></span></q></dt></tr></i><div id='thafY'><tfoot id='thafY'></tfoot><dl id='thafY'><fieldset id='thafY'></fieldset></dl></div>