home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!spool.mu.edu!umn.edu!staff.tc.umn.edu!kimmel
- From: kimmel@staff.tc.umn.edu (Eric Kimmel)
- Newsgroups: comp.os.ms-windows.programmer.misc
- Subject: Re: how to find parentless non-child windows?
- Message-ID: <1992Dec20.213229.12068@news2.cis.umn.edu>
- Date: 20 Dec 92 21:32:29 GMT
- References: <1992Dec19.022439.8466@emr1.emr.ca>
- Sender: news@news2.cis.umn.edu (Usenet News Administration)
- Organization: University of Minnesota
- Lines: 56
- Nntp-Posting-Host: staff.tc.umn.edu
-
- In article <1992Dec19.022439.8466@emr1.emr.ca> jagrant@emr1.emr.ca (John Grant) writes:
- >My app behaves a bit like a MDI app, but not quite. From the main
- >window, several other parentless non-child windows can be created as
- >follows:
- > CreateWindow("xxx",NULL,
- > WS_OVERLAPPED | WS_CAPTION |
- > WS_SYSMENU | WS_THICKFRAME |
- > WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
- > CW_USEDEFAULT,CW_USEDEFAULT,
- > CW_USEDEFAULT,CW_USEDEFAULT,
- > NULL, //note - no parent
- > NULL,
- > hinstance,(LPVOID)xxx);
- >
- >Note: they have *no parent* and they are *not* WS_CHILD.
- >
- >When I close the application from the main window, these secondary
- >windows do not receive WM_DESTROY (I breakpointed WM_DESTROY and
- >it never gets there). I guess the main window only sends WM_DESTROY
- >messages to them if they have a parent and/or if they are WS_CHILD?
- >Is that right?
- >
- >So, when I process WM_DESTROY for the main window, I want to find
- >all of the secondary windows and shut them down too (so they can
- >de-allocate their resources). I tried doing this when I get
- >WM_DESTROY for the main window:
- >
- > void DestroySecondaryWindows(void){
- > HWND hwnd;
- > while((hwnd=FindWindow("xxx",NULL)){
- > SendMessage(hwnd,WM_DESTROY,0,0);
- > }
- > return;
- > }
- >
- >Well, close but not quite. The secondary window receives several
- >WM_DESTROY messages, even though I am using 'Send' instead of 'Post'.
- >I guess I need to wait until each window is destroyed before I
- >try to 'find' another one? If so, how?
- >
- >I had a glance at GetWindow, but I'm a bit confused by it - should
- >I be using GetWindow instead of FindWindow? The problem is that the
- >secondary windows have *no parent*.
- >
- I'd use:
-
- PostMessage(hWnd,WM_CLOSE,0,0L);
-
- instead of your SendMessage. Additionally you can now redefine the WM_CLOSE
- command to do other stuff like ask the user for confirmation. If you don't
- redefine it, it calls DestroyWindow, which is what you want. -Rick
-
- >--
- >John A. Grant jagrant@emr1.emr.ca
- >Airborne Geophysics
- >Geological Survey of Canada, Ottawa
-