
background color of CEdit control
Quote:
> I use Visual C++ 6.0.
> I'm developing a design program. I have a class that rapresents a
> rectangle. This class have a CEdit object called m_MyEdit.
> How I can control the backgroung color of m_MyEdit?
Handle the WM_CTLCOLOR/CTLCOLOR_EDIT message.
Quote:
> The MFC help say that I must rewrite the virtual handler OnCtlColor,
> but if I make a new Class CMyEdit, which was inherited from CEdit, and
> I run the debug, I never go inside this OnCtlColor function.
> Is the message pass to the base class CEdit and not to my class
> CMyEdit?
You should use the ClassWizard to add a message handler for the
reflected (=WM_CTLCOLOR) message to your CMyEdit class. See the
following URL...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmf...
Quote:
> Do I have to use SubClassDlgItem?
You should use the ClassWizard to map a control member variable of your
CMyEdit class to the EDIT control if at all possible. But you can use
SubclassDlgItem.
Quote:
> The help suggests to use SubClassDlgItem in OnCreate function of View
> class. But this is the case in which I know how many items I attach to
> this view, and it not is the my case. In fact the user can draws this
> CMyEdit controls during the program running.
> How I can risolve this problem?
If you are creating them dynamically, you should call the Create or
CreateEx member function through an instantiated instance of a CMyEdit
class. In this case you do not need to SubclassDlgItem or map a control
member variable.
Quote:
> And what about to create a CEdit control with a trasparent color (the
> user can moves the object also over the Cedit control)?
No not really, although I did manage to implement a version that seems
to work beautifully on Win2000/XP, it does not work well on any of the
16-bit platforms, nor has it ever been used in production code.
--
Jeff Partch [VC++ MVP]