举个例子:
我喜欢.Net的方法,编写方便。class CEditEx : public CEdit
{
public:
      CEditEx();public:
  __declspec(property(get=_GetText,put=_SetText)) CString m_strText;CString _GetText(void)
{
   GetWindowText(m_strText);
   return m_strText;
}void _SetText(CString psz)
{
  SetWindowText(psz);
}
}现在可以 MessageBox(m_strText); 或 m_strText = _T("Test");
这样就可以想.net一样方法变量来获取内容了。
但现在我如果从网上找一个 Edit控件,那我要把基类改成 CEditEx,这还好说。
但除了编辑框以外 按钮,富文本框,组合框都可以使用这个类里的函数。不可能让我去修改CWnd类 或 CEdit类吧。更不可能让我给每种控件都去写个这样的类。求各位高手给予指点。