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.
相关问题
- how to call a C++ dll from C# windows application
- efficiently calling unmanaged method taking unmana
- DBGrid - How to set an individual background color
- Why is my COM factory never released during the pr
- Create CFrameWnd gives first-chance exceptions--wh
相关文章
- Emacs/xterm color annoyance on Linux
- C++: Callback typedefs with __stdcall in MSVC
- matplotlib bwr-colormap, always centered on zero
- Is it possible to check whether you are building f
- Which VC++ redistributable package to choose (x86
- MeshLab: How to import XYZRGB file
- MFC CListView响应HDN_ITEMCHANGING后改变列宽无法自动显示隐藏水平滚动条
- How can I handle the Return key in a CEdit control
This can also be done without deriving from CEdit:
ON_WM_CTLCOLOR()
to your dialog'sBEGIN_MESSAGE_MAP()
code block.Add
OnCltColor()
to your dialog class:Implement
OnCtlColor()
like so:You cannot do it with a plain CEdit, you need to override a few bits.
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)