Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
Hi, can somebody tell why the window is not closing by clicking close icon in title bar?
Posted 13-Apr-11 2:42am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You have overridden WM_CLOSE (or Onclose) and prevent the default message handling.
  Permalink  
Comments
SAKryukov at 13-Apr-11 8:31am
   
And this advice can be used even for raw Windows code, my 5.
Teamwork!
--SA
Albert Holguin at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Probably because the message handler is missing for the dialog.
 
Have a look here:
Windows Message Handling - Part 1[^]
 
Good luck!
  Permalink  
Comments
Hans Dietrich at 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 at 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 at 13-Apr-11 8:13am
   
Exactly, which is what I said in my Solution 1.
SAKryukov at 13-Apr-11 8:31am
   
For MFC? Right, my 5.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 14 Apr 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100