What is the relationship of CloseWindow and WM_CLOSE
CloseWindow
is an unusually poorly named winapi function. It doesn't actually close a window, it just minimizes it. What you possibly meant was DestroyWindow()
.
WM_CLOSE
is normally a message that's generated by default window procedure, in response to the user pressing Alt+F4 or clicking the window's close button. The underlying message is WM_SYSCOMMAND
, SC_CLOSE
. It can be generated in code as well, like a Window + Close menu item.
You can listen for WM_CLOSE
in your window procedure or the MFC message map. The user will expect the window to be closed. So you normally call DestroyWindow()
. You don't have to, you might display a message box for example and ask the user if data should be saved. And if he clicks No then you don't call DestroyWindow()
.
CloseWindow
and WM_CLOSE
are completely unrelated. The CloseWindow
function is badly named. Its inverse function, OpenWindow
is similarly badly named given that it restores windows.
I suspect these names dates back a very long way indeed, probably to Windows version 1 or 2. I'm speculating that what we now call minimize and restore were, back then, called close and open.
The usual way to minimize or restore a window is to call ShowWindow
passing SW_MINIMIZE
or SW_RESTORE
.
I suggest that you forget all about CloseWindow
and OpenWindow
.