1.子类化是将一个控件资源映射到一个控件类中,比如一个按钮IDC_BUTTON映射到类CMyButton。
2.控件子类化后,消息由MFC同一的窗口过程AfxWndProc统一进行消息路由,消息首先路由到子类,再向父对话框路由。
3.可以使用DDX机制进行子类化:
DDX_Control(pDX, IDC_PORT, m_myButton); //m_myButton是CMyButton的对象
4.可以用SubClassDlgItem手动子类化:
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// IDC_BUTTON1 is the ID for a button on the
// dialog template used for CAboutDlg.
m_myButton.SubclassDlgItem(IDC_BUTTON1, this);
return TRUE; // Return TRUE unless you set the focus to a control
}
5.DDX_Control会调用SubClassDlgItem