Search code examples
windowswinapimfcwindow-messages

What is the relationship of CloseWindow and WM_CLOSE


I'm a bit confused currently: Are WM_CLOSE and ::CloseWindow in any way "related" or are for completely different things?

The docs for Closing Windows don't mention the API function CloseWindow at all. Should CloseWindow be really called "MinimizeWindow" or what am I missing?


Solution

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