home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / misc / 4379 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.5 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!spool.mu.edu!umn.edu!staff.tc.umn.edu!kimmel
  2. From: kimmel@staff.tc.umn.edu (Eric Kimmel)
  3. Newsgroups: comp.os.ms-windows.programmer.misc
  4. Subject: Re: how to find parentless non-child windows?
  5. Message-ID: <1992Dec20.213229.12068@news2.cis.umn.edu>
  6. Date: 20 Dec 92 21:32:29 GMT
  7. References: <1992Dec19.022439.8466@emr1.emr.ca>
  8. Sender: news@news2.cis.umn.edu (Usenet News Administration)
  9. Organization: University of Minnesota
  10. Lines: 56
  11. Nntp-Posting-Host: staff.tc.umn.edu
  12.  
  13. In article <1992Dec19.022439.8466@emr1.emr.ca> jagrant@emr1.emr.ca (John Grant) writes:
  14. >My app behaves a bit like a MDI app, but not quite.  From the main
  15. >window, several other parentless non-child windows can be created as
  16. >follows:
  17. >    CreateWindow("xxx",NULL,
  18. >            WS_OVERLAPPED  | WS_CAPTION    |
  19. >            WS_SYSMENU     | WS_THICKFRAME |
  20. >            WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
  21. >            CW_USEDEFAULT,CW_USEDEFAULT,
  22. >            CW_USEDEFAULT,CW_USEDEFAULT,
  23. >            NULL,           //note - no parent
  24. >            NULL,                           
  25. >            hinstance,(LPVOID)xxx);
  26. >
  27. >Note: they have *no parent* and they are *not* WS_CHILD.
  28. >
  29. >When I close the application from the main window, these secondary
  30. >windows do not receive WM_DESTROY (I breakpointed WM_DESTROY and
  31. >it never gets there).  I guess the main window only sends WM_DESTROY
  32. >messages to them if they have a parent and/or if they are WS_CHILD?
  33. >Is that right?
  34. >
  35. >So, when I process WM_DESTROY for the main window, I want to find
  36. >all of the secondary windows and shut them down too (so they can
  37. >de-allocate their resources).  I tried doing this when I get
  38. >WM_DESTROY for the main window:
  39. >
  40. >  void DestroySecondaryWindows(void){
  41. >  HWND hwnd;
  42. >    while((hwnd=FindWindow("xxx",NULL)){
  43. >      SendMessage(hwnd,WM_DESTROY,0,0);
  44. >    }
  45. >    return;
  46. >  }
  47. >
  48. >Well, close but not quite.  The secondary window receives several
  49. >WM_DESTROY messages, even though I am using 'Send' instead of 'Post'.
  50. >I guess I need to wait until each window is destroyed before I
  51. >try to 'find' another one?  If so, how?  
  52. >
  53. >I had a glance at GetWindow, but I'm a bit confused by it - should
  54. >I be using GetWindow instead of FindWindow?  The problem is that the
  55. >secondary windows have *no parent*.
  56. >
  57. I'd use:
  58.  
  59. PostMessage(hWnd,WM_CLOSE,0,0L);
  60.  
  61. instead of your SendMessage.  Additionally you can now redefine the WM_CLOSE
  62. command to do other stuff like ask the user for confirmation.  If you don't
  63. redefine it, it calls DestroyWindow, which is what you want.  -Rick
  64.  
  65. >-- 
  66. >John A. Grant                        jagrant@emr1.emr.ca
  67. >Airborne Geophysics
  68. >Geological Survey of Canada, Ottawa
  69.