Add OnButton Function Error (MFC)
Hi,
When I double click on a button of my dialog in the resource view in order to automatically add the fuction handling the action of the button, the error message apears as "Add/remove the function is impossible, because the parent class is read only". I don't know what I have done wrong. The dialog code and resource was created automatically by the Visual Studio.net 2003 wizard.
Any suggestion please?
Monch
[447 byte] By [
Monch] at [2007-11-19 7:40:06]

# 2 Re: Add OnButton Function Error (MFC)
Take a look at the class files (h and cpp) and check if they are by any chances read-only.
Even I have made sure that all of my files are not read only, the error message still appears. However, I figured out how to solve it. I found my additional code on the wrong possition in message-map macro. Thanks anyway for your suggestion.
This code order causes the error.
BEGIN_MESSAGE_MAP(CTestHookDlg, CDialog)
ON_WM_CLOSE()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
// My additional code begin here
{ WM_HOOK_SHOWWINDOW1, 0, 0, 0, AfxSig_lwl, \
(AFX_PMSG)(AFX_PMSGW) \
(static_cast< VOID (AFX_MSG_CALL CTestHookDlg::*)(WPARAM, LPARAM) > \
(OnHookShowwindow)) },
// My additional code end here
END_MESSAGE_MAP()
Just move the additional code to the begining of message-map macro will solves the error.
BEGIN_MESSAGE_MAP(CTestHookDlg, CDialog)
// My additional code begin here
{ WM_HOOK_SHOWWINDOW1, 0, 0, 0, AfxSig_lwl, \
(AFX_PMSG)(AFX_PMSGW) \
(static_cast< VOID (AFX_MSG_CALL CTestHookDlg::*)(WPARAM, LPARAM) > \
(OnHookShowwindow)) },
// My additional code end here
ON_WM_CLOSE()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Monch at 2007-11-11 0:27:46 >
