DestroyWindow( HWND hWnd ) doesnt kill window 
Author Message
 DestroyWindow( HWND hWnd ) doesnt kill window

I am trying to programmatically shut down a program by using EnumWindows to
get an HWND and then using the DestroyWindow function to kill it.  Why
doesnt this work and what else should I try?

Thanks,
Tony



Mon, 03 Feb 2003 03:00:00 GMT  
 DestroyWindow( HWND hWnd ) doesnt kill window

Quote:

>I am trying to programmatically shut down a program by using EnumWindows to
>get an HWND and then using the DestroyWindow function to kill it.

Send a WM_CLOSE message instead.

Quote:
>Why
>doesnt this work and what else should I try?

Because you didn't call CreateWindow; the other
process did.


Mon, 03 Feb 2003 03:00:00 GMT  
 DestroyWindow( HWND hWnd ) doesnt kill window
Not terribly surprising. Destroying a window destroys the window. It
has nothing to do with shutting down an application; that's a more
complex task. There is no reason that destroying a window should shut
down an application, and in fact if the app is multithreaded, it will
simply destroy a window but in no way cause the message loop to shut
down or kill any of the threads, so if you kill the main window you'll
get an invisible, but still running, application. Send WM_CLOSE.
That's the specified way to shut down an application. Note that the
application doesn't have to honor the WM_CLOSE! It is advisory, and an
application can override it, ignore it, or pop up a dialog demanding
confirmation (which may not be forthcoming).
                                joe



Quote:
>I am trying to programmatically shut down a program by using EnumWindows to
>get an HWND and then using the DestroyWindow function to kill it.  Why
>doesnt this work and what else should I try?

>Thanks,
>Tony

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Thu, 06 Feb 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to get HWND in ::GetDlgItem(HWND hDlg,ID_SECTIONS) before dlg.DoModal()

2. Question on HWND hDlg Parameter in ::SetDlgItemText(HWND hDlg, int nIDDlgItem, LPTSTR lpString, int nMaxCount)

3. How to get HWND in ::GetDlgItem(HWND hDlg,ID_SECTIONS) before dlg.DoModal()

4. HWND hWnd

5. Question on HWND hDlg Parameter in ::SetDlgItemText(HWND hDlg, int nIDDlgItem, LPTSTR lpString, int nMaxCount)

6. retrieving a HWND hWnd from a UINT wParam

7. Ever seen debug build HWND != release HWND

8. Retrieving the HWnd of an Explorer window

9. Hwnd of window (MFC bitmap bitmap control)

10. HWND For A Console Window

11. Way to clear window? given hWnd

12. Get the HWND handle from spawned window

 

 
Powered by phpBB® Forum Software