tags:

views:

27

answers:

1

I got this class

class CWebBrowser2 : public CWnd

And i want to override OnClose What i have done so far is in the header file I added void OnClose(); and in the .cpp file i added

void CWebBrowser2::OnClose ()
{
        int i=0;
        i++;
}

But the OnClose is never called.

Then I tried to to modify the header file to

afx_msg void OnClose();
DECLARE_MESSAGE_MAP()

And added this to the .cpp file

BEGIN_MESSAGE_MAP(CWebBrowser2, CWnd)
    //{{AFX_MSG_MAP(CBrowserDlg)
    ON_WM_CLOSE()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

But still OnClose is never called. I have tried to Change to OnClose to OnDestroy but that isnt called either.

any ideas on what Im doing wrong?

+1  A: 

After adding the ON_WM_CLOSE() it should work. In which way are you closing the window?

In your header file of your class do you have this line? DECLARE_MESSAGE_MAP()

Brian R. Bondy