🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #2030

how to find parentless non-child windows?

#2030
From: John Grant
Date: Sat, 19 Dec 1992 02:24
47 lines
2065 bytes
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*.

-- 
John A. Grant						jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa
Technical Details
Message-ID: <1992Dec19.022439.8466@emr1.emr.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!torn!nott!emr1!jagrant

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!torn!nott!emr1!jagrant
From: jagrant@emr1.emr.ca (John Grant)
Subject: how to find parentless non-child windows?
Message-ID: <1992Dec19.022439.8466@emr1.emr.ca>
Organization: Energy, Mines, and Resources, Ottawa
Date: Sat, 19 Dec 1992 02:24:39 GMT
Lines: 47