Re: Question of newbie: why an Avs occurs?
jin jian wrote:
Hi,
Can I replace a class simply with its subclass?
I have done some test like this:
First I define a subclass of CEdit.
class CWzdEdit:public CEdit{
BOOL PreTranslateMessage(MSG *pMsg);
};
BOOL CWzdEdit::PreTranslateMessage(MSG *pMsg)
{
return CEdit::PreTranslageMessage(pMsg);
}
Then I place two edit control on the dialog with the resource editor and
generate the DoDataExchange. Then I replace the "CEdit" with "CWzdEdit".
class CWzdDialog : public CDialog{
public:
CWzdEdit m_ctrlWzd1;
CWzdEdit m_ctrlWzd2;
virtual void DoDataExchange(CDataExchange* pDX);
};
void CWzdDialog::DoDataExchange(CDataExchange* pDX){
DDX_Control(pDX, IDC_EDIT_WZD1, m_ctrlWzd1);
DDX_Control(pDX, IDC_EDIT_WZD2, m_ctrlWzd2);
}
But an AVs occurs after I close the dialog even I do nothing. What's wrong
with my code?
Thank in advanced.
bucher
bucher:
I do not see any problem with what you have shown us. Where does this
access violation occur?
David Wilkinson