home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / misc / 4360 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.0 KB  |  57 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!cs.utexas.edu!torn!nott!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: how to find parentless non-child windows?
  5. Message-ID: <1992Dec19.022439.8466@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. Date: Sat, 19 Dec 1992 02:24:39 GMT
  8. Lines: 47
  9.  
  10. My app behaves a bit like a MDI app, but not quite.  From the main
  11. window, several other parentless non-child windows can be created as
  12. follows:
  13.     CreateWindow("xxx",NULL,
  14.             WS_OVERLAPPED  | WS_CAPTION    |
  15.             WS_SYSMENU     | WS_THICKFRAME |
  16.             WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
  17.             CW_USEDEFAULT,CW_USEDEFAULT,
  18.             CW_USEDEFAULT,CW_USEDEFAULT,
  19.             NULL,           //note - no parent
  20.             NULL,                           
  21.             hinstance,(LPVOID)xxx);
  22.  
  23. Note: they have *no parent* and they are *not* WS_CHILD.
  24.  
  25. When I close the application from the main window, these secondary
  26. windows do not receive WM_DESTROY (I breakpointed WM_DESTROY and
  27. it never gets there).  I guess the main window only sends WM_DESTROY
  28. messages to them if they have a parent and/or if they are WS_CHILD?
  29. Is that right?
  30.  
  31. So, when I process WM_DESTROY for the main window, I want to find
  32. all of the secondary windows and shut them down too (so they can
  33. de-allocate their resources).  I tried doing this when I get
  34. WM_DESTROY for the main window:
  35.  
  36.   void DestroySecondaryWindows(void){
  37.   HWND hwnd;
  38.     while((hwnd=FindWindow("xxx",NULL)){
  39.       SendMessage(hwnd,WM_DESTROY,0,0);
  40.     }
  41.     return;
  42.   }
  43.  
  44. Well, close but not quite.  The secondary window receives several
  45. WM_DESTROY messages, even though I am using 'Send' instead of 'Post'.
  46. I guess I need to wait until each window is destroyed before I
  47. try to 'find' another one?  If so, how?  
  48.  
  49. I had a glance at GetWindow, but I'm a bit confused by it - should
  50. I be using GetWindow instead of FindWindow?  The problem is that the
  51. secondary windows have *no parent*.
  52.  
  53. -- 
  54. John A. Grant                        jagrant@emr1.emr.ca
  55. Airborne Geophysics
  56. Geological Survey of Canada, Ottawa
  57.