Hi
I have an MFC DLL thats called by another application. When I hit Alt-F4 on the parent window, it closes itself and my MFC DLL application as well.
I have been trying to implement the same from my MFC DLL application as well. i.e. When I hit Alt+F4 from my MFC DLL app, it should close itself and the calling application as well.
I've tried the following in the OnClose message handler of the MFC DLL application:
1. DestroyWindow(GetParent()->m_hWnd);
2. DestroyWindow(AfxGetMainWnd()->GetParent()->m_hWnd);
3. DestroyWindow(AfxGetMainWnd()->m_hWnd);
4. PostMessage(AfxGetMainWnd()->m_hWnd, WM_SYSCOMMAND, SC_CLOSE, NULL);
However, none of them seems to be working: When I hit Alt+F4, the MFC DLL application closes followed by a crash message from Windows.
A quick reply would help immensely.
Thanks.
|
Go4Expert Founder
|
![]() |
| 16Nov2007,19:01 | #2 |
|
Try sending the WM_CLOSE message
|
|
Newbie Member
|
|
| 16Nov2007,19:30 | #3 |
|
Are you saying
PostMessage(AfxGetMainWnd()->m_hWnd, WM_CLOSE, SC_CLOSE, NULL); |
|
Newbie Member
|
|
| 16Nov2007,19:30 | #4 |
|
Are you saying
PostMessage(AfxGetMainWnd()->m_hWnd, WM_CLOSE, NULL, NULL); |
|
Newbie Member
|
|
| 16Nov2007,19:35 | #5 |
|
I tried WM_CLOSE. But it still crashes.
|
|
Go4Expert Founder
|
![]() |
| 16Nov2007,22:45 | #6 |
|
Even Alt + F4 crashes so I think there is some problem in the cleanup of your code.
|

