I am writing an ActiveX control for a webpage using MFC. When the explorer closes, some resource must be freed before the main control window is destroyed. I did a search and found that the overridden function COleControl::OnClose(DWORD dwSaveOption) should be a good place to do the release task. Therefore, the following changes were made to my code:
Add the following line to my control declaration in the header file:
virtual void OnClose (DWORD dwSaveOption);
Add the following lines to the control file:
void MyControl :: OnClose (DWORD dwSaveOption)
{
// some code that do relesing job
COleControl :: OnClose (dwSaveOption);
}
I think that when closing the explorer MyControl :: OnClose should execute, but that is not the case. Am I missing something to override the function correctly, or is the OnClose function not suitable for this?
source share