: : What message does a dialog box receive when the x (top right of a window) is pressed? It isn't WM_DESTROY like it is with the main window.Learning Win32 Api and some DirectX. How long did it take you to learn DirectX and the Windows API.
: What is it you trying to do?
: I think that [X] message depends on how dialog box was launched: if it is modal - I think you get the WM_COMMAND with IDCANCEL - in other words it mimics the pressing of CANCEL button, but I am not sure about that... if it is modeless - then you get the WM_CLOSE I think and then you close it as you do with regular windows - call 'DestroyWindow()'.
: It requires some research from your side: set a breakpoint in debugger at WM_COMMAND/WM_CLOSE and see what message is it and what parameters are passed by windows when you click on [X].
Is this what your looking for?
if(wParam == IDCANCEL) EndDialog(hWnd, 0);
Thats what I've been using & it seems to work fine.