Click here to Skip to main content
15,887,411 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, can somebody tell why the window is not closing by clicking close icon in title bar?
Posted

You have overridden WM_CLOSE (or Onclose) and prevent the default message handling.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-Apr-11 8:31am    
And this advice can be used even for raw Windows code, my 5.
Teamwork!
--SA
Albert Holguin 13-Apr-11 10:26am    
another thing that may cause this is overriding message handling methods (that affect all messages instead of just WM_CLOSE).... good answer though, my 5
Probably because the message handler is missing for the dialog.

Have a look here:
Windows Message Handling - Part 1[^]

Good luck!
 
Share this answer
 
Comments
Hans Dietrich 13-Apr-11 7:55am    
If the message map entry or message handler is missing, it would be passed to default handler, which would close it.
E.F. Nijboer 13-Apr-11 8:11am    
Correct, there is a message handler but this prevents the dialog from closing because the WM_CLOSE isn't handled properly.
Hans Dietrich 13-Apr-11 8:13am    
Exactly, which is what I said in my Solution 1.
Sergey Alexandrovich Kryukov 13-Apr-11 8:31am    
For MFC? Right, my 5.
--SA
There are a few ways to close windows:
1) Modal dialog: handle WM_CLOSE or WM_COMMAND and close the window by calling EndDialog.
2) Modeless windows (popup or overlapped) handle the WM_CLOSE message by DestroyWindow.
3) Application windows: handle the WM_CLOSE or any command by DestroyWindow and handle the WM_DESTROY by PostQuitMessage to end the message loop.
Regards.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900