Determining if a window as been closed

I'm having trouble determining if a window has been closed (by the user pressing the "x" button) based on the window's handle. I *can* just try showing the window and checking for a failure, but there's obviously a better way than that.

-Pseudo
When a windows is being closed, windows will send your program a message WM_CLOSE
you may be able to use windows' synchronization functions. off the top of my head, I don't remember if they work with a window handle but if you are looking to see if a process has terminated they should work, and may work for a window handle as well.

http://msdn.microsoft.com/en-us/library/ms686353(VS.85).aspx

one of the 'waitfor...' functions may do the trick
Last edited on
A Window is not a synchronization object, you cannot "wait" for it.

guestgulkan is correct. You are notified with WM_CLOSE and have the opportunity to allow or disallow the close. That's where some applications display a message box asking for confirmation.
Use System Notifications to get notified for windows belonging to any process.
george135, you mean use a COM+ service to determine if a window is closing? I don't think so.
Topic archived. No new replies allowed.