MFC & COM object - Programmer
This is a discussion on MFC & COM object - Programmer ; hi,
I created a project ATL to make automation with Outlook. Then I
included this project into a MFC project(a dialog is displayed during
the automation).
The dialog have a COM object in his private members.
When I stop the ...
-
MFC & COM object
hi,
I created a project ATL to make automation with Outlook. Then I
included this project into a MFC project(a dialog is displayed during
the automation).
The dialog have a COM object in his private members.
When I stop the automation I want the dialog to be closed
automatically, so I use AfxGetMainWnd()->SendMessage(WM_CLOSE).
My problem is that I have an error on this instruction.
I think I have to destroy my COM object but I don't know how.
could someone help me because it really drives me crazy...
thanks in advance
-
Re: MFC & COM object
Hallo cyan!
> I created a project ATL to make automation with Outlook. Then I
> included this project into a MFC project(a dialog is displayed during
> the automation).
> The dialog have a COM object in his private members.
>
> When I stop the automation I want the dialog to be closed
> automatically, so I use AfxGetMainWnd()->SendMessage(WM_CLOSE).
> My problem is that I have an error on this instruction.
> I think I have to destroy my COM object but I don't know how.
>
> could someone help me because it really drives me crazy...
> thanks in advance
Just use PostMessage(WM_CLOSE);
Using SendMessage(WM_CLOSE) is the same as directly using DestroyWindow.
The destructor is called imidiatly and all your member objects are
destroyed after this call. So using the this pointer again causes an
access violation.
--
Martin Richter [MVP] WWJD
"In C we had to code our own bugs. In C++ we can inherit them."
FAQ : http://www.mpdvc.de
Samples: http://www.codeguru.com http://www.codeproject.com