[Win32 api] Can't close dialog (main window)

Hello,

I've come accross this problem several times, but well it fixed itself somehow, I have no idea how, and it was working 15 min ago, simply, when I click on "X", the dialog won't close (dialog is my main window)

source code:

http://pastebin.com/2Bs1F0mp
Last edited on
You need to return TRUE (or 1) after calling PostQuitMessage();
also I don't think you need WM_DESTROY only WM_CLOSE because you are using a dialog just call EndDialog(hWnd,0); inside of WM_CLOSE
Last edited on
some advices by andywestken when I was learning winapi:

- DestroyWindow() results in a WM_DESTROY message
- The WM_DESTROY calls PostQuitMessage (as yours already does)

CreateDialog is used to create a modeless dialog, which allows other windows to function while it's displayed. It has to be destroyed using DestroyWindow

DialogBox is used to create a modal dialog, which disables the other application windows until is is close. This type of dialog is closed by a call to EndDialog from inside the dialog proc.


therefore when I'm using CreateDialog - I have to use WM_DESTROY


anyway returning 1 don't works and I've been using CreateDialog with WM_DESTROY for a long time, and it worked so far, just several times not but I have no idea how I fixed that
Topic archived. No new replies allowed.